Skip to content

HDDS-16211. Avoid the throwaway list copy in OMAllocateBlockRequest quota check - #11057

Open
rich7420 wants to merge 1 commit into
apache:masterfrom
rich7420:HDDS-16211
Open

HDDS-16211. Avoid the throwaway list copy in OMAllocateBlockRequest quota check#11057
rich7420 wants to merge 1 commit into
apache:masterfrom
rich7420:HDDS-16211

Conversation

@rich7420

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

OMAllocateBlockRequest.validateAndUpdateCache computes the already-allocated key size only to multiply by the block size, but calls getLocationList() (documented as not O(1)) purely to read size(), then discards the list — on every block allocation, under the bucket write lock:

long hadAllocatedKeySize =
openKeyInfo.getLatestVersionLocations().getLocationList().size()
* ozoneManager.getScmBlockSize();
Fix: use getLocationListCount() (values().stream().mapToLong(List::size).sum()), which returns the same total with no allocation. The result already widens to long for the multiplication, so the value is unchanged. Behavior unchanged.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-16211

How was this patch tested?

https://github.com/rich7420/ozone/actions/runs/32219890598

…uota check

getLatestVersionLocations().getLocationList().size() allocated a flattened
list on every block allocation just to read its size. Use getLocationListCount(),
which sums the per-version list sizes with no allocation; the value is identical
and the multiplication already widens to long.
Copilot AI lite review requested due to automatic review settings August 19, 2026 05:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chihsuan chihsuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rich7420 LGTM +1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants