Github user pnowojski commented on a diff in the pull request:
https://github.com/apache/flink/pull/5923#discussion_r185819830
--- Diff:
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/NetworkEnvironment.java
---
@@ -228,20 +228,19 @@ public void setupPartition(ResultPartition partition)
throws IOException {
@VisibleForTesting
public void setupInputGate(SingleInputGate gate) throws IOException {
BufferPool bufferPool = null;
- int maxNumberOfMemorySegments;
try {
if (enableCreditBased) {
- maxNumberOfMemorySegments =
gate.getConsumedPartitionType().isBounded() ?
- extraNetworkBuffersPerGate :
Integer.MAX_VALUE;
-
// assign exclusive buffers to input channels
directly and use the rest for floating buffers
- gate.assignExclusiveSegments(networkBufferPool,
networkBuffersPerChannel);
- bufferPool =
networkBufferPool.createBufferPool(0, maxNumberOfMemorySegments);
+ int nrExclusiveMemorySegments =
gate.assignExclusiveSegments(networkBufferPool, networkBuffersPerChannel);
+ int maxNumberOfMemorySegments =
gate.getConsumedPartitionType().isBounded() ?
+ gate.getNumberOfInputChannels() *
networkBuffersPerChannel +
+ extraNetworkBuffersPerGate -
nrExclusiveMemorySegments : Integer.MAX_VALUE;
+ bufferPool = networkBufferPool
+ .createBufferPool(0,
maxNumberOfMemorySegments);
--- End diff --
I think that express this way:
```
if (enableCreditBased) {
int desiredMaxNumberOfMemorySegments = gate.getNumberOfInputChannels()
* networkBuffersPerChannel + extraNetworkBuffersPerGate;
int assignedExclusiveMemorySegments =
gate.assignExclusiveSegments(networkBufferPool, networkBuffersPerChannel);
int floatingMemorySegments = desiredMaxNumberOfMemorySegments -
assignedExclusiveMemorySegments;
bufferPool = networkBufferPool
.createBufferPool(0,
gate.getConsumedPartitionType().isBounded() ? floatingMemorySegments :
Integer.MAX_VALUE);
}
```
it's more easier to understand and allows us to skip the redundant comment.
Especially current `maxNumberOfMemorySegments` is strange name.
---