This commit is contained in:
Michael Kolupaev 2024-05-14 00:29:52 +00:00
parent bdc82b61f5
commit f6cc1051c1

View File

@ -199,16 +199,17 @@ PageCache::MemoryStats PageCache::getResidentSetSize() const
{ {
MemoryStats stats; MemoryStats stats;
/// Don't spend time on reading smaps if page cache is not used.
if (mmaps.empty())
return stats;
#ifdef OS_LINUX #ifdef OS_LINUX
if (use_madv_free) if (use_madv_free)
{ {
std::unordered_set<UInt64> cache_mmap_addrs; std::unordered_set<UInt64> cache_mmap_addrs;
{ {
std::lock_guard lock(global_mutex); std::lock_guard lock(global_mutex);
/// Don't spend time on reading smaps if page cache is not used.
if (mmaps.empty())
return stats;
for (const auto & m : mmaps) for (const auto & m : mmaps)
cache_mmap_addrs.insert(reinterpret_cast<UInt64>(m.ptr)); cache_mmap_addrs.insert(reinterpret_cast<UInt64>(m.ptr));
} }