Skip to content

Commit

Permalink
Add mmap file usage metric
Browse files Browse the repository at this point in the history
Signed-off-by: tinswzy <[email protected]>
  • Loading branch information
tinswzy committed Dec 4, 2024
1 parent d822edb commit 96a7e11
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/core/src/mmap/Column.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions internal/core/src/monitor/prometheus_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
3 changes: 3 additions & 0 deletions internal/core/src/monitor/prometheus_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions internal/core/src/storage/MmapChunkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
}
Expand All @@ -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;
}

Expand Down

0 comments on commit 96a7e11

Please sign in to comment.