dawidwys commented on a change in pull request #17541:
URL: https://github.com/apache/flink/pull/17541#discussion_r741117079



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/metrics/TimeToConsumeGauge.java
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.io.network.metrics;
+
+import org.apache.flink.metrics.Gauge;
+import org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate;
+
+/** Gauge metric measuring the maximal time to consume all buffers of all 
input gates. */
+public class TimeToConsumeGauge implements Gauge<Long> {
+
+    private final SingleInputGate[] gates;
+
+    public TimeToConsumeGauge(SingleInputGate[] gates) {
+        this.gates = gates;
+    }
+
+    @Override
+    public Long getValue() {
+        long result = Long.MIN_VALUE;
+        for (SingleInputGate gate : gates) {
+            result = Math.max(gate.getLastEstimatedTimeToConsume().toMillis(), 
result);

Review comment:
       It is because the throughput of each gate is affected by the other gate. 
   Basically 
   ```
   throughput_1 = data_1/(busy_1 + busy_2)
   ```
   At the same time gates are consumed in a fair manner. The 
`getLastEstimatedTimeToConsume` always includes some portion of the time spent 
on processing the other gate. And in a special case the bigger time will 
include the entire `lastEstimatedTimeToConsume` of the other gate.
   




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