|
8 | 8 | #include <Common/AsynchronousMetrics.h> |
9 | 9 | #include <Common/Exception.h> |
10 | 10 | #include <Common/Jemalloc.h> |
| 11 | +#include <Common/PageCache.h> |
11 | 12 | #include <Common/formatReadable.h> |
12 | 13 | #include <Common/logger_useful.h> |
13 | 14 | #include <Common/setThreadName.h> |
@@ -843,6 +844,22 @@ void AsynchronousMetrics::update(TimePoint update_time, bool force_update) |
843 | 844 | " The large values of this metric are totally normal, and makes only technical sense."}; |
844 | 845 | new_values["MemoryResident"] = { data.resident, |
845 | 846 | "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 | + |
846 | 863 | #if !defined(OS_FREEBSD) |
847 | 864 | new_values["MemoryShared"] = { data.shared, |
848 | 865 | "The amount of memory used by the server process, that is also shared by another processes, in bytes." |
|
0 commit comments