yiguolei commented on code in PR #34262: URL: https://github.com/apache/doris/pull/34262#discussion_r1590492617
########## be/src/util/mem_info.cpp: ########## @@ -387,58 +386,74 @@ void MemInfo::refresh_proc_meminfo() { } } } - if (meminfo.is_open()) meminfo.close(); - - if (_mem_info_bytes.find("MemAvailable") != _mem_info_bytes.end()) { - _s_sys_mem_available.store(_mem_info_bytes["MemAvailable"], std::memory_order_relaxed); - _s_sys_mem_available_str = PrettyPrinter::print( - _s_sys_mem_available.load(std::memory_order_relaxed), TUnit::BYTES); -#ifdef ADDRESS_SANITIZER - _s_sys_mem_available_str = - "[ASAN]" + - PrettyPrinter::print(_s_sys_mem_available.load(std::memory_order_relaxed), - TUnit::BYTES); -#else - _s_sys_mem_available_str = PrettyPrinter::print( - _s_sys_mem_available.load(std::memory_order_relaxed), TUnit::BYTES); -#endif + if (meminfo.is_open()) { + meminfo.close(); } -} -void MemInfo::init() { - refresh_proc_meminfo(); - _s_physical_mem = _mem_info_bytes["MemTotal"]; - - int64_t cgroup_mem_limit = 0; + // 1. calculate physical_mem + int64_t physical_mem = -1; + int64_t cgroup_mem_limit = -1; + physical_mem = _mem_info_bytes["MemTotal"]; Status status = CGroupUtil::find_cgroup_mem_limit(&cgroup_mem_limit); if (status.ok() && cgroup_mem_limit > 0) { - _s_physical_mem = std::min(_s_physical_mem, cgroup_mem_limit); + // In theory, always cgroup_mem_limit < physical_mem + physical_mem = std::min(physical_mem, cgroup_mem_limit); } - if (_s_physical_mem == -1) { - LOG(WARNING) << "Could not determine amount of physical memory on this machine."; + // 2. if physical_mem changed, refresh mem limit and gc size. + if (_s_physical_mem.load(std::memory_order_relaxed) != physical_mem) { Review Comment: should check physical_mem > 0. Because if it == -1, then the following logic after 410 is wrong. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org