You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2023/05/19 08:52:37 UTC
[iotdb] 02/02: merge operator metric together
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch QueryMetricOpt
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 237921e244b961aede12b3d528cd98bd808443f2
Author: JackieTien97 <ja...@gmail.com>
AuthorDate: Fri May 19 16:52:09 2023 +0800
merge operator metric together
---
.../org/apache/iotdb/db/mpp/execution/driver/Driver.java | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/execution/driver/Driver.java b/server/src/main/java/org/apache/iotdb/db/mpp/execution/driver/Driver.java
index a214522ca65..67f8ff2c810 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/execution/driver/Driver.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/execution/driver/Driver.java
@@ -37,7 +37,9 @@ import org.slf4j.LoggerFactory;
import javax.annotation.concurrent.GuardedBy;
import java.io.File;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
@@ -382,15 +384,20 @@ public abstract class Driver implements IDriver {
sink.setNoMoreTsBlocks();
+ Map<String, long[]> operatorType2TotalCost = new HashMap<>();
// record operator execution statistics to metrics
List<OperatorContext> operatorContexts = driverContext.getOperatorContexts();
for (OperatorContext operatorContext : operatorContexts) {
String operatorType = operatorContext.getOperatorType();
- QUERY_METRICS.recordOperatorExecutionCost(
- operatorType, operatorContext.getTotalExecutionTimeInNanos());
- QUERY_METRICS.recordOperatorExecutionCount(
- operatorType, operatorContext.getNextCalledCount());
+ long[] value = operatorType2TotalCost.computeIfAbsent(operatorType, k -> new long[2]);
+ value[0] += operatorContext.getTotalExecutionTimeInNanos();
+ value[1] += operatorContext.getNextCalledCount();
}
+ for (Map.Entry<String, long[]> entry : operatorType2TotalCost.entrySet()) {
+ QUERY_METRICS.recordOperatorExecutionCost(entry.getKey(), entry.getValue()[0]);
+ QUERY_METRICS.recordOperatorExecutionCount(entry.getKey(), entry.getValue()[1]);
+ }
+
} catch (InterruptedException t) {
// don't record the stack
wasInterrupted = true;