Skip to content

HDDS-16213. Avoid the per-group list copy in KeyManagerImpl.getPendingDeletionKeys - #11082

Open
orca-07 wants to merge 2 commits into
apache:masterfrom
orca-07:HDDS-16213
Open

HDDS-16213. Avoid the per-group list copy in KeyManagerImpl.getPendingDeletionKeys#11082
orca-07 wants to merge 2 commits into
apache:masterfrom
orca-07:HDDS-16213

Conversation

@orca-07

@orca-07 orca-07 commented Aug 21, 2026

Copy link
Copy Markdown

What changes were proposed in this pull request?

In KeyManagerImpl.getPendingDeletionKeys (the KeyDeletingService reclaimable-key scan), each key's DeletedBlock list is built via a flatten-copy that is immediately re-streamed and discarded, once per key in the scan:

List<DeletedBlock> deletedBlocks = info.getKeyLocationVersions().stream()
    .flatMap(versionLocations -> versionLocations.getLocationList().stream()
        .map(b -> new DeletedBlock(
            new BlockID(b.getContainerID(), b.getLocalID()),
            b.getLength(),
            QuotaUtil.getReplicatedSize(b.getLength(), info.getReplicationConfig()),
            QuotaUtil.getSizePerReplica(b.getLength(), info.getReplicationConfig())
        ))).collect(Collectors.toList());

Fix: use getLocationLists() (no copy): .flatMap(v -> v.getLocationLists().stream().flatMap(List::stream)). Behavior unchanged. Complementary to HDDS-16195, which reuses the computed replicated sizes on the same loop but leaves this copy in place.

What is the link to the Apache JIRA

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

How was this patch tested?

https://github.com/orca-07/ozone/actions/runs/32501303771

https://github.com/orca-07/ozone/actions/runs/32457228935

@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 for the patch! @orca-07 +1 LGTM

@rich7420 rich7420 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.

@orca-07 thanks for the patch! LGTM

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