Skip to content

Commit 2648300

Browse files
committed
add MemoryResidentWithoutPageCache metric which excludes page cache when user space page cache is used
1 parent 9fbdae0 commit 2648300

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/Common/AsynchronousMetrics.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <Common/AsynchronousMetrics.h>
99
#include <Common/Exception.h>
1010
#include <Common/Jemalloc.h>
11+
#include <Common/PageCache.h>
1112
#include <Common/formatReadable.h>
1213
#include <Common/logger_useful.h>
1314
#include <Common/setThreadName.h>
@@ -843,6 +844,22 @@ void AsynchronousMetrics::update(TimePoint update_time, bool force_update)
843844
" The large values of this metric are totally normal, and makes only technical sense."};
844845
new_values["MemoryResident"] = { data.resident,
845846
"The amount of physical memory used by the server process, in bytes." };
847+
848+
UInt64 page_cache_bytes = 0;
849+
if (context && context->getPageCache())
850+
page_cache_bytes = context->getPageCache()->sizeInBytes();
851+
852+
UInt64 resident_without_page_cache = (data.resident > page_cache_bytes)
853+
? (data.resident - page_cache_bytes)
854+
: 0;
855+
856+
new_values["MemoryResidentWithoutPageCache"] = {
857+
resident_without_page_cache,
858+
"The amount of physical memory used by the server process, excluding userspace page cache, in bytes. "
859+
"This provides a more accurate view of actual memory usage when userspace page cache is utilized. "
860+
"When userspace page cache is disabled, this value equals MemoryResident."
861+
};
862+
846863
#if !defined(OS_FREEBSD)
847864
new_values["MemoryShared"] = { data.shared,
848865
"The amount of memory used by the server process, that is also shared by another processes, in bytes."

0 commit comments

Comments
 (0)