Copilot commented on code in PR #11008:
URL: https://github.com/apache/ozone/pull/11008#discussion_r3771841003


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/ChecksumCache.java:
##########
@@ -87,6 +87,13 @@ List<ByteString> computeChecksum(ChunkBuffer data,
           + bytesPerChecksum + " call=" + chksumSize);
     }
     final int currChunkLength = data.remaining();
+    long readableByteCount = 0;
+    for (ByteBuffer buffer : data.asByteBufferList()) {
+      readableByteCount += buffer.remaining();
+    }

Review Comment:
   `computeChecksum` calls `data.asByteBufferList()` here for validation, and 
then calls `data.asByteBufferList()` again in the main processing loop below. 
For `ChunkBufferImplWithByteBuffer` and `IncrementalChunkBuffer`, 
`asByteBufferList()` allocates a wrapper list each call (eg 
`Collections.singletonList`, `Collections.unmodifiableList`), so this doubles 
the per-call allocation and adds an extra traversal. Capture the list once and 
reuse it for both validation and processing to keep the checksum path as 
allocation- and CPU-light as possible.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to