pnowojski commented on a change in pull request #17660:
URL: https://github.com/apache/flink/pull/17660#discussion_r744462195



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/consumer/SingleInputGate.java
##########
@@ -433,6 +433,24 @@ public int getNumberOfQueuedBuffers() {
         return 0;
     }
 
+    public long getSizeOfQueuedBuffers() {
+        // re-try 3 times, if fails, return 0 for "unknown"
+        for (int retry = 0; retry < 3; retry++) {
+            try {
+                long totalSize = 0;
+
+                for (InputChannel channel : inputChannels.values()) {
+                    totalSize += 
channel.unsynchronizedGetSizeOfQueuedBuffers();
+                }
+
+                return totalSize;
+            } catch (Exception ignored) {

Review comment:
       log exception with debug?

##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/PipelinedSubpartition.java
##########
@@ -497,6 +497,12 @@ public int unsynchronizedGetNumberOfQueuedBuffers() {
         return Math.max(buffers.size(), 0);
     }
 
+    @Override
+    public long unsynchronizedGetSizeOfQueuedBuffers() {
+        // Pretty rough approximation of real queue size.
+        return Math.max(unsynchronizedGetNumberOfQueuedBuffers() * bufferSize, 
0);

Review comment:
       I have a feeling that in this implementation this metric doesn't really 
tell us anything more compared to output queue length and desired buffer size. 
Probably we should provide a more accurate estimate/metric or just drop it.
   
   The question would be what to do with this for the input bytes length. As 
this is only for local input channels, maybe that's a good enough estimation?

##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/PipelinedSubpartition.java
##########
@@ -535,7 +541,9 @@ private void updateStatistics(BufferConsumer buffer) {
     }
 
     private void updateStatistics(Buffer buffer) {
-        totalNumberOfBytes += buffer.getSize();
+        if (buffer.isBuffer()) {
+            totalNumberOfBytes += buffer.getSize();

Review comment:
       But why are you changing this in the first place? What's your 
motivation? 

##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/BufferWritingResultPartition.java
##########
@@ -111,6 +111,17 @@ public int getNumberOfQueuedBuffers() {
         return totalBuffers;
     }
 
+    @Override
+    public long getSizeOfQueuedBuffers() {
+        long totalNumberOfBytes = 0;
+
+        for (ResultSubpartition subpartition : subpartitions) {
+            totalNumberOfBytes += Math.max(0, 
subpartition.getTotalNumberOfBytes());

Review comment:
       Rename `getSizeOfQueuedBuffers` to `getSizeOfQueuedBuffersUnsafe`?




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