HDDS-15342. Make RocksDB bottommost level compaction options configurable for background compaction#10419
Conversation
| </property> | ||
| <property> | ||
| <name>ozone.om.compaction.service.bottommostlevelcompaction</name> | ||
| <value>0</value> |
There was a problem hiding this comment.
Can we use kSkip/kForce for better readability.
There was a problem hiding this comment.
While I agree that a string option will be more readable, I have kept it this way because I want to use the native org.rocksdb.CompactRangeOptions.BottommostLevelCompaction#fromRocksId method.
That method converts an integer to compaction type. There is no method that RocksDB provides that converts a string to target compaction type.
The reason for keeping it this way is that I want to avoid writing and updating our custom method as and when RocksDB provides new compaction type options.
For example, the latest RocksDB already has a kForceOptimized option which our current version doesn't support. I want to avoid creating such manual mappings and validations in Ozone code.
In case we fail to provide a mapping for some future option, we will not be able to use that option even if RocksDB supports it.
As a compromise, the helper text provides the relevant information that is needed.
There was a problem hiding this comment.
I want to avoid writing and updating our custom method as and when RocksDB provides new compaction type options
No custom method is needed if the config value is converted to enum BottommostLevelCompaction using Configuration.getEnum instead getInt.
There was a problem hiding this comment.
I have updated the code to use getEnum
There was a problem hiding this comment.
getEnum expects enum names with this change. Please update the value as well as the description.
sarvekshayr
left a comment
There was a problem hiding this comment.
Thanks @ptlrs for working on this.
…configuration logic.
…nfiguration and update its default type.
|
Failed acceptance (tools) CI - |
ashishkumar50
left a comment
There was a problem hiding this comment.
@ptlrs Thanks for the update, LGTM.
|
@ptlrs Can you please look at test failure, looks related. |
|
@ashishkumar50 as @sarvekshayr had also observed, this PR depends on #10428 which fixes the failing Robot test. Can we please merge that first? I may need to pull the changes in this PR after that. |
…ocksDB-BottommostLevelCompaction-options-configurable # Conflicts: # hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/CompactDBUtil.java # hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/CompactionService.java
… in OzoneManager.
|
Hi @ashishkumar50 @sarvekshayr, could you please take another look? I have merged the changes from master. The robot test should now pass. |
| </property> | ||
| <property> | ||
| <name>ozone.om.compaction.service.bottommostlevelcompaction</name> | ||
| <value>0</value> |
There was a problem hiding this comment.
I want to avoid writing and updating our custom method as and when RocksDB provides new compaction type options
No custom method is needed if the config value is converted to enum BottommostLevelCompaction using Configuration.getEnum instead getInt.
| </description> | ||
| </property> | ||
| <property> | ||
| <name>ozone.om.compaction.service.bottommostlevelcompaction</name> |
There was a problem hiding this comment.
Please use - as separator in last part of the property name.
There was a problem hiding this comment.
Is this necessary? bottommostlevelcompaction is the original name as per org.rocksdb.CompactRangeOptions.BottommostLevelCompaction.
Most importantly, searching for bottommostlevelcompaction brings up all instances of it in both code and configuration in my IDE. Adding a separator would break that.
There was a problem hiding this comment.
BottommostLevelCompaction uses CamelCase. The same with lower case needs some separator, e.g. - (kebab-case) or _ (snake_case) for readability. In config property names - is commonly used.
| @Test | ||
| void testCompactWithKSkip() { | ||
| assertDoesNotThrow(() -> | ||
| CompactDBUtil.compactTable(omMetadataManager, "keyTable", | ||
| ManagedCompactRangeOptions.BottommostLevelCompaction.kSkip)); | ||
| } | ||
|
|
||
| @Test | ||
| void testCompactWithKForce() { | ||
| assertDoesNotThrow(() -> | ||
| CompactDBUtil.compactTable(omMetadataManager, "keyTable", | ||
| ManagedCompactRangeOptions.BottommostLevelCompaction.kForce)); | ||
| } | ||
|
|
||
| @Test | ||
| void testCompactWithKIfHaveCompactionFilter() { | ||
| assertDoesNotThrow(() -> | ||
| CompactDBUtil.compactTable(omMetadataManager, "keyTable", | ||
| ManagedCompactRangeOptions.BottommostLevelCompaction.kIfHaveCompactionFilter)); | ||
| } |
There was a problem hiding this comment.
Please use @ParameterizedTest with @EnumSource.
| @Test | ||
| void testConfigValueMapsToCorrectEnum() { | ||
| assertEquals(ManagedCompactRangeOptions.BottommostLevelCompaction.kSkip, | ||
| ManagedCompactRangeOptions.BottommostLevelCompaction.fromRocksId(0)); | ||
| assertEquals(ManagedCompactRangeOptions.BottommostLevelCompaction.kIfHaveCompactionFilter, | ||
| ManagedCompactRangeOptions.BottommostLevelCompaction.fromRocksId(1)); | ||
| assertEquals(ManagedCompactRangeOptions.BottommostLevelCompaction.kForce, | ||
| ManagedCompactRangeOptions.BottommostLevelCompaction.fromRocksId(2)); | ||
| } | ||
|
|
||
| @Test | ||
| void testInvalidConfigValueReturnsNull() { | ||
| assertNull(ManagedCompactRangeOptions.BottommostLevelCompaction.fromRocksId(99)); | ||
| } |
There was a problem hiding this comment.
These tests exercising RocksDB method fromRocksId would be unnecessary with the enum config approach.
|
This PR has been marked as stale due to 21 days of inactivity. Please comment or remove the stale label to keep it open. Otherwise, it will be automatically closed in 7 days. |
|
@ptlrs Could you please drive this PR to completion by addressing the minor comments given? |
…ocksDB-BottommostLevelCompaction-options-configurable
…BottommostLevelCompaction configuration values.
There was a problem hiding this comment.
Thanks for updating the patch @ptlrs.
-
Please look into the CI build failure.
-
Let's update compaction CLI to also use enum names instead of int - #10428
It can also be done in a follow-up PR.
| <value>0</value> | ||
| <tag>OZONE, OM, PERFORMANCE</tag> | ||
| <description> | ||
| Bottommost level compaction type for compaction. | ||
| Invalid values will default to kSkip. | ||
| Valid values: 0 (kSkip), 1 (kIfHaveCompactionFilter), 2 (kForce), 3 (kForceOptimized). | ||
| </description> |
There was a problem hiding this comment.
getEnum expects enum names with this change. Please update the value as well as the description.
| <value>0</value> | |
| <tag>OZONE, OM, PERFORMANCE</tag> | |
| <description> | |
| Bottommost level compaction type for compaction. | |
| Invalid values will default to kSkip. | |
| Valid values: 0 (kSkip), 1 (kIfHaveCompactionFilter), 2 (kForce), 3 (kForceOptimized). | |
| </description> | |
| <value>kSkip</value> | |
| <tag>OZONE, OM, PERFORMANCE</tag> | |
| <description> | |
| Bottommost level compaction type for compaction. | |
| Invalid values will default to kSkip. | |
| Valid values: kSkip, kIfHaveCompactionFilter, kForce, kForceOptimized. | |
| </description> |
| * Bottommost level compaction type for manual compaction. | ||
| * Invalid values will default to kSkip. | ||
| * Valid values: 0 (kSkip), 1 (kIfHaveCompactionFilter), 2 (kForce), 3 (kForceOptimized). |
There was a problem hiding this comment.
| * Bottommost level compaction type for manual compaction. | |
| * Invalid values will default to kSkip. | |
| * Valid values: 0 (kSkip), 1 (kIfHaveCompactionFilter), 2 (kForce), 3 (kForceOptimized). | |
| * Bottommost level compaction type for background compaction service. | |
| * Invalid values will default to kSkip. | |
| * Valid values: kSkip, kIfHaveCompactionFilter, kForce, kForceOptimized. |
| @Test | ||
| public void testConfiguredCompactionLevelKForce() { | ||
| OzoneConfiguration conf = new OzoneConfiguration(); | ||
| conf.setInt(OZONE_OM_COMPACTION_SERVICE_BOTTOMMOSTLEVELCOMPACTION, 2); |
There was a problem hiding this comment.
| conf.setInt(OZONE_OM_COMPACTION_SERVICE_BOTTOMMOSTLEVELCOMPACTION, 2); | |
| conf.set(OZONE_OM_COMPACTION_SERVICE_BOTTOMMOSTLEVELCOMPACTION, "kForce"); |
| @Test | ||
| public void testInvalidCompactionLevelFallsBackToDefault() { | ||
| OzoneConfiguration conf = new OzoneConfiguration(); | ||
| conf.setInt(OZONE_OM_COMPACTION_SERVICE_BOTTOMMOSTLEVELCOMPACTION, 99); |
There was a problem hiding this comment.
Any invalid string can be used here -
| conf.setInt(OZONE_OM_COMPACTION_SERVICE_BOTTOMMOSTLEVELCOMPACTION, 99); | |
| conf.set(OZONE_OM_COMPACTION_SERVICE_BOTTOMMOSTLEVELCOMPACTION, "abc"); |
| return compactableTables; | ||
| } | ||
|
|
||
| @VisibleForTesting |
There was a problem hiding this comment.
@VisibleForTesting annotation is no longer used, see HDDS-12725.
| @VisibleForTesting |
What changes were proposed in this pull request?
RocksDB allows multiple configurations for configuration the compaction strategy for the bottom-most layer. These configurations impact the compaction times.
This PR makes the compaction strategy configurable.
kSkipwhich is faster thankForceWhat is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-15342
How was this patch tested?
CI: https://github.com/ptlrs/ozone/actions/runs/26857346964