You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/05/23 01:17:14 UTC

[GitHub] [incubator-doris] stalary commented on a diff in pull request #9725: [Enhancement] Add a ProfileStorage interface to support record all the querylog in persist storage.

stalary commented on code in PR #9725:
URL: https://github.com/apache/incubator-doris/pull/9725#discussion_r878959299


##########
fe/fe-core/src/main/java/org/apache/doris/common/util/ProfileManager.java:
##########
@@ -104,160 +90,60 @@ public static ProfileManager getInstance() {
     }
 
     private ProfileManager() {
-        lock = new ReentrantReadWriteLock(true);
-        readLock = lock.readLock();
-        writeLock = lock.writeLock();
-        queryIdDeque = new LinkedList<>();
-        queryIdToProfileMap = new ConcurrentHashMap<>();
+        storage = new InMemoryProfileStorage();

Review Comment:
   Will we use variables to decide which storage to use in the future?



##########
fe/fe-core/src/main/java/org/apache/doris/common/Pair.java:
##########
@@ -22,14 +22,15 @@
 
 import com.google.gson.annotations.SerializedName;
 
+import java.io.Serializable;
 import java.util.Comparator;
 
 /**
  * The equivalent of C++'s std::pair<>.
  *
  * Notice: When using Pair for persistence, users need to guarantee that F and S can be serialized through Gson
  */
-public class Pair<F, S> {
+public class Pair<F, S> implements Serializable {

Review Comment:
   Why change it.



##########
fe/fe-core/src/main/java/org/apache/doris/common/profile/InMemoryProfileStorage.java:
##########
@@ -0,0 +1,159 @@
+// 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.doris.common.profile;
+
+import org.apache.doris.common.util.ProfileManager;
+import org.apache.doris.common.util.ProfileManager.ProfileElement;
+import org.apache.doris.common.util.ProfileManager.ProfileType;
+import org.apache.doris.common.util.RuntimeProfile;
+
+import com.google.common.base.Strings;
+import com.google.common.collect.Lists;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.Deque;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
+
+/**
+ * An inMemory impl of profile storage. It will only keep 100 records in memory.
+ * If you want to keep more query records, you can use other impl of profile storage.
+ */
+public class InMemoryProfileStorage implements ProfileStorage {
+    private static final Logger LOG = LogManager.getLogger(InMemoryProfileStorage.class);
+
+    private static final int ARRAY_SIZE = 100;

Review Comment:
   Maybe we can control the size by variables.



-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org