Skip to content

Commit

Permalink
Merge pull request #32811 from vespa-engine/toregge/move-disk-usage-m…
Browse files Browse the repository at this point in the history
…etrics-into-index-metrics-entry-as-disk-io-metrics

Move DiskUsageMetrics to IndexMetricsEntry::DiskIoMetrics.
  • Loading branch information
geirst authored Nov 8, 2024
2 parents 597f917 + af9174a commit 6079d3c
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ vespa_add_library(searchcore_proton_metrics STATIC
attribute_metrics_entry.cpp
cache_metrics.cpp
content_proton_metrics.cpp
disk_usage_metrics.cpp
documentdb_job_trackers.cpp
documentdb_tagged_metrics.cpp
document_db_commit_metrics.cpp
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ namespace proton {

FieldMetricsEntry::FieldMetricsEntry(const std::string& name, const std::string& field_name, const std::string& description)
: metrics::MetricSet(name, {{"field", field_name}}, description, nullptr),
memoryUsage(this)
memoryUsage(this),
size_on_disk("size_on_disk", {}, "Size on disk (bytes)", this)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace proton {
* Class containing metrics for an aspect (attribute or index) of a field.
*/
struct FieldMetricsEntry : public metrics::MetricSet {
MemoryUsageMetrics memoryUsage;
MemoryUsageMetrics memoryUsage;
metrics::LongValueMetric size_on_disk;
FieldMetricsEntry(const std::string& name, const std::string& field_name, const std::string& description);
~FieldMetricsEntry() override;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,47 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "index_metrics_entry.h"
#include <vespa/searchlib/util/disk_io_stats.h>

using search::DiskIoStats;

namespace proton {

namespace {

const std::string entry_name("index_field");
const std::string entry_name("index");
const std::string entry_description("Metrics for indexes for a given field");

}

IndexMetricsEntry::DiskIoMetrics::SearchMetrics::SearchMetrics(metrics::MetricSet* parent)
: MetricSet("search", {}, "The search io for a given component", parent),
_read_bytes("read_bytes", {}, "Bytes read in posting list files as part of search", this)
{
}

IndexMetricsEntry::DiskIoMetrics::SearchMetrics::~SearchMetrics() = default;

void
IndexMetricsEntry::DiskIoMetrics::SearchMetrics::update(const DiskIoStats& disk_io_stats)
{
_read_bytes.addTotalValueBatch(disk_io_stats.read_bytes_total(),
disk_io_stats.read_operations(),
disk_io_stats.read_bytes_min(),
disk_io_stats.read_bytes_max());
}

IndexMetricsEntry::DiskIoMetrics::DiskIoMetrics(metrics::MetricSet* parent)
: MetricSet("io", {}, "The disk usage for a given component", parent),
_search(this)
{
}

IndexMetricsEntry::DiskIoMetrics::~DiskIoMetrics() = default;

IndexMetricsEntry::IndexMetricsEntry(const std::string& field_name)
: FieldMetricsEntry(entry_name, field_name, entry_description),
_disk_usage(this)
_disk_io(this)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,40 @@

#pragma once

#include "disk_usage_metrics.h"
#include "field_metrics_entry.h"

namespace search { class DiskIoStats; }

namespace proton {

/*
* Class containing metrics for the index aspect of a field, i.e.
* disk indexes and memory indexes.
*/
struct IndexMetricsEntry : public FieldMetricsEntry {
DiskUsageMetrics _disk_usage;
class IndexMetricsEntry : public FieldMetricsEntry {
class DiskIoMetrics : public metrics::MetricSet {
class SearchMetrics : public metrics::MetricSet {
metrics::LongValueMetric _read_bytes;
public:
explicit SearchMetrics(metrics::MetricSet* parent);
~SearchMetrics() override;
void update(const search::DiskIoStats& disk_io_stats);
};

SearchMetrics _search;

public:
explicit DiskIoMetrics(metrics::MetricSet* parent);
~DiskIoMetrics() override;
void update(const search::DiskIoStats& disk_io_stats) { _search.update(disk_io_stats); }
};

DiskIoMetrics _disk_io;

IndexMetricsEntry(const std::string& field_name);
public:
explicit IndexMetricsEntry(const std::string& field_name);
~IndexMetricsEntry() override;
void update_disk_io(const search::DiskIoStats& disk_io_stats) { _disk_io.update(disk_io_stats); }
};

} // namespace proton
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ updateIndexMetrics(DocumentDBTaggedMetrics &metrics, const search::SearchableSta
auto entry = field_metrics.get_field_metrics_entry(field.first);
if (entry) {
entry->memoryUsage.update(field.second.memory_usage());
entry->_disk_usage.update(field.second.size_on_disk(), field.second.disk_io_stats());
entry->size_on_disk.set(field.second.size_on_disk());
entry->update_disk_io(field.second.disk_io_stats());
}
}
}
Expand Down

0 comments on commit 6079d3c

Please sign in to comment.