You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2021/10/05 11:50:29 UTC

[GitHub] [iotdb] Alima777 commented on a change in pull request #4018: [IOTDB-1607] Optimize Tracing

Alima777 commented on a change in pull request #4018:
URL: https://github.com/apache/iotdb/pull/4018#discussion_r722065492



##########
File path: jdbc/src/main/java/org/apache/iotdb/jdbc/AbstractIoTDBJDBCResultSet.java
##########
@@ -90,6 +91,7 @@ public AbstractIoTDBJDBCResultSet(
             timeout,
             sgColumns,
             aliasColumnMap);
+    this.ioTDBRpcTracingInfo = new IoTDBTracingInfo();

Review comment:
       Initialization required? We only use it when it's set explicitly.

##########
File path: server/src/main/java/org/apache/iotdb/db/qp/logical/crud/QueryOperator.java
##########
@@ -64,9 +64,12 @@
   protected Map<String, Object> props;
   protected IndexType indexType;
 
+  protected boolean enableTracing;
+
   public QueryOperator() {
     super(SQLConstant.TOK_QUERY);
     operatorType = Operator.OperatorType.QUERY;
+    enableTracing = false;

Review comment:
       Its default is false. Remove this.

##########
File path: server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
##########
@@ -748,18 +755,22 @@ private TSExecuteStatementResp internalExecuteQueryStatement(
     AUDIT_LOGGER.debug(
         "Session {} execute Query: {}", sessionManager.getCurrSessionId(), statement);
 
-    final long startTime = System.currentTimeMillis();
+    final long queryStartTime = System.currentTimeMillis();

Review comment:
       Why two `startTime` parameter?

##########
File path: server/src/main/java/org/apache/iotdb/db/qp/physical/PhysicalPlan.java
##########
@@ -96,6 +96,7 @@
   protected long index;
 
   private boolean debug;
+  private boolean enableTracing = false;

Review comment:
       Move this to queryPlan?

##########
File path: server/src/main/java/org/apache/iotdb/db/query/control/tracing/TracingManager.java
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.iotdb.db.query.control.tracing;
+
+import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
+import org.apache.iotdb.service.rpc.thrift.TSTracingInfo;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class TracingManager {
+
+  // (queryId -> TracingInfo)
+  private final Map<Long, TracingInfo> queryIdToTracingInfo = new ConcurrentHashMap<>();
+
+  public TracingManager() {}
+
+  public static TracingManager getInstance() {
+    return TracingManagerHelper.INSTANCE;
+  }
+
+  private TracingInfo getTracingInfo(long queryId) {
+    return queryIdToTracingInfo.computeIfAbsent(queryId, k -> new TracingInfo());
+  }
+
+  public void setSeriesPathNum(long queryId, int pathsNum) {
+    getTracingInfo(queryId).setSeriesPathNum(pathsNum);
+  }
+
+  public void addTsFileSet(
+      long queryId, List<TsFileResource> seqResources, List<TsFileResource> unseqResources) {
+    getTracingInfo(queryId).addTsFileSet(seqResources, unseqResources);
+  }
+
+  public void addChunkInfo(long queryId, int chunkNum, long pointsNum, boolean seq) {
+    getTracingInfo(queryId).addChunkInfo(chunkNum, pointsNum, seq);
+  }
+
+  public void addTotalPageNum(long queryId, int pageNum) {
+    getTracingInfo(queryId).addTotalPageNum(pageNum);
+  }
+
+  public void addOverlappedPageNum(long queryId) {
+    getTracingInfo(queryId).addOverlappedPageNum();
+  }
+
+  public void setStartTime(long queryId, long startTime) {
+    getTracingInfo(queryId).setStartTime(startTime);
+  }
+
+  public void registerActivity(long queryId, String activity, long startTime) {
+    getTracingInfo(queryId).addActivity(activity, startTime);
+  }
+
+  public TSTracingInfo fillRpcReturnTracingInfo(long queryId) {
+    return getTracingInfo(queryId).fillRpcReturnTracingInfo();
+  }

Review comment:
       Remove this after using in case memory leak.
   ```suggestion
     public TSTracingInfo fillRpcReturnTracingInfo(long queryId) {
       return queryIdToTracingInfo.remove(queryId).fillRpcReturnTracingInfo();
     }
   ```




-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org