xiangfu0 commented on code in PR #19530:
URL: https://github.com/apache/pinot/pull/19530#discussion_r4021624992


##########
pinot-broker/src/main/java/org/apache/pinot/broker/routing/instanceselector/BalancedInstanceSelector.java:
##########
@@ -72,20 +76,24 @@ public InstanceMapping select(List<String> segments, int 
requestId,
       } else {
         selectedCandidate = candidates.get(requestId++ % candidates.size());
       }
-      poolToSegmentCount.merge(selectedCandidate.getPool(), 1, Integer::sum);
+      poolToSegmentCount.addTo(selectedCandidate.getPool(), 1);
       // This can only be offline when it is a new segment. And such segment 
is marked as optional segment so that
       // broker or server can skip it upon any issue to process it.
       if (selectedCandidate.isOnline()) {
+        if (segmentToSelectedInstanceMap == null) {
+          segmentToSelectedInstanceMap = new 
Object2ObjectOpenHashMap<>(segments.size());

Review Comment:
   Re-ran all eight interning/map/counter combinations against pinned current 
master with a corrected Helix-decoding fixture. At 10K segments, the 
flat-map/traversal change alone is slower in both orders, while saving about 
254.5 KB/call; primitive counters provide the clearest repeatable throughput 
improvement and save another 157.9 KB/call. I am retaining the flat map for its 
allocation benefit and have removed the implication that it independently 
explains the speedup. The pushed eager-map revision has a separate comparison, 
including the small balanced-request and all-unavailable tradeoffs. The PR 
description now distinguishes all of these results and supersedes the earlier 
headline. Raw data and reproducible evidence: 
https://gist.github.com/xiangfu0/342748edfb070a5cfaa3792f55ab86c7



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