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


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyRequest.java:
##########
@@ -213,13 +237,25 @@ protected List<OmKeyLocationInfo> allocateBlock(
       }
       throw ex;
     }
+    // Cache the sorted order by pipeline nodes so blocks whose pipelines have
+    // the same datanodes are sorted once (mirrors the read path's caching).
     for (AllocatedBlock allocatedBlock : allocatedBlocks) {
       BlockID blockID = new BlockID(allocatedBlock.getBlockID());
+      Pipeline pipeline = allocatedBlock.getPipeline();
+      if (sortedByNodes != null) {
+        final List<DatanodeDetails> nodes = pipeline.getNodes();
+        final List<? extends DatanodeDetails> sorted = sortedByNodes
+            .computeIfAbsent(nodes,
+                n -> keyManager.sortDatanodesForWrite(n, omClientMachine));

Review Comment:
   The allocateBlock write-sort cache is keyed by `pipeline.getNodes()` (a 
newly-created, order-sensitive `List`). If the same pipeline members are 
encountered with a different iteration/insertion order, this cache will miss 
and re-sort even though the datanode set is identical (which contradicts the 
intent described in the comment). Consider keying the cache by 
`pipeline.getId()` (or a canonical set of UUIDs) so the 'sorted once per 
pipeline' optimization is robust to node-list ordering/copying.



-- 
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