Skip to content

Commit

Permalink
fix web page
Browse files Browse the repository at this point in the history
  • Loading branch information
xinyiZzz committed Nov 7, 2022
1 parent 10edd76 commit e9303cc
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 17 deletions.
15 changes: 8 additions & 7 deletions be/src/http/default_path_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,14 @@ void mem_tracker_handler(const WebPageHandler::ArgumentMap& args, std::stringstr
MemTrackerLimiter::Type::CONSISTENCY);
}
} else {
(*output) << "<h4>*注: (详情见文档)</h4>\n";
(*output) << "<h4> 1.`/mem_tracker?type=global`查看每个type的内存统计</h4>\n";
(*output) << "<h4> 2.`/mem_tracker`统计的是虚存, 等于`/memz`中`Actual memory "
"used`</h4>\n";
(*output) << "<h4> 3.`process`等于所有type内存之和, `/mem_tracker`逻辑上可分为4层: "
"1)`process` 2)`type` 3)`query/load/compation task etc.` 4)`exec node "
"etc.`</h4>\n";
(*output) << "<h4>*Note: (see documentation for details)</h4>\n";
(*output) << "<h4> 1.`/mem_tracker?type=global` to view the memory statistics of each "
"type</h4>\n";
(*output) << "<h4> 2.`/mem_tracker` counts virtual memory, which is equal to `Actual "
"memory used` in `/memz`</h4>\n";
(*output) << "<h4> 3.`process` is equal to the sum of all types of memory, "
"`/mem_tracker` can be logically divided into 4 layers: 1)`process` 2)`type` "
"3)`query/load/compation task etc.` 4)`exec node etc.`</h4>\n";
MemTrackerLimiter::make_process_snapshots(&snapshots);
}

Expand Down
7 changes: 5 additions & 2 deletions be/src/olap/delta_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "olap/schema.h"
#include "olap/schema_change.h"
#include "olap/storage_engine.h"
#include "runtime/load_channel_mgr.h"
#include "runtime/row_batch.h"
#include "runtime/tuple_row.h"
#include "service/backend_options.h"
Expand Down Expand Up @@ -285,10 +286,12 @@ void DeltaWriter::_reset_mem_table() {
}
auto mem_table_insert_tracker = std::make_shared<MemTracker>(
fmt::format("MemTableManualInsert:TabletId={}:MemTableNum={}#loadID={}",
std::to_string(tablet_id()), _mem_table_num, _load_id.to_string()));
std::to_string(tablet_id()), _mem_table_num, _load_id.to_string()),
nullptr, ExecEnv::GetInstance()->load_channel_mgr()->mem_tracker_set());
auto mem_table_flush_tracker = std::make_shared<MemTracker>(
fmt::format("MemTableHookFlush:TabletId={}:MemTableNum={}#loadID={}",
std::to_string(tablet_id()), _mem_table_num++, _load_id.to_string()));
std::to_string(tablet_id()), _mem_table_num++, _load_id.to_string()),
nullptr, ExecEnv::GetInstance()->load_channel_mgr()->mem_tracker_set());
{
std::lock_guard<SpinLock> l(_mem_table_tracker_lock);
_mem_table_tracker.push_back(mem_table_insert_tracker);
Expand Down
8 changes: 6 additions & 2 deletions be/src/runtime/load_channel_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ Status LoadChannelMgr::init(int64_t process_mem_limit) {
_load_hard_mem_limit = calc_process_max_load_memory(process_mem_limit);
_load_soft_mem_limit = _load_hard_mem_limit * config::load_process_soft_mem_limit_percent / 100;
_mem_tracker = std::make_unique<MemTracker>("LoadChannelMgr");
_mem_tracker_set = std::make_unique<MemTrackerLimiter>(MemTrackerLimiter::Type::LOAD,
"LoadChannelMgrTrackerSet");
REGISTER_HOOK_METRIC(load_channel_mem_consumption,
[this]() { return _mem_tracker->consumption(); });
_last_success_channel = new_lru_cache("LastestSuccessChannelCache", 1024);
Expand All @@ -94,8 +96,10 @@ Status LoadChannelMgr::open(const PTabletWriterOpenRequest& params) {
bool is_high_priority = (params.has_is_high_priority() && params.is_high_priority());

// Use the same mem limit as LoadChannelMgr for a single load channel
auto channel_mem_tracker = std::make_unique<MemTracker>(fmt::format(
"LoadChannel#senderIp={}#loadID={}", params.sender_ip(), load_id.to_string()));
auto channel_mem_tracker = std::make_unique<MemTracker>(
fmt::format("LoadChannel#senderIp={}#loadID={}", params.sender_ip(),
load_id.to_string()),
nullptr, ExecEnv::GetInstance()->load_channel_mgr()->mem_tracker_set());
channel.reset(new LoadChannel(load_id, std::move(channel_mem_tracker),
channel_timeout_s, is_high_priority, params.sender_ip(),
params.is_vectorized()));
Expand Down
3 changes: 3 additions & 0 deletions be/src/runtime/load_channel_mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class LoadChannelMgr {
}
_mem_tracker->set_consumption(mem_usage);
}
MemTrackerLimiter* mem_tracker_set() { return _mem_tracker_set.get(); }

private:
template <typename Request>
Expand All @@ -91,6 +92,8 @@ class LoadChannelMgr {

// check the total load channel mem consumption of this Backend
std::unique_ptr<MemTracker> _mem_tracker;
// Associate load channel tracker and memtable tracker, avoid default association to Orphan tracker.
std::unique_ptr<MemTrackerLimiter> _mem_tracker_set;
int64_t _load_hard_mem_limit = -1;
int64_t _load_soft_mem_limit = -1;

Expand Down
16 changes: 11 additions & 5 deletions be/src/runtime/memory/mem_tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ struct TrackerGroup {
// Multiple groups are used to reduce the impact of locks.
static std::vector<TrackerGroup> mem_tracker_pool(1000);

MemTracker::MemTracker(const std::string& label, RuntimeProfile* profile) : _label(label) {
MemTracker::MemTracker(const std::string& label, RuntimeProfile* profile, MemTrackerLimiter* parent)
: _label(label) {
if (profile == nullptr) {
_consumption = std::make_shared<RuntimeProfile::HighWaterMarkCounter>(TUnit::BYTES);
} else {
Expand All @@ -57,10 +58,15 @@ MemTracker::MemTracker(const std::string& label, RuntimeProfile* profile) : _lab
_consumption = profile->AddSharedHighWaterMarkCounter(COUNTER_NAME, TUnit::BYTES);
}

DCHECK(thread_context()->_thread_mem_tracker_mgr->limiter_mem_tracker() != nullptr);
_parent_label = thread_context()->_thread_mem_tracker_mgr->limiter_mem_tracker()->label();
_parent_group_num =
thread_context()->_thread_mem_tracker_mgr->limiter_mem_tracker()->group_num();
if (parent) {
_parent_label = parent->label();
_parent_group_num = parent->group_num();
} else {
DCHECK(thread_context()->_thread_mem_tracker_mgr->limiter_mem_tracker() != nullptr);
_parent_label = thread_context()->_thread_mem_tracker_mgr->limiter_mem_tracker()->label();
_parent_group_num =
thread_context()->_thread_mem_tracker_mgr->limiter_mem_tracker()->group_num();
}
{
std::lock_guard<std::mutex> l(mem_tracker_pool[_parent_group_num].group_lock);
_tracker_group_it = mem_tracker_pool[_parent_group_num].trackers.insert(
Expand Down
5 changes: 4 additions & 1 deletion be/src/runtime/memory/mem_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

namespace doris {

class MemTrackerLimiter;

// Used to track memory usage.
//
// MemTracker can be consumed manually by consume()/release(), or put into SCOPED_CONSUME_MEM_TRACKER,
Expand All @@ -42,7 +44,8 @@ class MemTracker {
};

// Creates and adds the tracker to the mem_tracker_pool.
MemTracker(const std::string& label, RuntimeProfile* profile = nullptr);
MemTracker(const std::string& label, RuntimeProfile* profile = nullptr,
MemTrackerLimiter* parent = nullptr);
// For MemTrackerLimiter
MemTracker() { _parent_group_num = -1; }

Expand Down
1 change: 1 addition & 0 deletions be/src/runtime/memory/thread_mem_tracker_mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ inline void ThreadMemTrackerMgr::init() {
DCHECK(_limiter_tracker == nullptr);
_limiter_tracker = ExecEnv::GetInstance()->orphan_mem_tracker();
_limiter_tracker_raw = ExecEnv::GetInstance()->orphan_mem_tracker_raw();
_check_limit = true;
_init = true;
}

Expand Down

0 comments on commit e9303cc

Please sign in to comment.