Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4509#discussion_r143225914
  
    --- Diff: 
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/consumer/RemoteInputChannel.java
 ---
    @@ -306,10 +311,27 @@ public void recycle(MemorySegment segment) {
                                        ExceptionUtils.rethrow(t);
                                }
                        }
    +
    +                   // Recycle the extra floating buffers in order not to 
stack up 2*initialCredit
    +                   // buffers once current backlog is 0
    +                   if (senderBacklog.get() == 0 && availableBuffers.size() 
>= initialCredit) {
    --- End diff --
    
    Actually, I guess, this should happen after adding the segment to 
`availableBuffers` and also not only when `senderBacklog.get() == 0`. The idiom 
you could follow is that after we integrated our exclusive buffer back, we 
should have a total of `buffersToMaintain = senderBacklog.get() + 
initialCredit` buffers. If there are more, we release `availableBuffers.size() 
- buffersToMaintain` _floating_ buffers accordingly. Since we only get one 
exclusive buffer back at a time, we only need to release at most one floating 
buffer here, as done by your code.


---

Reply via email to