FMX commented on code in PR #2134:
URL:
https://github.com/apache/incubator-celeborn/pull/2134#discussion_r1418646492
##########
common/src/main/java/org/apache/celeborn/common/write/InFlightRequestTracker.java:
##########
@@ -173,6 +169,10 @@ public boolean limitZeroInFlight() throws IOException {
return times <= 0;
}
+ private int totalInflightReqs() {
+ return
inflightBatchesPerAddress.values().parallelStream().mapToInt(Set::size).sum();
Review Comment:
No need to get the count in this expensive way.
##########
common/src/main/java/org/apache/celeborn/common/write/InFlightRequestTracker.java:
##########
@@ -58,11 +55,10 @@ public InFlightRequestTracker(CelebornConf conf, PushState
pushState) {
}
public void addBatch(int batchId, String hostAndPushPort) {
- Set<Integer> batchIdSetPerPair =
+ Set<Integer> batchIdSet =
inflightBatchesPerAddress.computeIfAbsent(
hostAndPushPort, id -> ConcurrentHashMap.newKeySet());
- batchIdSetPerPair.add(batchId);
- totalInflightReqs.increment();
+ batchIdSet.add(batchId);
}
public void removeBatch(int batchId, String hostAndPushPort) {
Review Comment:
I think calling `totalInflightReqs.decrement()` when batchIdSet is not null
can be equivalent to this PR.
--
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]