mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Merge pull request #61354 from tuanpavn/tuanpavn-add-vm-async-metrics
Add async metrics for virtual memory mappings: VMMaxMapCount & VMNumMaps
This commit is contained in:
commit
b55c1d7bc1
@ -9,6 +9,7 @@
|
|||||||
#include <IO/MMappedFileCache.h>
|
#include <IO/MMappedFileCache.h>
|
||||||
#include <IO/ReadHelpers.h>
|
#include <IO/ReadHelpers.h>
|
||||||
#include <base/errnoToString.h>
|
#include <base/errnoToString.h>
|
||||||
|
#include <base/find_symbols.h>
|
||||||
#include <base/getPageSize.h>
|
#include <base/getPageSize.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
@ -90,6 +91,9 @@ AsynchronousMetrics::AsynchronousMetrics(
|
|||||||
openFileIfExists("/sys/fs/cgroup/cpu/cpu.cfs_quota_us", cgroupcpu_cfs_quota);
|
openFileIfExists("/sys/fs/cgroup/cpu/cpu.cfs_quota_us", cgroupcpu_cfs_quota);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openFileIfExists("/proc/sys/vm/max_map_count", vm_max_map_count);
|
||||||
|
openFileIfExists("/proc/self/maps", vm_maps);
|
||||||
|
|
||||||
openSensors();
|
openSensors();
|
||||||
openBlockDevices();
|
openBlockDevices();
|
||||||
openEDAC();
|
openEDAC();
|
||||||
@ -1423,6 +1427,55 @@ void AsynchronousMetrics::update(TimePoint update_time, bool force_update)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (vm_max_map_count)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
vm_max_map_count->rewind();
|
||||||
|
|
||||||
|
uint64_t max_map_count = 0;
|
||||||
|
readText(max_map_count, *vm_max_map_count);
|
||||||
|
new_values["VMMaxMapCount"] = { max_map_count, "The maximum number of memory mappings a process may have (/proc/sys/vm/max_map_count)."};
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||||
|
openFileIfExists("/proc/sys/vm/max_map_count", vm_max_map_count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vm_maps)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
vm_maps->rewind();
|
||||||
|
|
||||||
|
uint64_t num_maps = 0;
|
||||||
|
while (!vm_maps->eof())
|
||||||
|
{
|
||||||
|
char * next_pos = find_first_symbols<'\n'>(vm_maps->position(), vm_maps->buffer().end());
|
||||||
|
vm_maps->position() = next_pos;
|
||||||
|
|
||||||
|
if (!vm_maps->hasPendingData())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (*vm_maps->position() == '\n')
|
||||||
|
{
|
||||||
|
++num_maps;
|
||||||
|
++vm_maps->position();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
new_values["VMNumMaps"] = { num_maps,
|
||||||
|
"The current number of memory mappings of the process (/proc/self/maps)."
|
||||||
|
" If it is close to the maximum (VMMaxMapCount), you should increase the limit for vm.max_map_count in /etc/sysctl.conf"};
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||||
|
openFileIfExists("/proc/self/maps", vm_maps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (size_t i = 0, size = thermal.size(); i < size; ++i)
|
for (size_t i = 0, size = thermal.size(); i < size; ++i)
|
||||||
|
@ -123,6 +123,9 @@ private:
|
|||||||
std::optional<ReadBufferFromFilePRead> cgroupcpu_cfs_quota TSA_GUARDED_BY(data_mutex);
|
std::optional<ReadBufferFromFilePRead> cgroupcpu_cfs_quota TSA_GUARDED_BY(data_mutex);
|
||||||
std::optional<ReadBufferFromFilePRead> cgroupcpu_max TSA_GUARDED_BY(data_mutex);
|
std::optional<ReadBufferFromFilePRead> cgroupcpu_max TSA_GUARDED_BY(data_mutex);
|
||||||
|
|
||||||
|
std::optional<ReadBufferFromFilePRead> vm_max_map_count TSA_GUARDED_BY(data_mutex);
|
||||||
|
std::optional<ReadBufferFromFilePRead> vm_maps TSA_GUARDED_BY(data_mutex);
|
||||||
|
|
||||||
std::vector<std::unique_ptr<ReadBufferFromFilePRead>> thermal TSA_GUARDED_BY(data_mutex);
|
std::vector<std::unique_ptr<ReadBufferFromFilePRead>> thermal TSA_GUARDED_BY(data_mutex);
|
||||||
|
|
||||||
std::unordered_map<String /* device name */,
|
std::unordered_map<String /* device name */,
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
0
|
||||||
|
0
|
@ -0,0 +1,4 @@
|
|||||||
|
-- Tags: no-replicated-database
|
||||||
|
|
||||||
|
SELECT least(value, 0) FROM system.asynchronous_metrics WHERE metric = 'VMMaxMapCount';
|
||||||
|
SELECT least(value, 0) FROM system.asynchronous_metrics WHERE metric = 'VMNumMaps';
|
Loading…
Reference in New Issue
Block a user