This is an automated email from the ASF dual-hosted git repository.

rexxiong pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/celeborn.git


The following commit(s) were added to refs/heads/main by this push:
     new 5fc0f199a [CELEBORN-2282] Eliminate redundant HashMap lookups in 
CelebornInputStream#fillBuffer
5fc0f199a is described below

commit 5fc0f199a4080c407bcb2bd5225b6e1edafaadf8
Author: yew1eb <[email protected]>
AuthorDate: Wed Mar 18 22:22:55 2026 +0800

    [CELEBORN-2282] Eliminate redundant HashMap lookups in 
CelebornInputStream#fillBuffer
    
    ### What changes were proposed in this pull request?
    
    Replace three redundant HashMap operations (`containsKey` + `put` + `get`) 
with a single `computeIfAbsent` call in `CelebornInputStream#fillBuffer`.
    
    ### Why are the changes needed?
    
    `fillBuffer` is on the hot shuffle-read path and called for every batch 
read. The original code performs up to three HashMap lookups per batch instead 
of one, causing unnecessary CPU overhead at scale.
    
    ### Does this PR resolve a correctness bug?
    
    No.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Existing unit tests.
    
    Closes #3627 from yew1eb/CELEBORN-2282.
    
    Authored-by: yew1eb <[email protected]>
    Signed-off-by: Shuang <[email protected]>
---
 .../java/org/apache/celeborn/client/read/CelebornInputStream.java   | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git 
a/client/src/main/java/org/apache/celeborn/client/read/CelebornInputStream.java 
b/client/src/main/java/org/apache/celeborn/client/read/CelebornInputStream.java
index bb959f0d5..37e0be3e3 100644
--- 
a/client/src/main/java/org/apache/celeborn/client/read/CelebornInputStream.java
+++ 
b/client/src/main/java/org/apache/celeborn/client/read/CelebornInputStream.java
@@ -853,11 +853,7 @@ public abstract class CelebornInputStream extends 
InputStream {
                 }
               }
             }
-            if (!batchesRead.containsKey(mapId)) {
-              Set<Integer> batchSet = new HashSet<>();
-              batchesRead.put(mapId, batchSet);
-            }
-            Set<Integer> batchSet = batchesRead.get(mapId);
+            Set<Integer> batchSet = batchesRead.computeIfAbsent(mapId, k -> 
new HashSet<>());
             if (!batchSet.contains(batchId)) {
               batchSet.add(batchId);
               callback.incBytesRead(BATCH_HEADER_SIZE + size);

Reply via email to