Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
xinyiZzz committed Jul 8, 2024
1 parent 111886a commit 20e8053
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
12 changes: 10 additions & 2 deletions be/src/runtime/memory/mem_tracker_limiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,21 @@ void MemTrackerLimiter::make_process_snapshots(std::vector<MemTracker::Snapshot>
}

snapshot.type = "overview";
snapshot.label = "tc/jemalloc cache";
snapshot.label = "tc/jemalloc_cache";
snapshot.limit = -1;
snapshot.cur_consumption = MemInfo::allocator_cache_mem();
snapshot.peak_consumption = -1;
(*snapshots).emplace_back(snapshot);
all_tracker_mem_sum += MemInfo::allocator_cache_mem();

snapshot.type = "overview";
snapshot.label = "tc/jemalloc_metadata";
snapshot.limit = -1;
snapshot.cur_consumption = MemInfo::allocator_metadata_mem();
snapshot.peak_consumption = -1;
(*snapshots).emplace_back(snapshot);
all_tracker_mem_sum += MemInfo::allocator_metadata_mem();

snapshot.type = "overview";
snapshot.label = "sum of all trackers"; // is virtual memory
snapshot.limit = -1;
Expand All @@ -287,7 +295,7 @@ void MemTrackerLimiter::make_process_snapshots(std::vector<MemTracker::Snapshot>
(*snapshots).emplace_back(snapshot);

snapshot.type = "overview";
snapshot.label = "reserved memory";
snapshot.label = "reserve_memory";
snapshot.limit = -1;
snapshot.cur_consumption = GlobalMemoryArbitrator::process_reserved_memory();
snapshot.peak_consumption = -1;
Expand Down
3 changes: 2 additions & 1 deletion be/src/util/mem_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ std::atomic<int64_t> MemInfo::_s_mem_limit = std::numeric_limits<int64_t>::max()
std::atomic<int64_t> MemInfo::_s_soft_mem_limit = std::numeric_limits<int64_t>::max();

std::atomic<int64_t> MemInfo::_s_allocator_cache_mem = 0;
std::atomic<int64_t> MemInfo::_s_allocator_metadata_mem = 0;
std::atomic<int64_t> MemInfo::_s_je_dirty_pages_mem = std::numeric_limits<int64_t>::min();
std::atomic<int64_t> MemInfo::_s_je_dirty_pages_mem_limit = std::numeric_limits<int64_t>::max();
std::atomic<int64_t> MemInfo::_s_virtual_memory_used = 0;
Expand Down Expand Up @@ -85,9 +86,9 @@ void MemInfo::refresh_allocator_mem() {
// https://jemalloc.net/jemalloc.3.html
// https://www.bookstack.cn/read/aliyun-rds-core/4a0cdf677f62feb3.md
_s_allocator_cache_mem.store(get_je_all_arena_metrics("tcache_bytes") +
get_je_metrics("stats.metadata") +
get_je_all_arena_metrics("pdirty") * get_page_size(),
std::memory_order_relaxed);
_s_allocator_metadata_mem.store(get_je_metrics("stats.metadata"), std::memory_order_relaxed);
_s_je_dirty_pages_mem.store(get_je_all_arena_metrics("pdirty") * get_page_size(),
std::memory_order_relaxed);
_s_virtual_memory_used.store(get_je_metrics("stats.mapped"), std::memory_order_relaxed);
Expand Down
4 changes: 4 additions & 0 deletions be/src/util/mem_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ class MemInfo {
static inline size_t allocator_cache_mem() {
return _s_allocator_cache_mem.load(std::memory_order_relaxed);
}
static inline size_t allocator_metadata_mem() {
return _s_allocator_metadata_mem.load(std::memory_order_relaxed);
}
static inline int64_t je_dirty_pages_mem() {
return _s_je_dirty_pages_mem.load(std::memory_order_relaxed);
}
Expand Down Expand Up @@ -187,6 +190,7 @@ class MemInfo {
static std::atomic<int64_t> _s_soft_mem_limit;

static std::atomic<int64_t> _s_allocator_cache_mem;
static std::atomic<int64_t> _s_allocator_metadata_mem;
static std::atomic<int64_t> _s_je_dirty_pages_mem;
static std::atomic<int64_t> _s_je_dirty_pages_mem_limit;
static std::atomic<int64_t> _s_virtual_memory_used;
Expand Down

0 comments on commit 20e8053

Please sign in to comment.