pnowojski commented on a change in pull request #9993:
[FLINK-14498][runtime]Introduce NetworkBufferPool#isAvailable() for interacting
with LocalBufferPool.
URL: https://github.com/apache/flink/pull/9993#discussion_r340505699
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/buffer/LocalBufferPool.java
##########
@@ -406,7 +415,11 @@ public void setNumBuffers(int numBuffers) throws
IOException {
@Override
public CompletableFuture<?> isAvailable() {
- return availabilityHelper.isAvailable();
+ if (numberOfRequestedMemorySegments >= currentPoolSize) {
Review comment:
If this condition is not met (which is pretty common), this brakes the
performance optimisation and the contract of `isAvailable()`:
```
* @return a future that is completed if there are more records
available. If there are more
* records available immediately, {@link #AVAILABLE} should be returned.
```
since `return CompletableFuture.anyOf(availabilityHelper.isAvailable(),
networkBufferPool.isAvailable());` will always go through the expensive
`volatile` accesses.
Maybe we can add a check like this:
```
if (numberOfRequestedMemorySegments >= currentPoolSize) {
...
}
else if (availabilityHelper.isAvailable() == AVAILABLE ||
networkBufferPool.isAvailable() == AVAILABLE) {
return AVAILABLE;
}
else {
return CompletableFuture.anyOf(availabilityHelper.isAvailable(),
networkBufferPool.isAvailable());
}
```
?
----------------------------------------------------------------
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