rickyma commented on code in PR #1531:
URL:
https://github.com/apache/incubator-uniffle/pull/1531#discussion_r1492728564
##########
server/src/main/java/org/apache/uniffle/server/buffer/ShuffleBufferManager.java:
##########
@@ -241,22 +265,34 @@ void flushSingleBufferIfNecessary(
boolean isHugePartition = isHugePartition(appId, shuffleId, partitionId);
// When we use multi storage and trigger single buffer flush, the buffer
size should be bigger
// than rss.server.flush.cold.storage.threshold.size, otherwise cold
storage will be useless.
- if ((isHugePartition || this.bufferFlushEnabled)
- && buffer.getSize() > this.bufferFlushThreshold) {
+ long size = nettyServerEnabled ? buffer.getEstimatedSize() :
buffer.getSize();
+ if ((isHugePartition || this.bufferFlushEnabled) && size >
this.bufferFlushThreshold) {
flushBuffer(buffer, appId, shuffleId, startPartition, endPartition,
isHugePartition);
return;
}
}
public void flushIfNecessary() {
// if data size in buffer > highWaterMark, do the flush
- if (usedMemory.get() - preAllocatedSize.get() - inFlushSize.get() >
highWaterMark) {
Review Comment:
> Could you extract a method to make logic more clearer?
I think the code is clear enough. I don't know if we need to extract a
method?
After extracting a method, will it make it less clear? I don't know.
```
if (nettyServerEnabled) {
needFlush = pinnedDirectMemory > highWaterMark;
} else {
needFlush = usedMemory.get() - preAllocatedSize.get() - inFlushSize.get()
> highWaterMark;
}
```
the pseudocode for `needFlush` is as follows:
```
needFlush = Current shuffle server's actual used memory > highWaterMark;
```
In netty mode, `Current shuffle server's actual used memory` will be
`pinnedUsedMemory`.
In grpc mode, `Current shuffle server's actual used memory` will be
`usedMemory.get()` - `preAllocatedSize.get()` - `inFlushSize.get()`.
--
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]