wsry commented on a change in pull request #18173:
URL: https://github.com/apache/flink/pull/18173#discussion_r774335993



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/buffer/NetworkBufferPool.java
##########
@@ -158,7 +159,8 @@ public MemorySegment requestMemorySegment() {
 
     public List<MemorySegment> requestMemorySegmentsBlocking(int 
numberOfSegmentsToRequest)
             throws IOException {
-        return internalRequestMemorySegments(numberOfSegmentsToRequest);
+        return internalRequestMemorySegments(
+                numberOfSegmentsToRequest, 
this::internalRecycleMemorySegments);

Review comment:
       I agree that the method name is misleading. Currently, the 
```requestMemorySegments``` method is only used by InputChannel for exclusive 
buffer requesting and it will add the number of required buffers to the total 
required buffers. If the total required buffers is larger than the total number 
of buffers, the "Insufficient number of network buffers" exception will be 
thrown. Because the logic number of available buffers 
(totalNumberOfMemorySegments - numTotalRequiredBuffers) is changed, buffer 
redistribution is needed. Different from the ```requestMemorySegments``` 
method, the ```requestMemorySegment``` and ```requestMemorySegmentsBlocking``` 
methods are only used by ```LocalBufferPool```, because ```LocalBufferPool``` 
has already reserved required buffers logically when it was created, so when 
requesting buffers, the logic number of available buffers is not changed, as a 
result, buffer redistribution is not needed. What do you think is I change the 
method name of ```requestMe
 morySegments``` to ```requestExclusiveSegments```? Any suggestions?




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