tillrohrmann 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_r354861235
##########
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;
+ }
+
+ return new MemorySize((long) networkBufferSize * (inputBuffers
+ resultBuffers));
+ }
Review comment:
I'm wondering how we can enforce the contract we are defining here. In
different words, how can we prevent the `NettyShuffleService` implementation to
setup the `SingleInputGates` and `ResultPartitions` with a different number of
network buffers than defined in this method. Maybe one could write a test where
we create a couple of `SingleInputGates` with `RemoteInputChannels` and
`ResultPartitions` and make sure that we asked the `NetworkBufferPool` for
exactly the number of network buffers as we are expecting according to this
method here.
----------------------------------------------------------------
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