1996fanrui commented on code in PR #22381:
URL: https://github.com/apache/flink/pull/22381#discussion_r1163988392


##########
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/buffer/LocalBufferPool.java:
##########
@@ -671,13 +675,20 @@ public void setNumBuffers(int numBuffers) {
 
             currentPoolSize = Math.min(numBuffers, maxNumberOfMemorySegments);
 
-            // reset overdraft buffers
+            // If pool size increases, try to convert overdraft buffer to 
ordinary buffer.
             while (numberOfRequestedOverdraftMemorySegments > 0
                     && numberOfRequestedMemorySegments < currentPoolSize) {
                 numberOfRequestedOverdraftMemorySegments--;
                 numberOfRequestedMemorySegments++;
             }
 
+            // If pool size decreases, try to convert ordinary buffer to 
overdraft buffer.
+            while (numberOfRequestedMemorySegments > currentPoolSize
+                    && numberOfRequestedOverdraftMemorySegments < 
maxOverdraftBuffersPerGate) {
+                numberOfRequestedMemorySegments--;
+                numberOfRequestedOverdraftMemorySegments++;
+            }

Review Comment:
   Hi @reswqa , thanks for the fix.
   
   I'm curious, what's wrong with just leaving `numberOfRequestedMemorySegments 
> currentPoolSize`? Count extra buffers to the `overdraft buffer`.
   
   ```suggestion
               while (numberOfRequestedMemorySegments > currentPoolSize) {
                   numberOfRequestedMemorySegments--;
                   numberOfRequestedOverdraftMemorySegments++;
               }
   ```



-- 
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]

Reply via email to