enhance: Add mmap file usage metric (#38193)

issue: #38156  Add mmap file usage metric

Signed-off-by: tinswzy <zhenyuan.wei@zilliz.com>
pull/38212/head
tinswzy 2024-12-04 16:12:47 +08:00 committed by GitHub
parent 87aa9a0f2d
commit 262f6db3d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 0 deletions

View File

@ -472,11 +472,13 @@ class SingleChunkColumnBase : public ColumnBase {
mapped_size);
milvus::monitor::internal_mmap_in_used_space_bytes_anon.Increment(
mapped_size);
milvus::monitor::internal_mmap_in_used_count_anon.Increment();
} else if (mapping_type_ == MappingType::MAP_WITH_FILE) {
milvus::monitor::internal_mmap_allocated_space_bytes_file.Observe(
mapped_size);
milvus::monitor::internal_mmap_in_used_space_bytes_file.Increment(
mapped_size);
milvus::monitor::internal_mmap_in_used_count_file.Increment();
}
// else: does not update metric for MAP_WITH_MANAGER, MmapChunkManagerPtr
// will update metric itself.
@ -487,9 +489,11 @@ class SingleChunkColumnBase : public ColumnBase {
if (mapping_type_ == MappingType::MAP_WITH_ANONYMOUS) {
milvus::monitor::internal_mmap_in_used_space_bytes_anon.Decrement(
mapped_size);
milvus::monitor::internal_mmap_in_used_count_anon.Decrement();
} else if (mapping_type_ == MappingType::MAP_WITH_FILE) {
milvus::monitor::internal_mmap_in_used_space_bytes_file.Decrement(
mapped_size);
milvus::monitor::internal_mmap_in_used_count_file.Decrement();
}
// else: does not update metric for MAP_WITH_MANAGER, MmapChunkManagerPtr
// will update metric itself.

View File

@ -201,6 +201,10 @@ std::map<std::string, std::string> mmapAllocatedSpaceAnonLabel = {
{"type", "anon"}};
std::map<std::string, std::string> mmapAllocatedSpaceFileLabel = {
{"type", "file"}};
std::map<std::string, std::string> mmapAllocatedCountAnonLabel = {
{"type", "anon"}};
std::map<std::string, std::string> mmapAllocatedCountFileLabel = {
{"type", "file"}};
DEFINE_PROMETHEUS_HISTOGRAM_FAMILY(internal_mmap_allocated_space_bytes,
"[cpp]mmap allocated space stats")
@ -223,4 +227,12 @@ DEFINE_PROMETHEUS_GAUGE(internal_mmap_in_used_space_bytes_anon,
DEFINE_PROMETHEUS_GAUGE(internal_mmap_in_used_space_bytes_file,
internal_mmap_in_used_space_bytes,
mmapAllocatedSpaceFileLabel)
DEFINE_PROMETHEUS_GAUGE_FAMILY(internal_mmap_in_used_count,
"[cpp]mmap in used count stats")
DEFINE_PROMETHEUS_GAUGE(internal_mmap_in_used_count_anon,
internal_mmap_in_used_count,
mmapAllocatedCountAnonLabel)
DEFINE_PROMETHEUS_GAUGE(internal_mmap_in_used_count_file,
internal_mmap_in_used_count,
mmapAllocatedCountFileLabel)
} // namespace milvus::monitor

View File

@ -127,6 +127,9 @@ DECLARE_PROMETHEUS_HISTOGRAM(internal_mmap_allocated_space_bytes_file);
DECLARE_PROMETHEUS_GAUGE_FAMILY(internal_mmap_in_used_space_bytes);
DECLARE_PROMETHEUS_GAUGE(internal_mmap_in_used_space_bytes_anon);
DECLARE_PROMETHEUS_GAUGE(internal_mmap_in_used_space_bytes_file);
DECLARE_PROMETHEUS_GAUGE_FAMILY(internal_mmap_in_used_count);
DECLARE_PROMETHEUS_GAUGE(internal_mmap_in_used_count_anon);
DECLARE_PROMETHEUS_GAUGE(internal_mmap_in_used_count_file);
// search metrics
DECLARE_PROMETHEUS_HISTOGRAM_FAMILY(internal_core_search_latency);

View File

@ -73,6 +73,7 @@ MmapBlock::Init() {
file_size_);
milvus::monitor::internal_mmap_in_used_space_bytes_file.Increment(
file_size_);
milvus::monitor::internal_mmap_in_used_count_file.Increment();
is_valid_ = true;
allocated_size_.fetch_add(file_size_);
}
@ -98,6 +99,7 @@ MmapBlock::Close() {
allocated_size_.fetch_sub(file_size_);
milvus::monitor::internal_mmap_in_used_space_bytes_file.Decrement(
file_size_);
milvus::monitor::internal_mmap_in_used_count_file.Decrement();
is_valid_ = false;
}