[fix](debug) add bvar counter for memtable & loadchannel (#22578)

* [fix](debug) add bvar counter for memtable & loadchannel

Signed-off-by: freemandealer <freeman.zhang1992@gmail.com>

* format code

Signed-off-by: freemandealer <freeman.zhang1992@gmail.com>

---------

Signed-off-by: freemandealer <freeman.zhang1992@gmail.com>
This commit is contained in:
zhengyu
2023-08-04 13:58:28 +08:00
committed by GitHub
parent 658d75c816
commit 24c1953e91
2 changed files with 11 additions and 0 deletions

View File

@ -26,6 +26,7 @@
#include <string>
#include <vector>
#include "bvar/bvar.h"
#include "common/config.h"
#include "olap/memtable_memory_limiter.h"
#include "olap/olap_define.h"
@ -41,6 +42,9 @@
#include "vec/columns/column.h"
namespace doris {
bvar::Adder<int64_t> g_memtable_cnt("memtable_cnt");
using namespace ErrorCode;
MemTable::MemTable(int64_t tablet_id, const TabletSchema* tablet_schema,
@ -59,6 +63,7 @@ MemTable::MemTable(int64_t tablet_id, const TabletSchema* tablet_schema,
_offsets_of_aggregate_states(tablet_schema->num_columns()),
_total_size_of_aggregate_states(0),
_mem_usage(0) {
g_memtable_cnt << 1;
#ifndef BE_TEST
_insert_mem_tracker_use_hook = std::make_unique<MemTracker>(
fmt::format("MemTableHookInsert:TabletId={}", std::to_string(tablet_id)),
@ -129,6 +134,7 @@ void MemTable::_init_agg_functions(const vectorized::Block* block) {
}
MemTable::~MemTable() {
g_memtable_cnt << -1;
if (_keys_type != KeysType::DUP_KEYS) {
for (auto it = _row_in_blocks.begin(); it != _row_in_blocks.end(); it++) {
if (!(*it)->has_init_agg()) {

View File

@ -20,11 +20,14 @@
#include <gen_cpp/internal_service.pb.h>
#include <glog/logging.h>
#include "bvar/bvar.h"
#include "runtime/memory/mem_tracker.h"
#include "runtime/tablets_channel.h"
namespace doris {
bvar::Adder<int64_t> g_loadchannel_cnt("loadchannel_cnt");
LoadChannel::LoadChannel(const UniqueId& load_id, int64_t timeout_s, bool is_high_priority,
const std::string& sender_ip, int64_t backend_id, bool enable_profile)
: _load_id(load_id),
@ -33,6 +36,7 @@ LoadChannel::LoadChannel(const UniqueId& load_id, int64_t timeout_s, bool is_hig
_sender_ip(sender_ip),
_backend_id(backend_id),
_enable_profile(enable_profile) {
g_loadchannel_cnt << 1;
// _last_updated_time should be set before being inserted to
// _load_channels in load_channel_mgr, or it may be erased
// immediately by gc thread.
@ -41,6 +45,7 @@ LoadChannel::LoadChannel(const UniqueId& load_id, int64_t timeout_s, bool is_hig
}
LoadChannel::~LoadChannel() {
g_loadchannel_cnt << -1;
LOG(INFO) << "load channel removed"
<< " load_id=" << _load_id << ", is high priority=" << _is_high_priority
<< ", sender_ip=" << _sender_ip;