This is an automated email from the ASF dual-hosted git repository.
zouxinyi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 2d5fd6d458b [fix](stacktrace) Speed up BE UT stacktrace (#50340)
2d5fd6d458b is described below
commit 2d5fd6d458bc8f49409e862541d2c58fa01f862d
Author: Xinyi Zou <[email protected]>
AuthorDate: Fri Apr 25 17:55:07 2025 +0800
[fix](stacktrace) Speed up BE UT stacktrace (#50340)
### What problem does this PR solve?
Testing Doris stacktrace methods, `libunwind DISABLED` mode is the
fastest (not parse debug information).
except for the `libunwind FAST` mode (parses .debug_aranges), the other
4 methods do not have line numbers, including glog, boost, and glibc.
If you find that stacktrace is too slow, use `libunwind DISABLED`.
```
17382022 : libunwind FAST cost(ms)
2305 : libunwind DISABLED cost(ms)
4779629 : boost cost(ms)
142682336 : glog cost(ms)
28597 : glibc cost(ms)
---
be/src/common/exception.cpp | 9 +++++++--
be/src/util/stack_util.cpp | 5 +----
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/be/src/common/exception.cpp b/be/src/common/exception.cpp
index 507c850d1f1..5d609126562 100644
--- a/be/src/common/exception.cpp
+++ b/be/src/common/exception.cpp
@@ -25,13 +25,18 @@ Exception::Exception(int code, const std::string_view& msg)
{
_code = code;
_err_msg = std::make_unique<ErrMsg>();
_err_msg->_msg = msg;
+#ifndef BE_TEST
if (ErrorCode::error_states[abs(code)].stacktrace) {
_err_msg->_stack = get_stack_trace();
}
-#ifdef BE_TEST
+#else
+ if (ErrorCode::error_states[abs(code)].stacktrace) {
+ _err_msg->_stack = get_stack_trace(0, "DISABLED");
+ }
// BE UT TEST exceptions thrown during execution cannot be caught
// and the error `C++ exception with description "argument not found"
thrown in the test body` will be printed.
- std::cout << "Exception: " << code << ", " << msg << ", " <<
get_stack_trace() << std::endl;
+ std::cout << "Exception: " << code << ", " << msg << ", " <<
get_stack_trace(0, "DISABLED")
+ << std::endl;
#endif
if (config::exit_on_exception) {
LOG(FATAL) << "[ExitOnException] error code: " << code << ", message:
" << msg;
diff --git a/be/src/util/stack_util.cpp b/be/src/util/stack_util.cpp
index 4adeb7b5548..d8613cc1a5f 100644
--- a/be/src/util/stack_util.cpp
+++ b/be/src/util/stack_util.cpp
@@ -44,11 +44,8 @@ std::string get_stack_trace(int start_pointers_index,
std::string dwarf_location
if (dwarf_location_info_mode.empty()) {
dwarf_location_info_mode = config::dwarf_location_info_mode;
}
-#ifdef BE_TEST
- auto tool = std::string {"boost"};
-#else
+
auto tool = config::get_stack_trace_tool;
-#endif
if (tool == "glog") {
return get_stack_trace_by_glog();
} else if (tool == "boost") {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]