CodingCat commented on code in PR #2358:
URL:
https://github.com/apache/incubator-celeborn/pull/2358#discussion_r1520864848
##########
client-spark/common/src/main/java/org/apache/spark/shuffle/celeborn/SortBasedPusher.java:
##########
@@ -44,6 +44,65 @@
public class SortBasedPusher extends MemoryConsumer {
+ class MemoryThresholdManager {
+
+ private long maxMemoryThresholdInBytes;
+ private double smallPushTolerateFactor;
+
+ private long sendBufferSizeInBytes;
+
+ MemoryThresholdManager(
+ int numPartitions, long sendBufferSizeInBytes, double
smallPushTolerateFactor) {
+ this.maxMemoryThresholdInBytes = numPartitions * sendBufferSizeInBytes;
+ this.smallPushTolerateFactor = smallPushTolerateFactor;
+ this.sendBufferSizeInBytes = sendBufferSizeInBytes;
+ }
+
+ private boolean shouldGrow() {
+ boolean enoughSpace = pushSortMemoryThreshold * 2 <=
maxMemoryThresholdInBytes;
+ double expectedPushSize = Long.MAX_VALUE;
+ if (this.expectedPushedCount != 0) {
+ expectedPushSize = this.expectedPushedBytes * 1.0 /
this.expectedPushedCount;
+ }
+ boolean tooManyPushed =
+ pushedMemorySizeInBytes * 1.0 / pushedCount * (1 +
this.smallPushTolerateFactor)
+ < expectedPushSize;
+ return enoughSpace && tooManyPushed;
+ }
+
+ public void growThresholdIfNeeded() {
+ if (shouldGrow()) {
+ long oldThreshold = pushSortMemoryThreshold;
+ pushSortMemoryThreshold = pushSortMemoryThreshold * 2;
+ logger.info(
Review Comment:
updated
--
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]