zhijiangW commented on a change in pull request #11786: [FLINK-17208][network] 
Reduce redundant data available notifications of PipelinedSubpartition
URL: https://github.com/apache/flink/pull/11786#discussion_r410367542
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/PipelinedSubpartition.java
 ##########
 @@ -146,7 +149,10 @@ private boolean add(BufferConsumer bufferConsumer, 
boolean finish, boolean inser
                        handleAddingBarrier(bufferConsumer, insertAsHead);
                        updateStatistics(bufferConsumer);
                        increaseBuffersInBacklog(bufferConsumer);
-                       notifyDataAvailable = insertAsHead || finish || 
shouldNotifyDataAvailable();
+
+                       // Notify only when we added first finished buffer.
+                       notifyDataAvailable = mayNotifyDataAvailable() && 
getNumberOfFinishedBuffers() == 1;
+                       dataAvailableNotified = dataAvailableNotified || 
notifyDataAvailable;
 
 Review comment:
   We can remove `dataAvailableNotified = dataAvailableNotified || 
notifyDataAvailable` and migrate it into internal `#notifyDataAvailable()` to 
tag `dataAvailableNotified = true` instead. There are two benefits:
   
   1. It is more easily understood after actually calling 
`#notifyDataAvailable`, then set it as true.
   2. It can be reused for three below places, which i will point it out below.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to