summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorGeir Storli <geirst@yahooinc.com>2022-01-25 13:51:23 +0100
committerGitHub <noreply@github.com>2022-01-25 13:51:23 +0100
commitb204e44404142250b79be20c492951de1287609d (patch)
tree68a2d1248a1c08125cc1b40945495b33764d1504 /searchcore
parent0dcd724d233f3833180030907e969007a81a9682 (diff)
parent949932e310963df295c27af0dc62b77d4625288a (diff)
Merge pull request #20915 from vespa-engine/havardpe/proton-cpu-util-metrics
added cpu util metrics
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/proton/metrics/resource_usage_metrics.cpp15
-rw-r--r--searchcore/src/vespa/searchcore/proton/metrics/resource_usage_metrics.h12
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/proton.cpp8
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/proton.h2
4 files changed, 36 insertions, 1 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/metrics/resource_usage_metrics.cpp b/searchcore/src/vespa/searchcore/proton/metrics/resource_usage_metrics.cpp
index 9bc20f95d13..9cf0339986c 100644
--- a/searchcore/src/vespa/searchcore/proton/metrics/resource_usage_metrics.cpp
+++ b/searchcore/src/vespa/searchcore/proton/metrics/resource_usage_metrics.cpp
@@ -4,6 +4,18 @@
namespace proton {
+ResourceUsageMetrics::CpuUtilMetrics::CpuUtilMetrics(metrics::MetricSet *parent)
+ : MetricSet("cpu_util", {}, "Unnormalized cpu utilization for various categories", parent),
+ setup("setup", {}, "cpu used by system init and (re-)configuration", this),
+ read("read", {}, "cpu used by reading data from the system", this),
+ write("write", {}, "cpu used by writing data to the system", this),
+ compact("compact", {}, "cpu used by internal data re-structuring", this),
+ other("other", {}, "cpu used by work not classified as a specific category", this)
+{
+}
+
+ResourceUsageMetrics::CpuUtilMetrics::~CpuUtilMetrics() = default;
+
ResourceUsageMetrics::ResourceUsageMetrics(metrics::MetricSet *parent)
: MetricSet("resource_usage", {}, "Usage metrics for various resources in this search engine", parent),
disk("disk", {}, "The relative amount of disk space used on this machine (value in the range [0, 1])", this),
@@ -15,7 +27,8 @@ ResourceUsageMetrics::ResourceUsageMetrics(metrics::MetricSet *parent)
memoryMappings("memory_mappings", {}, "The number of mapped memory areas", this),
openFileDescriptors("open_file_descriptors", {}, "The number of open files", this),
feedingBlocked("feeding_blocked", {}, "Whether feeding is blocked due to resource limits being reached (value is either 0 or 1)", this),
- mallocArena("malloc_arena", {}, "Size of malloc arena", this)
+ mallocArena("malloc_arena", {}, "Size of malloc arena", this),
+ cpu_util(this)
{
}
diff --git a/searchcore/src/vespa/searchcore/proton/metrics/resource_usage_metrics.h b/searchcore/src/vespa/searchcore/proton/metrics/resource_usage_metrics.h
index 774bb645c84..35100084cf7 100644
--- a/searchcore/src/vespa/searchcore/proton/metrics/resource_usage_metrics.h
+++ b/searchcore/src/vespa/searchcore/proton/metrics/resource_usage_metrics.h
@@ -12,6 +12,17 @@ namespace proton {
*/
struct ResourceUsageMetrics : metrics::MetricSet
{
+ struct CpuUtilMetrics : metrics::MetricSet {
+ metrics::DoubleValueMetric setup;
+ metrics::DoubleValueMetric read;
+ metrics::DoubleValueMetric write;
+ metrics::DoubleValueMetric compact;
+ metrics::DoubleValueMetric other;
+
+ CpuUtilMetrics(metrics::MetricSet *parent);
+ ~CpuUtilMetrics();
+ };
+
metrics::DoubleValueMetric disk;
metrics::DoubleValueMetric diskUtilization;
metrics::DoubleValueMetric memory;
@@ -22,6 +33,7 @@ struct ResourceUsageMetrics : metrics::MetricSet
metrics::LongValueMetric openFileDescriptors;
metrics::LongValueMetric feedingBlocked;
metrics::LongValueMetric mallocArena;
+ CpuUtilMetrics cpu_util;
ResourceUsageMetrics(metrics::MetricSet *parent);
~ResourceUsageMetrics();
diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp
index b128fe16e5e..b2a86102cd1 100644
--- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp
@@ -61,6 +61,7 @@ using vespalib::Slime;
using vespalib::makeLambdaTask;
using vespalib::slime::ArrayInserter;
using vespalib::slime::Cursor;
+using CpuCategory = vespalib::CpuUsage::Category;
using search::transactionlog::DomainStats;
using vespa::config::search::core::ProtonConfig;
@@ -207,6 +208,7 @@ Proton::Proton(const config::ConfigUri & configUri,
StatusProducer(),
IPersistenceEngineOwner(),
ComponentConfigProducer(),
+ _cpu_util(),
_configUri(configUri),
_mutex(),
_metricsHook(std::make_unique<MetricsUpdateHook>(*this)),
@@ -775,6 +777,12 @@ Proton::updateMetrics(const metrics::MetricLockGuard &)
#else
metrics.resourceUsage.mallocArena.set(UINT64_C(0));
#endif
+ auto cpu_util = _cpu_util.get_util();
+ metrics.resourceUsage.cpu_util.setup.set(cpu_util[CpuCategory::SETUP]);
+ metrics.resourceUsage.cpu_util.read.set(cpu_util[CpuCategory::READ]);
+ metrics.resourceUsage.cpu_util.write.set(cpu_util[CpuCategory::WRITE]);
+ metrics.resourceUsage.cpu_util.compact.set(cpu_util[CpuCategory::COMPACT]);
+ metrics.resourceUsage.cpu_util.other.set(cpu_util[CpuCategory::OTHER]);
}
{
ContentProtonMetrics::ProtonExecutorMetrics &metrics = _metricsEngine->root().executor;
diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.h b/searchcore/src/vespa/searchcore/proton/server/proton.h
index 573f215c722..90a257a0aaa 100644
--- a/searchcore/src/vespa/searchcore/proton/server/proton.h
+++ b/searchcore/src/vespa/searchcore/proton/server/proton.h
@@ -25,6 +25,7 @@
#include <vespa/vespalib/net/json_handler_repo.h>
#include <vespa/vespalib/net/state_explorer.h>
#include <vespa/vespalib/util/varholder.h>
+#include <vespa/vespalib/util/cpu_usage.h>
#include <mutex>
#include <shared_mutex>
@@ -81,6 +82,7 @@ private:
void setClusterName(const vespalib::string &clusterName, const vespalib::string &baseDir);
};
+ vespalib::CpuUtil _cpu_util;
const config::ConfigUri _configUri;
mutable std::shared_mutex _mutex;
std::unique_ptr<metrics::UpdateHook> _metricsHook;