HDDS-16255. Avoid the per-group list copy in ContainerMapper.parseOmDB - #11100
Open
shuan1026 wants to merge 1 commit into
Open
HDDS-16255. Avoid the per-group list copy in ContainerMapper.parseOmDB#11100shuan1026 wants to merge 1 commit into
shuan1026 wants to merge 1 commit into
Conversation
sravani-revuri
left a comment
Contributor
There was a problem hiding this comment.
Thanks @shuan1026 for the patch. few minor comments below.
| /** | ||
| * Generates Container Id to Blocks and BlockDetails mapping. | ||
| * @param configuration @{@link OzoneConfiguration} | ||
| * @return {@code Map<Long, List<Map<Long, BlockDetails>>> |
Contributor
There was a problem hiding this comment.
nit: return type here says BlockDetails but the actual type is BlockIdDetails.
| innerList = dataMap.get(containerID); | ||
| for (List<OmKeyLocationInfo> keyLocationInfo : keyLocationInfoGroup | ||
| .getLocationLists()) { | ||
| for (OmKeyLocationInfo keyLocation : keyLocationInfo) { |
Contributor
There was a problem hiding this comment.
nit: this method now has 4 levels of looping which can be hard to read and understand. would it be better to put the logic below into a separate function?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
ContainerMapper.parseOmDBcalledOmKeyLocationInfoGroup.createLocationList()once per version group of every key, only to iterate the result once.createLocationList()is documented as not O(1).This PR adds one nested loop over the zero-copy
getLocationLists()accessor; the inner loop body that buildsBlockIdDetailsis unchanged.Additionally, a throwaway (not committed) JUnit micro-benchmark measured per-traversal thread allocation for both implementations (JDK 21.0.12, 50,000-iteration warmup then 500,000 measured iterations per shape, deterministic checksums asserted equal,
volatilesink to block JIT elimination). Results, reproduced across two independent JVM processes:What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-16255
How was this patch tested?
The following test passed:
TestContainerMapper#testContainerMapperAlso ran
checkstyle.shandauthor.shsuccessfully.