Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
xinyiZzz committed Sep 9, 2024
1 parent c84426f commit 1fce289
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions be/src/runtime/memory/global_memory_arbitrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,8 @@ void GlobalMemoryArbitrator::release_process_reserved_memory(int64_t bytes) {
}
}

int64_t GlobalMemoryArbitrator::sub_thread_reserve_memory(int64_t bytes) {
return bytes - doris::thread_context()->thread_mem_tracker_mgr->reserved_mem();
}

} // namespace doris
10 changes: 10 additions & 0 deletions be/src/runtime/memory/global_memory_arbitrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,22 @@ class GlobalMemoryArbitrator {
return _s_process_reserved_memory.load(std::memory_order_relaxed);
}

static int64_t sub_thread_reserve_memory(int64_t bytes);

static bool is_exceed_soft_mem_limit(int64_t bytes = 0) {
bytes = sub_thread_reserve_memory(bytes);
if (bytes <= 0) {
return false;
}
return process_memory_usage() + bytes >= MemInfo::soft_mem_limit() ||
sys_mem_available() - bytes < MemInfo::sys_mem_available_warning_water_mark();
}

static bool is_exceed_hard_mem_limit(int64_t bytes = 0) {
bytes = sub_thread_reserve_memory(bytes);
if (bytes <= 0) {
return false;
}
// Limit process memory usage using the actual physical memory of the process in `/proc/self/status`.
// This is independent of the consumption value of the mem tracker, which counts the virtual memory
// of the process malloc.
Expand Down

0 comments on commit 1fce289

Please sign in to comment.