zhuzhurk commented on a change in pull request #10462: [FLINK-15031][runtime] 
Calculate required shuffle memory before allocating slots if resources are 
specified
URL: https://github.com/apache/flink/pull/10462#discussion_r355121075
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/shuffle/NettyShuffleMaster.java
 ##########
 @@ -68,4 +77,19 @@ private static PartitionConnectionInfo createConnectionInfo(
                        
NetworkPartitionConnectionInfo.fromProducerDescriptor(producerDescriptor, 
connectionIndex) :
                        LocalExecutionPartitionConnectionInfo.INSTANCE;
        }
+
+       @Override
+       public MemorySize getShuffleMemoryForTask(final 
TaskInputsOutputsDescriptor taskInputsOutputsDescriptor) {
+               // each input channel will retain N exclusive network buffers, 
N = buffersPerInputChannel
+               final int inputBuffers = networkBuffersPerInputChannel * 
taskInputsOutputsDescriptor.getTotalNumberOfInputChannels();
+
+               // each result partition will retain 
(numberOfResultSubpartitions + 1) network buffers for its local buffer pool,
+               // according to ResultPartitionFactory#createBufferPoolFactory
+               int resultBuffers = 0;
+               for (int numberOfResultPartitions : 
taskInputsOutputsDescriptor.getNumbersOfResultSubpartitions().values()) {
+                       resultBuffers += numberOfResultPartitions + 1;
+               }
 
 Review comment:
   Will introduce  
`NettyShuffleUtils#getNumberOfRequiredBuffersForResultPartition(numberOfSubpartitions)`
 to share the calculation.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to