HDDS-16216. Avoid the flatten-copy in KeyInputStream.getBlockLocationInfo - #11099
Open
0lai0 wants to merge 1 commit into
Open
HDDS-16216. Avoid the flatten-copy in KeyInputStream.getBlockLocationInfo#110990lai0 wants to merge 1 commit into
0lai0 wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Optimizes block-location lookup by avoiding flattening, temporary allocations, and unnecessary stream processing.
Changes:
- Uses short-circuiting nested iteration over location lists.
- Restricts
commons-collections4to test scope.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/KeyInputStream.java |
Replaces stream-based lookup with direct allocation-free iteration. |
hadoop-ozone/client/pom.xml |
Adjusts the Commons Collections dependency scope. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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?
KeyInputStream.getBlockLocationInforuns on every per-block pipeline refresh / read retry. It flatten-copies the version map withcreateLocationList(), then doesstream().filter().collect(toList())just to pickget(0), two throwawayArrayLists per call, no short-circuit.OmKeyLocationInfoGroup.createLocationList()is documented a s"expensive ... Use getLocationLists() instead".Fix: iterate
getLocationLists()(the raw uncopiedCollection<List<...>>) with a nested for-loop, return on first match. Zero allocations, short-circuits, same semantics.What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-16216
How was this patch tested?
https://github.com/0lai0/ozone/actions/runs/32735325487
mvn -pl :ozone-client install -DskipTests— passmvn -pl :ozone-client test -Dtest=TestKeyInputStreamEC— passmvn -pl :ozone-client checkstyle:check— passLocal JMH (target at last position → worst-case scan, gains are purely from removed allocations):
Generated-by: Claude Code (claude-opus-4-7)