Merge pull request #63730 from ClickHouse/nomaps

Userspace page cache: don't collect stats if cache is unused
This commit is contained in:
Michael Kolupaev 2024-05-14 08:30:03 +00:00 committed by GitHub
commit f5decc7ac3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -198,12 +198,18 @@ size_t PageCache::getPinnedSize() const
PageCache::MemoryStats PageCache::getResidentSetSize() const
{
MemoryStats stats;
#ifdef OS_LINUX
if (use_madv_free)
{
std::unordered_set<UInt64> cache_mmap_addrs;
{
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)
cache_mmap_addrs.insert(reinterpret_cast<UInt64>(m.ptr));
}
@ -258,7 +264,7 @@ PageCache::MemoryStats PageCache::getResidentSetSize() const
UInt64 addr = unhexUInt<UInt64>(s.c_str());
current_range_is_cache = cache_mmap_addrs.contains(addr);
}
else if (s == "Rss:" || s == "LazyFree")
else if (s == "Rss:" || s == "LazyFree:")
{
skip_whitespace();
size_t val;