Skip to content

Commit

Permalink
2
Browse files Browse the repository at this point in the history
  • Loading branch information
xinyiZzz committed May 6, 2024
1 parent 71c4347 commit 074297d
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions be/src/util/mem_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ bvar::PassiveStatus<int64_t> g_proc_mem_no_allocator_cache(
[](void*) { return MemInfo::proc_mem_no_allocator_cache(); }, nullptr);

bool MemInfo::_s_initialized = false;
std::atomic<int64_t> MemInfo::_s_physical_mem = -1;
std::atomic<int64_t> MemInfo::_s_mem_limit = -1;
std::atomic<int64_t> MemInfo::_s_soft_mem_limit = -1;
std::atomic<int64_t> MemInfo::_s_physical_mem = std::numeric_limits<int64_t>::max();
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::string MemInfo::_s_allocator_cache_mem_str = "";
Expand Down Expand Up @@ -406,14 +406,16 @@ void MemInfo::refresh_proc_meminfo() {
physical_mem = std::min(physical_mem, cgroup_mem_limit);
}

if (physical_mem <= 0) {
LOG(WARNING)
<< "Could not determine amount of physical memory on this machine, physical_mem: "
<< physical_mem;
}

// 2. if physical_mem changed, refresh mem limit and gc size.
if (_s_physical_mem.load(std::memory_order_relaxed) != physical_mem) {
if (physical_mem > 0 && _s_physical_mem.load(std::memory_order_relaxed) != physical_mem) {
_s_physical_mem.store(physical_mem);

if (_s_physical_mem == -1) {
LOG(WARNING) << "Could not determine amount of physical memory on this machine.";
}

bool is_percent = true;
_s_mem_limit.store(
ParseUtil::parse_mem_spec(config::mem_limit, -1, _s_physical_mem, &is_percent));
Expand Down Expand Up @@ -451,7 +453,7 @@ void MemInfo::refresh_proc_meminfo() {
}
if (mem_available < 0) {
LOG(WARNING) << "Failed to get available memory, set MAX_INT.";
mem_available = 9223372036854775807LL;
mem_available = std::numeric_limits<int64_t>::max();
}
if (_s_sys_mem_available.load(std::memory_order_relaxed) != mem_available) {
_s_sys_mem_available.store(mem_available);
Expand Down

0 comments on commit 074297d

Please sign in to comment.