github-actions[bot] commented on code in PR #18908: URL: https://github.com/apache/doris/pull/18908#discussion_r1173591681
########## be/src/runtime/tablets_channel.cpp: ########## @@ -221,17 +241,33 @@ } int64_t TabletsChannel::mem_consumption() { - int64_t mem_usage = 0; + int64_t write_mem_usage = 0; + int64_t flush_mem_usage = 0; + int64_t max_tablet_mem_usage = 0; + int64_t max_tablet_write_mem_usage = 0; + int64_t max_tablet_flush_mem_usage = 0; { std::lock_guard<SpinLock> l(_tablet_writers_lock); _mem_consumptions.clear(); for (auto& it : _tablet_writers) { - int64_t writer_mem = it.second->mem_consumption(); - mem_usage += writer_mem; - _mem_consumptions.emplace(writer_mem, it.first); + int64_t write_mem = it.second->mem_consumption(MemType::WRITE); + write_mem_usage += write_mem; + int64_t flush_mem = it.second->mem_consumption(MemType::FLUSH); + flush_mem_usage += flush_mem; + if (write_mem > max_tablet_write_mem_usage) max_tablet_write_mem_usage = write_mem; + if (flush_mem > max_tablet_flush_mem_usage) max_tablet_flush_mem_usage = flush_mem; Review Comment: warning: statement should be inside braces [readability-braces-around-statements] ```suggestion if (flush_mem > max_tablet_flush_mem_usage) { max_tablet_flush_mem_usage = flush_mem; } ``` ########## be/src/runtime/tablets_channel.cpp: ########## @@ -221,17 +241,33 @@ void TabletsChannel::_close_wait(DeltaWriter* writer, } int64_t TabletsChannel::mem_consumption() { - int64_t mem_usage = 0; + int64_t write_mem_usage = 0; + int64_t flush_mem_usage = 0; + int64_t max_tablet_mem_usage = 0; + int64_t max_tablet_write_mem_usage = 0; + int64_t max_tablet_flush_mem_usage = 0; { std::lock_guard<SpinLock> l(_tablet_writers_lock); _mem_consumptions.clear(); for (auto& it : _tablet_writers) { - int64_t writer_mem = it.second->mem_consumption(); - mem_usage += writer_mem; - _mem_consumptions.emplace(writer_mem, it.first); + int64_t write_mem = it.second->mem_consumption(MemType::WRITE); + write_mem_usage += write_mem; + int64_t flush_mem = it.second->mem_consumption(MemType::FLUSH); + flush_mem_usage += flush_mem; + if (write_mem > max_tablet_write_mem_usage) max_tablet_write_mem_usage = write_mem; Review Comment: warning: statement should be inside braces [readability-braces-around-statements] ```suggestion if (write_mem > max_tablet_write_mem_usage) { max_tablet_write_mem_usage = write_mem; } ``` ########## be/src/util/runtime_profile.cpp: ########## @@ -125,6 +127,90 @@ void RuntimeProfile::merge(RuntimeProfile* other) { } } +void RuntimeProfile::update(const PRuntimeProfileTree& proto_profile) { Review Comment: warning: unknown type name 'PRuntimeProfileTree'; did you mean 'TRuntimeProfileTree'? [clang-diagnostic-error] ```suggestion void RuntimeProfile::update(const TRuntimeProfileTree& proto_profile) { ``` **be/src/util/runtime_profile.h:47:** 'TRuntimeProfileTree' declared here ```cpp class TRuntimeProfileTree; ^ ``` ########## be/src/util/runtime_profile.cpp: ########## @@ -125,6 +127,90 @@ } } +void RuntimeProfile::update(const PRuntimeProfileTree& proto_profile) { + int idx = 0; + std::vector<PRuntimeProfileNode> nodes = {proto_profile.nodes().begin(), + proto_profile.nodes().end()}; Review Comment: warning: type 'const std::vector<TRuntimeProfileNode>' does not provide a call operator [clang-diagnostic-error] ```cpp proto_profile.nodes().end()}; ^ ``` ########## be/src/util/runtime_profile.cpp: ########## @@ -125,6 +127,90 @@ } } +void RuntimeProfile::update(const PRuntimeProfileTree& proto_profile) { + int idx = 0; + std::vector<PRuntimeProfileNode> nodes = {proto_profile.nodes().begin(), + proto_profile.nodes().end()}; + update(nodes, &idx); + DCHECK_EQ(idx, nodes.size()); +} + +void RuntimeProfile::update(const std::vector<PRuntimeProfileNode>& nodes, int* idx) { + DCHECK_LT(*idx, nodes.size()); + const PRuntimeProfileNode& node = nodes[*idx]; + { + std::lock_guard<std::mutex> l(_counter_map_lock); + + for (const auto& counter : node.counters()) { + CounterMap::iterator j = _counter_map.find(counter.name()); + + if (j == _counter_map.end()) { + _counter_map[counter.name()] = _pool->add( + new Counter(static_cast<TUnit::type>(counter.type()), counter.value())); + } else { + if (j->second->type() != static_cast<TUnit::type>(counter.type())) { + LOG(ERROR) << "Cannot update protobuf counters with the same name (" << j->first + << ") but different types."; + } else { + j->second->set(counter.value()); + } + } + } + + for (auto& child_counter_src_itr : node.child_counters_map()) { + std::set<std::string>* child_counters = find_or_insert( + &_child_counter_map, child_counter_src_itr.first, std::set<std::string>()); + child_counters->insert(child_counter_src_itr.second.child_counters_name().begin(), + child_counter_src_itr.second.child_counters_name().end()); + } + } + + { + std::lock_guard<std::mutex> l(_info_strings_lock); + const InfoStrings& info_strings = {node.info_strings().begin(), node.info_strings().end()}; + for (const std::string& key : node.info_strings_display_order()) { Review Comment: warning: type 'const std::vector<std::string>' (aka 'const vector<basic_string<char>>') does not provide a call operator [clang-diagnostic-error] ```cpp for (const std::string& key : node.info_strings_display_order()) { ^ ``` ########## be/src/util/runtime_profile.cpp: ########## @@ -125,6 +127,90 @@ } } +void RuntimeProfile::update(const PRuntimeProfileTree& proto_profile) { + int idx = 0; + std::vector<PRuntimeProfileNode> nodes = {proto_profile.nodes().begin(), + proto_profile.nodes().end()}; + update(nodes, &idx); + DCHECK_EQ(idx, nodes.size()); +} + +void RuntimeProfile::update(const std::vector<PRuntimeProfileNode>& nodes, int* idx) { + DCHECK_LT(*idx, nodes.size()); + const PRuntimeProfileNode& node = nodes[*idx]; + { + std::lock_guard<std::mutex> l(_counter_map_lock); + + for (const auto& counter : node.counters()) { + CounterMap::iterator j = _counter_map.find(counter.name()); + + if (j == _counter_map.end()) { + _counter_map[counter.name()] = _pool->add( + new Counter(static_cast<TUnit::type>(counter.type()), counter.value())); + } else { + if (j->second->type() != static_cast<TUnit::type>(counter.type())) { + LOG(ERROR) << "Cannot update protobuf counters with the same name (" << j->first + << ") but different types."; + } else { + j->second->set(counter.value()); + } + } + } + + for (auto& child_counter_src_itr : node.child_counters_map()) { + std::set<std::string>* child_counters = find_or_insert( + &_child_counter_map, child_counter_src_itr.first, std::set<std::string>()); + child_counters->insert(child_counter_src_itr.second.child_counters_name().begin(), + child_counter_src_itr.second.child_counters_name().end()); + } + } + + { + std::lock_guard<std::mutex> l(_info_strings_lock); + const InfoStrings& info_strings = {node.info_strings().begin(), node.info_strings().end()}; Review Comment: warning: type 'const std::map<std::string, std::string>' (aka 'const map<basic_string<char>, basic_string<char>>') does not provide a call operator [clang-diagnostic-error] ```cpp const InfoStrings& info_strings = {node.info_strings().begin(), node.info_strings().end()}; ^ ``` ########## be/src/util/runtime_profile.cpp: ########## @@ -125,6 +127,90 @@ } } +void RuntimeProfile::update(const PRuntimeProfileTree& proto_profile) { + int idx = 0; + std::vector<PRuntimeProfileNode> nodes = {proto_profile.nodes().begin(), + proto_profile.nodes().end()}; + update(nodes, &idx); + DCHECK_EQ(idx, nodes.size()); +} + +void RuntimeProfile::update(const std::vector<PRuntimeProfileNode>& nodes, int* idx) { + DCHECK_LT(*idx, nodes.size()); + const PRuntimeProfileNode& node = nodes[*idx]; + { + std::lock_guard<std::mutex> l(_counter_map_lock); + + for (const auto& counter : node.counters()) { + CounterMap::iterator j = _counter_map.find(counter.name()); + + if (j == _counter_map.end()) { + _counter_map[counter.name()] = _pool->add( + new Counter(static_cast<TUnit::type>(counter.type()), counter.value())); + } else { + if (j->second->type() != static_cast<TUnit::type>(counter.type())) { + LOG(ERROR) << "Cannot update protobuf counters with the same name (" << j->first + << ") but different types."; + } else { + j->second->set(counter.value()); + } + } + } + + for (auto& child_counter_src_itr : node.child_counters_map()) { Review Comment: warning: type 'const std::map<std::string, std::set<std::string>>' (aka 'const map<basic_string<char>, set<basic_string<char>>>') does not provide a call operator [clang-diagnostic-error] ```cpp for (auto& child_counter_src_itr : node.child_counters_map()) { ^ ``` ########## be/src/util/runtime_profile.h: ########## @@ -272,6 +272,14 @@ // the key has already been registered. void update(const TRuntimeProfileTree& thrift_profile); + // update a subtree of profiles from nodes, rooted at *idx. + // On return, *idx points to the node immediately following this subtree. + void update(const std::vector<TRuntimeProfileNode>& nodes, int* idx); + + // Used to transfer profile between BE, same behavior as thrift update. + void update(const PRuntimeProfileTree& proto_profile); Review Comment: warning: unknown type name 'PRuntimeProfileTree'; did you mean 'TRuntimeProfileTree'? [clang-diagnostic-error] ```suggestion void update(const TRuntimeProfileTree& proto_profile); ``` **be/src/util/runtime_profile.h:47:** 'TRuntimeProfileTree' declared here ```cpp class TRuntimeProfileTree; ^ ``` ########## be/src/util/runtime_profile.h: ########## @@ -331,6 +339,10 @@ void to_thrift(TRuntimeProfileTree* tree); void to_thrift(std::vector<TRuntimeProfileNode>* nodes); + // Used to transfer profile between BE, same behavior as to_thrift. + void to_proto(PRuntimeProfileTree* tree); + void to_proto(google::protobuf::RepeatedPtrField<PRuntimeProfileNode>* nodes) const; Review Comment: warning: unknown type name 'PRuntimeProfileNode'; did you mean 'TRuntimeProfileNode'? [clang-diagnostic-error] ```suggestion void to_proto(google::protobuf::RepeatedPtrField<TRuntimeProfileNode>* nodes) const; ``` **be/src/util/runtime_profile.h:46:** 'TRuntimeProfileNode' declared here ```cpp class TRuntimeProfileNode; ^ ``` ########## be/src/util/runtime_profile.h: ########## @@ -331,6 +339,10 @@ void to_thrift(TRuntimeProfileTree* tree); void to_thrift(std::vector<TRuntimeProfileNode>* nodes); + // Used to transfer profile between BE, same behavior as to_thrift. + void to_proto(PRuntimeProfileTree* tree); Review Comment: warning: unknown type name 'PRuntimeProfileTree'; did you mean 'TRuntimeProfileTree'? [clang-diagnostic-error] ```suggestion void to_proto(TRuntimeProfileTree* tree); ``` **be/src/util/runtime_profile.h:47:** 'TRuntimeProfileTree' declared here ```cpp class TRuntimeProfileTree; ^ ``` ########## be/src/runtime/fragment_mgr.cpp: ########## @@ -402,7 +403,10 @@ void FragmentMgr::coordinator_callback(const ReportStatusRequest& req) { params.__isset.profile = false; } else { req.profile->to_thrift(¶ms.profile); + if (req.load_channel_profile) + req.load_channel_profile->to_thrift(¶ms.loadChannelProfile); Review Comment: warning: statement should be inside braces [readability-braces-around-statements] ```suggestion if (req.load_channel_profile) { req.load_channel_profile->to_thrift(¶ms.loadChannelProfile); } ``` ########## be/src/runtime/tablets_channel.cpp: ########## @@ -221,17 +241,33 @@ } int64_t TabletsChannel::mem_consumption() { - int64_t mem_usage = 0; + int64_t write_mem_usage = 0; + int64_t flush_mem_usage = 0; + int64_t max_tablet_mem_usage = 0; + int64_t max_tablet_write_mem_usage = 0; + int64_t max_tablet_flush_mem_usage = 0; { std::lock_guard<SpinLock> l(_tablet_writers_lock); _mem_consumptions.clear(); for (auto& it : _tablet_writers) { - int64_t writer_mem = it.second->mem_consumption(); - mem_usage += writer_mem; - _mem_consumptions.emplace(writer_mem, it.first); + int64_t write_mem = it.second->mem_consumption(MemType::WRITE); + write_mem_usage += write_mem; + int64_t flush_mem = it.second->mem_consumption(MemType::FLUSH); + flush_mem_usage += flush_mem; + if (write_mem > max_tablet_write_mem_usage) max_tablet_write_mem_usage = write_mem; + if (flush_mem > max_tablet_flush_mem_usage) max_tablet_flush_mem_usage = flush_mem; + if (write_mem + flush_mem > max_tablet_mem_usage) + max_tablet_mem_usage = write_mem + flush_mem; Review Comment: warning: statement should be inside braces [readability-braces-around-statements] ```suggestion if (write_mem + flush_mem > max_tablet_mem_usage) { max_tablet_mem_usage = write_mem + flush_mem; } ``` ########## be/src/util/runtime_profile.cpp: ########## @@ -125,6 +127,90 @@ } } +void RuntimeProfile::update(const PRuntimeProfileTree& proto_profile) { + int idx = 0; + std::vector<PRuntimeProfileNode> nodes = {proto_profile.nodes().begin(), + proto_profile.nodes().end()}; + update(nodes, &idx); + DCHECK_EQ(idx, nodes.size()); +} + +void RuntimeProfile::update(const std::vector<PRuntimeProfileNode>& nodes, int* idx) { Review Comment: warning: unknown type name 'PRuntimeProfileNode'; did you mean 'TRuntimeProfileNode'? [clang-diagnostic-error] ```suggestion void RuntimeProfile::update(const std::vector<TRuntimeProfileNode>& nodes, int* idx) { ``` **be/src/util/runtime_profile.h:46:** 'TRuntimeProfileNode' declared here ```cpp class TRuntimeProfileNode; ^ ``` ########## be/src/util/runtime_profile.cpp: ########## @@ -125,6 +127,90 @@ } } +void RuntimeProfile::update(const PRuntimeProfileTree& proto_profile) { + int idx = 0; + std::vector<PRuntimeProfileNode> nodes = {proto_profile.nodes().begin(), + proto_profile.nodes().end()}; + update(nodes, &idx); + DCHECK_EQ(idx, nodes.size()); +} + +void RuntimeProfile::update(const std::vector<PRuntimeProfileNode>& nodes, int* idx) { + DCHECK_LT(*idx, nodes.size()); + const PRuntimeProfileNode& node = nodes[*idx]; + { + std::lock_guard<std::mutex> l(_counter_map_lock); + + for (const auto& counter : node.counters()) { Review Comment: warning: type 'const std::vector<TCounter>' does not provide a call operator [clang-diagnostic-error] ```cpp for (const auto& counter : node.counters()) { ^ ``` ########## be/src/util/runtime_profile.cpp: ########## @@ -125,6 +127,90 @@ } } +void RuntimeProfile::update(const PRuntimeProfileTree& proto_profile) { + int idx = 0; + std::vector<PRuntimeProfileNode> nodes = {proto_profile.nodes().begin(), + proto_profile.nodes().end()}; + update(nodes, &idx); + DCHECK_EQ(idx, nodes.size()); +} + +void RuntimeProfile::update(const std::vector<PRuntimeProfileNode>& nodes, int* idx) { + DCHECK_LT(*idx, nodes.size()); + const PRuntimeProfileNode& node = nodes[*idx]; Review Comment: warning: unknown type name 'PRuntimeProfileNode'; did you mean 'TRuntimeProfileNode'? [clang-diagnostic-error] ```suggestion const TRuntimeProfileNode& node = nodes[*idx]; ``` **be/src/util/runtime_profile.h:46:** 'TRuntimeProfileNode' declared here ```cpp class TRuntimeProfileNode; ^ ``` ########## be/src/util/runtime_profile.cpp: ########## @@ -125,6 +127,90 @@ } } +void RuntimeProfile::update(const PRuntimeProfileTree& proto_profile) { + int idx = 0; + std::vector<PRuntimeProfileNode> nodes = {proto_profile.nodes().begin(), Review Comment: warning: unknown type name 'PRuntimeProfileNode'; did you mean 'TRuntimeProfileNode'? [clang-diagnostic-error] ```suggestion std::vector<TRuntimeProfileNode> nodes = {proto_profile.nodes().begin(), ``` **be/src/util/runtime_profile.h:46:** 'TRuntimeProfileNode' declared here ```cpp class TRuntimeProfileNode; ^ ``` ########## be/src/util/runtime_profile.cpp: ########## @@ -125,6 +127,90 @@ } } +void RuntimeProfile::update(const PRuntimeProfileTree& proto_profile) { + int idx = 0; + std::vector<PRuntimeProfileNode> nodes = {proto_profile.nodes().begin(), Review Comment: warning: type 'const std::vector<TRuntimeProfileNode>' does not provide a call operator [clang-diagnostic-error] ```cpp std::vector<PRuntimeProfileNode> nodes = {proto_profile.nodes().begin(), ^ ``` ########## be/src/util/runtime_profile.cpp: ########## @@ -125,6 +127,90 @@ } } +void RuntimeProfile::update(const PRuntimeProfileTree& proto_profile) { + int idx = 0; + std::vector<PRuntimeProfileNode> nodes = {proto_profile.nodes().begin(), + proto_profile.nodes().end()}; + update(nodes, &idx); + DCHECK_EQ(idx, nodes.size()); +} + +void RuntimeProfile::update(const std::vector<PRuntimeProfileNode>& nodes, int* idx) { + DCHECK_LT(*idx, nodes.size()); + const PRuntimeProfileNode& node = nodes[*idx]; + { + std::lock_guard<std::mutex> l(_counter_map_lock); + + for (const auto& counter : node.counters()) { + CounterMap::iterator j = _counter_map.find(counter.name()); + + if (j == _counter_map.end()) { + _counter_map[counter.name()] = _pool->add( + new Counter(static_cast<TUnit::type>(counter.type()), counter.value())); + } else { + if (j->second->type() != static_cast<TUnit::type>(counter.type())) { + LOG(ERROR) << "Cannot update protobuf counters with the same name (" << j->first + << ") but different types."; + } else { + j->second->set(counter.value()); + } + } + } + + for (auto& child_counter_src_itr : node.child_counters_map()) { + std::set<std::string>* child_counters = find_or_insert( + &_child_counter_map, child_counter_src_itr.first, std::set<std::string>()); + child_counters->insert(child_counter_src_itr.second.child_counters_name().begin(), + child_counter_src_itr.second.child_counters_name().end()); + } + } + + { + std::lock_guard<std::mutex> l(_info_strings_lock); + const InfoStrings& info_strings = {node.info_strings().begin(), node.info_strings().end()}; + for (const std::string& key : node.info_strings_display_order()) { + // Look for existing info strings and update in place. If there + // are new strings, add them to the end of the display order. + // TODO: Is nodes.info_strings always a superset of + // _info_strings? If so, can just copy the display order. + InfoStrings::const_iterator it = info_strings.find(key); + DCHECK(it != info_strings.end()); + InfoStrings::iterator existing = _info_strings.find(key); + + if (existing == _info_strings.end()) { + _info_strings.insert(std::make_pair(key, it->second)); + _info_strings_display_order.push_back(key); + } else { + _info_strings[key] = it->second; + } + } + } + + ++*idx; + { + std::lock_guard<std::mutex> l(_children_lock); + + // update children with matching names; create new ones if they don't match + for (int i = 0; i < node.num_children(); ++i) { Review Comment: warning: called object type 'int32_t' (aka 'int') is not a function or function pointer [clang-diagnostic-error] ```cpp for (int i = 0; i < node.num_children(); ++i) { ^ ``` ########## be/src/util/runtime_profile.cpp: ########## @@ -125,6 +127,90 @@ } } +void RuntimeProfile::update(const PRuntimeProfileTree& proto_profile) { + int idx = 0; + std::vector<PRuntimeProfileNode> nodes = {proto_profile.nodes().begin(), + proto_profile.nodes().end()}; + update(nodes, &idx); + DCHECK_EQ(idx, nodes.size()); +} + +void RuntimeProfile::update(const std::vector<PRuntimeProfileNode>& nodes, int* idx) { + DCHECK_LT(*idx, nodes.size()); + const PRuntimeProfileNode& node = nodes[*idx]; + { + std::lock_guard<std::mutex> l(_counter_map_lock); + + for (const auto& counter : node.counters()) { + CounterMap::iterator j = _counter_map.find(counter.name()); + + if (j == _counter_map.end()) { + _counter_map[counter.name()] = _pool->add( + new Counter(static_cast<TUnit::type>(counter.type()), counter.value())); + } else { + if (j->second->type() != static_cast<TUnit::type>(counter.type())) { + LOG(ERROR) << "Cannot update protobuf counters with the same name (" << j->first + << ") but different types."; + } else { + j->second->set(counter.value()); + } + } + } + + for (auto& child_counter_src_itr : node.child_counters_map()) { + std::set<std::string>* child_counters = find_or_insert( + &_child_counter_map, child_counter_src_itr.first, std::set<std::string>()); + child_counters->insert(child_counter_src_itr.second.child_counters_name().begin(), + child_counter_src_itr.second.child_counters_name().end()); + } + } + + { + std::lock_guard<std::mutex> l(_info_strings_lock); + const InfoStrings& info_strings = {node.info_strings().begin(), node.info_strings().end()}; Review Comment: warning: type 'const std::map<std::string, std::string>' (aka 'const map<basic_string<char>, basic_string<char>>') does not provide a call operator [clang-diagnostic-error] ```cpp const InfoStrings& info_strings = {node.info_strings().begin(), node.info_strings().end()}; ^ ``` ########## be/src/util/runtime_profile.h: ########## @@ -272,6 +272,14 @@ class RuntimeProfile { // the key has already been registered. void update(const TRuntimeProfileTree& thrift_profile); + // update a subtree of profiles from nodes, rooted at *idx. + // On return, *idx points to the node immediately following this subtree. + void update(const std::vector<TRuntimeProfileNode>& nodes, int* idx); + + // Used to transfer profile between BE, same behavior as thrift update. + void update(const PRuntimeProfileTree& proto_profile); Review Comment: warning: class member cannot be redeclared [clang-diagnostic-error] ```cpp void update(const PRuntimeProfileTree& proto_profile); ^ ``` **be/src/util/runtime_profile.h:272:** previous declaration is here ```cpp void update(const TRuntimeProfileTree& thrift_profile); ^ ``` ########## be/src/util/runtime_profile.h: ########## @@ -272,6 +272,14 @@ // the key has already been registered. void update(const TRuntimeProfileTree& thrift_profile); + // update a subtree of profiles from nodes, rooted at *idx. + // On return, *idx points to the node immediately following this subtree. + void update(const std::vector<TRuntimeProfileNode>& nodes, int* idx); + + // Used to transfer profile between BE, same behavior as thrift update. + void update(const PRuntimeProfileTree& proto_profile); + void update(const std::vector<PRuntimeProfileNode>& nodes, int* idx); Review Comment: warning: class member cannot be redeclared [clang-diagnostic-error] ```cpp void update(const std::vector<PRuntimeProfileNode>& nodes, int* idx); ^ ``` **be/src/util/runtime_profile.h:276:** previous declaration is here ```cpp void update(const std::vector<TRuntimeProfileNode>& nodes, int* idx); ^ ``` ########## be/src/util/runtime_profile.cpp: ########## @@ -125,6 +127,90 @@ } } +void RuntimeProfile::update(const PRuntimeProfileTree& proto_profile) { + int idx = 0; + std::vector<PRuntimeProfileNode> nodes = {proto_profile.nodes().begin(), + proto_profile.nodes().end()}; + update(nodes, &idx); + DCHECK_EQ(idx, nodes.size()); +} + +void RuntimeProfile::update(const std::vector<PRuntimeProfileNode>& nodes, int* idx) { + DCHECK_LT(*idx, nodes.size()); + const PRuntimeProfileNode& node = nodes[*idx]; + { + std::lock_guard<std::mutex> l(_counter_map_lock); + + for (const auto& counter : node.counters()) { + CounterMap::iterator j = _counter_map.find(counter.name()); + + if (j == _counter_map.end()) { + _counter_map[counter.name()] = _pool->add( + new Counter(static_cast<TUnit::type>(counter.type()), counter.value())); + } else { + if (j->second->type() != static_cast<TUnit::type>(counter.type())) { + LOG(ERROR) << "Cannot update protobuf counters with the same name (" << j->first + << ") but different types."; + } else { + j->second->set(counter.value()); + } + } + } + + for (auto& child_counter_src_itr : node.child_counters_map()) { + std::set<std::string>* child_counters = find_or_insert( + &_child_counter_map, child_counter_src_itr.first, std::set<std::string>()); + child_counters->insert(child_counter_src_itr.second.child_counters_name().begin(), + child_counter_src_itr.second.child_counters_name().end()); + } + } + + { + std::lock_guard<std::mutex> l(_info_strings_lock); + const InfoStrings& info_strings = {node.info_strings().begin(), node.info_strings().end()}; + for (const std::string& key : node.info_strings_display_order()) { + // Look for existing info strings and update in place. If there + // are new strings, add them to the end of the display order. + // TODO: Is nodes.info_strings always a superset of + // _info_strings? If so, can just copy the display order. + InfoStrings::const_iterator it = info_strings.find(key); + DCHECK(it != info_strings.end()); + InfoStrings::iterator existing = _info_strings.find(key); + + if (existing == _info_strings.end()) { + _info_strings.insert(std::make_pair(key, it->second)); + _info_strings_display_order.push_back(key); + } else { + _info_strings[key] = it->second; + } + } + } + + ++*idx; + { + std::lock_guard<std::mutex> l(_children_lock); + + // update children with matching names; create new ones if they don't match + for (int i = 0; i < node.num_children(); ++i) { + const PRuntimeProfileNode& pchild = nodes[*idx]; Review Comment: warning: unknown type name 'PRuntimeProfileNode'; did you mean 'TRuntimeProfileNode'? [clang-diagnostic-error] ```suggestion const TRuntimeProfileNode& pchild = nodes[*idx]; ``` **be/src/util/runtime_profile.h:46:** 'TRuntimeProfileNode' declared here ```cpp class TRuntimeProfileNode; ^ ``` ########## be/src/util/runtime_profile.h: ########## @@ -272,6 +272,14 @@ // the key has already been registered. void update(const TRuntimeProfileTree& thrift_profile); + // update a subtree of profiles from nodes, rooted at *idx. + // On return, *idx points to the node immediately following this subtree. + void update(const std::vector<TRuntimeProfileNode>& nodes, int* idx); + + // Used to transfer profile between BE, same behavior as thrift update. + void update(const PRuntimeProfileTree& proto_profile); + void update(const std::vector<PRuntimeProfileNode>& nodes, int* idx); Review Comment: warning: unknown type name 'PRuntimeProfileNode'; did you mean 'TRuntimeProfileNode'? [clang-diagnostic-error] ```suggestion void update(const std::vector<TRuntimeProfileNode>& nodes, int* idx); ``` **be/src/util/runtime_profile.h:46:** 'TRuntimeProfileNode' declared here ```cpp class TRuntimeProfileNode; ^ ``` -- 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-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org