This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new 4b9d500425 [improvement](profile) Add table name and predicates
(#10093)
4b9d500425 is described below
commit 4b9d5004258965154b00cd48ba71b51af068a8c2
Author: Jerry Hu <[email protected]>
AuthorDate: Thu Jun 16 10:59:31 2022 +0800
[improvement](profile) Add table name and predicates (#10093)
---
be/src/exec/olap_scan_node.cpp | 32 +++++++++-
be/src/util/to_string.h | 73 ++++++++++++++++++++++
.../doris/common/profile/ProfileTreeBuilder.java | 9 +++
.../doris/common/profile/ProfileTreeNode.java | 21 ++++++-
.../apache/doris/common/util/RuntimeProfile.java | 4 ++
5 files changed, 137 insertions(+), 2 deletions(-)
diff --git a/be/src/exec/olap_scan_node.cpp b/be/src/exec/olap_scan_node.cpp
index 401a1f2cea..5a621e5f06 100644
--- a/be/src/exec/olap_scan_node.cpp
+++ b/be/src/exec/olap_scan_node.cpp
@@ -38,6 +38,7 @@
#include "runtime/tuple_row.h"
#include "util/priority_thread_pool.hpp"
#include "util/runtime_profile.h"
+#include "util/to_string.h"
namespace doris {
@@ -195,6 +196,8 @@ Status OlapScanNode::prepare(RuntimeState* state) {
return Status::InternalError("Failed to get tuple descriptor.");
}
+ _runtime_profile->add_info_string("Table",
_tuple_desc->table_desc()->name());
+
const std::vector<SlotDescriptor*>& slots = _tuple_desc->slots();
for (int i = 0; i < slots.size(); ++i) {
@@ -555,7 +558,7 @@ void OlapScanNode::remove_pushed_conjuncts(RuntimeState*
state) {
// filter idle conjunct in vexpr_contexts
auto checker = [&](int index) { return
_pushed_conjuncts_index.count(index); };
std::string vconjunct_information = _peel_pushed_vconjunct(state, checker);
- _scanner_profile->add_info_string("VconjunctExprTree",
vconjunct_information);
+ _runtime_profile->add_info_string("NonPushdownPredicate",
vconjunct_information);
}
void OlapScanNode::eval_const_conjuncts() {
@@ -653,6 +656,31 @@ Status OlapScanNode::normalize_conjuncts() {
return Status::OK();
}
+static std::string olap_filter_to_string(const doris::TCondition& condition) {
+ auto op_name = condition.condition_op;
+ if (condition.condition_op == "*=") {
+ op_name = "IN";
+ } else if (condition.condition_op == "!*=") {
+ op_name = "NOT IN";
+ }
+ return fmt::format("{{{} {} {}}}", condition.column_name, op_name,
+ to_string(condition.condition_values));
+}
+
+static std::string olap_filters_to_string(const
std::vector<doris::TCondition>& filters) {
+ // std::vector<std::string> filters_string;
+ std::string filters_string;
+ filters_string += "[";
+ for (auto it = filters.cbegin(); it != filters.cend(); it++) {
+ if (it != filters.cbegin()) {
+ filters_string += ",";
+ }
+ filters_string += olap_filter_to_string(*it);
+ }
+ filters_string += "]";
+ return filters_string;
+}
+
Status OlapScanNode::build_olap_filters() {
for (auto& iter : _column_value_ranges) {
std::vector<TCondition> filters;
@@ -663,6 +691,8 @@ Status OlapScanNode::build_olap_filters() {
}
}
+ _runtime_profile->add_info_string("PushdownPredicate",
olap_filters_to_string(_olap_filter));
+
return Status::OK();
}
diff --git a/be/src/util/to_string.h b/be/src/util/to_string.h
new file mode 100644
index 0000000000..203ea8a0ae
--- /dev/null
+++ b/be/src/util/to_string.h
@@ -0,0 +1,73 @@
+// 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.
+//
+
+#pragma once
+
+#include <fmt/format.h>
+
+#include <map>
+#include <set>
+#include <string>
+#include <vector>
+
+namespace doris {
+template <typename T>
+std::string to_string(const T& t) {
+ return fmt::format("{}", t);
+}
+
+template <typename K, typename V>
+std::string to_string(const std::map<K, V>& m);
+
+template <typename T>
+std::string to_string(const std::set<T>& s);
+
+template <typename T>
+std::string to_string(const std::vector<T>& t);
+
+template <typename K, typename V>
+std::string to_string(const typename std::pair<K, V>& v) {
+ return fmt::format("{}: {}", to_string(v.first), to_string(v.second));
+}
+
+template <typename T>
+std::string to_string(const T& beg, const T& end) {
+ std::string out;
+ for (T it = beg; it != end; ++it) {
+ if (it != beg) out += ", ";
+ out += to_string(*it);
+ }
+ return out;
+}
+
+template <typename T>
+std::string to_string(const std::vector<T>& t) {
+ return "[" + to_string(t.begin(), t.end()) + "]";
+}
+
+template <typename K, typename V>
+std::string to_string(const std::map<K, V>& m) {
+ return "{" + to_string(m.begin(), m.end()) + "}";
+}
+
+template <typename T>
+std::string to_string(const std::set<T>& s) {
+ return "{" + to_string(s.begin(), s.end()) + "}";
+}
+
+} // namespace doris
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/common/profile/ProfileTreeBuilder.java
b/fe/fe-core/src/main/java/org/apache/doris/common/profile/ProfileTreeBuilder.java
index c56ae75ed8..c5720d76ab 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/common/profile/ProfileTreeBuilder.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/common/profile/ProfileTreeBuilder.java
@@ -31,6 +31,7 @@ import lombok.Setter;
import org.apache.commons.lang3.tuple.ImmutableTriple;
import org.apache.commons.lang3.tuple.Triple;
+import java.util.ArrayList;
import java.util.Formatter;
import java.util.List;
import java.util.Map;
@@ -266,6 +267,14 @@ public class ProfileTreeBuilder {
try (Formatter fmt = new Formatter()) {
node.setNonChild(fmt.format("%.2f",
profile.getLocalTimePercent()).toString());
}
+
+ if (!profile.getInfoStrings().isEmpty()) {
+ ArrayList<String> infoStrings = new ArrayList<String>();
+ for (Map.Entry<String, String> entry :
profile.getInfoStrings().entrySet()) {
+ infoStrings.add(entry.getKey() + ": " + entry.getValue());
+ }
+ node.setInfoStrings(infoStrings);
+ }
CounterNode rootCounterNode = new CounterNode();
buildCounterNode(profile, RuntimeProfile.ROOT_COUNTER,
rootCounterNode);
node.setCounterNode(rootCounterNode);
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/common/profile/ProfileTreeNode.java
b/fe/fe-core/src/main/java/org/apache/doris/common/profile/ProfileTreeNode.java
index e68e9e71f0..aa31682904 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/common/profile/ProfileTreeNode.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/common/profile/ProfileTreeNode.java
@@ -18,8 +18,10 @@
package org.apache.doris.common.profile;
import org.apache.doris.common.TreeNode;
-
import com.google.common.base.Strings;
+import com.google.common.collect.Lists;
+
+import java.util.List;
public class ProfileTreeNode extends TreeNode<ProfileTreeNode> {
@@ -27,6 +29,7 @@ public class ProfileTreeNode extends
TreeNode<ProfileTreeNode> {
protected String id;
protected CounterNode counterNode;
protected String activeTime;
+ protected List<String> infoStrings = Lists.newArrayList();
protected String nonChild;
protected String fragmentId = "";
@@ -75,6 +78,14 @@ public class ProfileTreeNode extends
TreeNode<ProfileTreeNode> {
return activeTime;
}
+ public void setInfoStrings(List<String> infoStrings) {
+ this.infoStrings = infoStrings;
+ }
+
+ public List<String> getInfoStrings() {
+ return infoStrings;
+ }
+
public void setNonChild(String nonChild) {
this.nonChild = nonChild;
}
@@ -129,6 +140,14 @@ public class ProfileTreeNode extends
TreeNode<ProfileTreeNode> {
if (level == ProfileTreePrinter.PrintLevel.INSTANCE) {
sb.append("(Active: ").append(activeTime).append(", ");
sb.append("non-child: ").append(nonChild).append(")").append("\n");
+ if (!infoStrings.isEmpty()) {
+ String infoStringIndent = printIndent(indent + 1);
+ sb.append(infoStringIndent).append(" - Info:").append("\n");
+ infoStringIndent = printIndent(indent + 5);
+ for (String info : infoStrings) {
+ sb.append(infoStringIndent).append(" -
").append(info).append("\n");
+ }
+ }
// print counters
sb.append(counterNode.toTree(indent + 1));
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/common/util/RuntimeProfile.java
b/fe/fe-core/src/main/java/org/apache/doris/common/util/RuntimeProfile.java
index 12d78cfe9e..f44ce0b672 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/util/RuntimeProfile.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/RuntimeProfile.java
@@ -469,4 +469,8 @@ public class RuntimeProfile {
public String getInfoString(String key) {
return infoStrings.get(key);
}
+
+ public Map<String, String> getInfoStrings() {
+ return infoStrings;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]