diff --git a/be/src/olap/rowset/segment_v2/stream_reader.h b/be/src/olap/rowset/segment_v2/stream_reader.h index 9aac3c0f232895..6cf7366fba25c7 100644 --- a/be/src/olap/rowset/segment_v2/stream_reader.h +++ b/be/src/olap/rowset/segment_v2/stream_reader.h @@ -41,13 +41,13 @@ struct SubstreamIterator { }; // path -> StreamReader -using SubstreamReaderTree = vectorized::SubcolumnsTree; +using SubstreamReaderTree = vectorized::SubcolumnsTree; // Reader for the storage layer, the file_column_type indicates the read type of the column in segment file struct SubcolumnReader { std::unique_ptr reader; std::shared_ptr file_column_type; }; -using SubcolumnColumnReaders = vectorized::SubcolumnsTree; +using SubcolumnColumnReaders = vectorized::SubcolumnsTree; } // namespace doris::segment_v2 \ No newline at end of file diff --git a/be/src/vec/columns/column_object.h b/be/src/vec/columns/column_object.h index 04a9cb4a7c102d..764000751865a6 100644 --- a/be/src/vec/columns/column_object.h +++ b/be/src/vec/columns/column_object.h @@ -235,7 +235,7 @@ class ColumnObject final : public COWHelper { // the root Node should be JSONB type when finalize bool is_root = false; }; - using Subcolumns = SubcolumnsTree; + using Subcolumns = SubcolumnsTree; private: /// If true then all subcolumns are nullable. diff --git a/be/src/vec/columns/subcolumn_tree.h b/be/src/vec/columns/subcolumn_tree.h index 8b53d1912f3d69..f1290737003b58 100644 --- a/be/src/vec/columns/subcolumn_tree.h +++ b/be/src/vec/columns/subcolumn_tree.h @@ -26,13 +26,11 @@ #include "vec/columns/column.h" #include "vec/common/arena.h" #include "vec/common/string_ref.h" -#include "vec/data_types/data_type.h" #include "vec/json/path_in_data.h" namespace doris::vectorized { -/// Tree that represents paths in document -/// with additional data in nodes. - -template +// Tree that represents paths in document with additional data in nodes. +// IsShared mean this object shared above multiple tasks, need swtich to subcolumns_tree_tracker +template class SubcolumnsTree { public: struct Node { @@ -75,10 +73,12 @@ class SubcolumnsTree { void add_child(std::string_view key, std::shared_ptr next_node, Arena& strings_pool) { next_node->parent = this; StringRef key_ref; - { + if constexpr (IsShared) { SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER( ExecEnv::GetInstance()->subcolumns_tree_tracker()); key_ref = {strings_pool.insert(key.data(), key.length()), key.length()}; + } else { + key_ref = {strings_pool.insert(key.data(), key.length()), key.length()}; } children[key_ref] = std::move(next_node); } @@ -256,7 +256,7 @@ class SubcolumnsTree { /// for the last rows. /// If there are no leaves, skip current node and find /// the next node up to the current. - leaf = SubcolumnsTree::find_leaf(node_nested, pred); + leaf = SubcolumnsTree::find_leaf(node_nested, pred); if (leaf) { break; @@ -308,14 +308,25 @@ class SubcolumnsTree { const_iterator end() const { return leaves.end(); } ~SubcolumnsTree() { - SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(ExecEnv::GetInstance()->subcolumns_tree_tracker()); - strings_pool.reset(); + if constexpr (IsShared) { + SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER( + ExecEnv::GetInstance()->subcolumns_tree_tracker()); + strings_pool.reset(); + } else { + strings_pool.reset(); + } } SubcolumnsTree() { - SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(ExecEnv::GetInstance()->subcolumns_tree_tracker()); - SCOPED_SKIP_MEMORY_CHECK(); - strings_pool = std::make_shared(); + if constexpr (IsShared) { + SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER( + ExecEnv::GetInstance()->subcolumns_tree_tracker()); + SCOPED_SKIP_MEMORY_CHECK(); + strings_pool = std::make_shared(); + } else { + SCOPED_SKIP_MEMORY_CHECK(); + strings_pool = std::make_shared(); + } } private: diff --git a/be/src/vec/common/allocator.cpp b/be/src/vec/common/allocator.cpp index 57394f65c1bc7d..22bc5ae3660f0e 100644 --- a/be/src/vec/common/allocator.cpp +++ b/be/src/vec/common/allocator.cpp @@ -289,6 +289,9 @@ void Allocator::add_add return; } #endif + if (!doris::config::crash_in_memory_tracker_inaccurate) { + return; + } doris::thread_context()->thread_mem_tracker_mgr->limiter_mem_tracker()->add_address_sanitizers( buf, size); } @@ -301,6 +304,9 @@ void Allocator::remove_ return; } #endif + if (!doris::config::crash_in_memory_tracker_inaccurate) { + return; + } doris::thread_context() ->thread_mem_tracker_mgr->limiter_mem_tracker() ->remove_address_sanitizers(buf, size);