Skip to content

HDDS-16205. Avoid the duplicate list copy in S3MultipartUploadCompleteRequest.getMultipartDataSize - #11064

Open
shuan1026 wants to merge 1 commit into
apache:masterfrom
shuan1026:HDDS-16205
Open

HDDS-16205. Avoid the duplicate list copy in S3MultipartUploadCompleteRequest.getMultipartDataSize#11064
shuan1026 wants to merge 1 commit into
apache:masterfrom
shuan1026:HDDS-16205

Conversation

@shuan1026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

S3MultipartUploadCompleteRequest.getMultipartDataSize calls OmKeyLocationInfoGroup.getLocationList() twice for the same version group per MPU part: once to set partNumber on each block, and again to addAll those same blocks into partLocationInfos. getLocationList() is documented as expensive: it flatten-copies locationVersionMap.values() into a brand-new ArrayList on every call. Since OmKeyLocationInfo is a mutable object, the second call re-flattens the same data the first call already produced, just to read it once more.

Replaces both calls with a single getLocationLists() walk of the live, uncopied Collection<List<OmKeyLocationInfo>> view of locationVersionMap.values(), setting partNumber and doing addAll in one pass per inner list. Zero list copies instead of two, same forEach idiom as before.

Same accessor-usage fix already applied in KeyManagerImpl.refreshPipeline (HDDS-5384), ContainerEndpoint.getBlocks (HDDS-16202), and ContainerToKeyMapping.getContainers (HDDS-16204). Behavior and ordering are unchanged.

What is the link to the Apache JIRA

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

How was this patch tested?

The following test suites passed (16 tests):

  • TestS3MultipartUploadCompleteRequest
  • TestS3MultipartUploadCompleteRequestWithFSO

Also ran checkstyle.sh and author.sh successfully.

@shuan1026 shuan1026 changed the title Avoid the duplicate list copy in S3MultipartUploadCompleteRequest.getMultipartDataSize HDDS-16205. Avoid the duplicate list copy in S3MultipartUploadCompleteRequest.getMultipartDataSize Aug 20, 2026
@rich7420

Copy link
Copy Markdown
Contributor

@shuan1026 thanks for the patch!
I think you could paste this in your pr content https://github.com/shuan1026/ozone/actions/runs/32261921025

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.

2 participants