diff options
author | zalyalov <zalyalov@yandex-team.com> | 2023-08-14 12:28:20 +0300 |
---|---|---|
committer | zalyalov <zalyalov@yandex-team.com> | 2023-08-14 13:22:19 +0300 |
commit | 9f52205835a5721f3dabb7bc301626fc9aef4f29 (patch) | |
tree | 1e10f5a478fa82f7048792eef565dcb4afe98904 | |
parent | 5cecdd5bd6547b2c61641b48cb54cfc06ebefc64 (diff) | |
download | ydb-9f52205835a5721f3dabb7bc301626fc9aef4f29.tar.gz |
add a histogram sensor for node usages KIKIMR-18705
-rw-r--r-- | ydb/core/mind/hive/hive_impl.cpp | 22 | ||||
-rw-r--r-- | ydb/core/mind/hive/hive_impl.h | 6 | ||||
-rw-r--r-- | ydb/core/protos/counters_hive.proto | 20 |
3 files changed, 38 insertions, 10 deletions
diff --git a/ydb/core/mind/hive/hive_impl.cpp b/ydb/core/mind/hive/hive_impl.cpp index 1fe5feaca1..98f3bada80 100644 --- a/ydb/core/mind/hive/hive_impl.cpp +++ b/ydb/core/mind/hive/hive_impl.cpp @@ -2077,23 +2077,17 @@ void THive::ProcessTabletBalancer() { } THive::THiveStats THive::GetStats() const { - struct TNodeStat { - TNodeId NodeId; - double Usage; - }; - THiveStats stats = {}; - TVector<TNodeStat> values; - values.reserve(Nodes.size()); + stats.Values.reserve(Nodes.size()); for (const auto& ni : Nodes) { if (ni.second.IsAlive() && !ni.second.Down) { - values.push_back({ni.first, ni.second.GetNodeUsage()}); + stats.Values.push_back({ni.first, ni.second.GetNodeUsage()}); } } - if (values.empty()) { + if (stats.Values.empty()) { return stats; } - auto it = std::minmax_element(values.begin(), values.end(), [](const TNodeStat& a, const TNodeStat& b) -> bool { + auto it = std::minmax_element(stats.Values.begin(), stats.Values.end(), [](const THiveStats::TNodeStat& a, const THiveStats::TNodeStat& b) -> bool { return a.Usage < b.Usage; }); stats.MaxUsage = it.second->Usage; @@ -2105,6 +2099,8 @@ THive::THiveStats THive::GetStats() const { double minUsage = std::max(stats.MinUsage, minUsageToBalance); double maxUsage = std::max(stats.MaxUsage, minUsageToBalance); stats.Scatter = (maxUsage - minUsage) / maxUsage; + } else { + stats.Scatter = 0; } return stats; } @@ -2137,6 +2133,12 @@ void THive::Handle(TEvPrivate::TEvProcessTabletBalancer::TPtr&) { TabletCounters->Simple()[NHive::COUNTER_BALANCE_USAGE_MIN].Set(stats.MinUsage * 100); TabletCounters->Simple()[NHive::COUNTER_BALANCE_USAGE_MAX].Set(stats.MaxUsage * 100); + auto& nodeUsageHistogram = TabletCounters->Percentile()[NHive::COUNTER_NODE_USAGE]; + nodeUsageHistogram.Clear(); + for (const auto& record : stats.Values) { + nodeUsageHistogram.IncrementFor(record.Usage * 100); + } + if (stats.MaxUsage >= GetMaxNodeUsageToKick()) { std::vector<TNodeId> overloadedNodes; for (const auto& [nodeId, nodeInfo] : Nodes) { diff --git a/ydb/core/mind/hive/hive_impl.h b/ydb/core/mind/hive/hive_impl.h index 41ac9a7c05..a26b4b9422 100644 --- a/ydb/core/mind/hive/hive_impl.h +++ b/ydb/core/mind/hive/hive_impl.h @@ -846,11 +846,17 @@ protected: double GetUsage() const; struct THiveStats { + struct TNodeStat { + TNodeId NodeId; + double Usage; + }; + double MinUsage; TNodeId MinUsageNodeId; double MaxUsage; TNodeId MaxUsageNodeId; double Scatter; + std::vector<TNodeStat> Values; }; THiveStats GetStats() const; diff --git a/ydb/core/protos/counters_hive.proto b/ydb/core/protos/counters_hive.proto index e62a1c02e7..8c628efe19 100644 --- a/ydb/core/protos/counters_hive.proto +++ b/ydb/core/protos/counters_hive.proto @@ -49,6 +49,26 @@ enum EPercentileCounters { }; COUNTER_PERCENTILE_IGNORE = 0; + + COUNTER_NODE_USAGE = 1 [(CounterOpts) = { + Name: "NodeUsage", + Integral: true, + Ranges: { Value: 30 Name: "30%" }, + Ranges: { Value: 35 Name: "35%" }, + Ranges: { Value: 40 Name: "40%" }, + Ranges: { Value: 45 Name: "45%" }, + Ranges: { Value: 50 Name: "50%" }, + Ranges: { Value: 55 Name: "55%" }, + Ranges: { Value: 60 Name: "60%" }, + Ranges: { Value: 65 Name: "65%" }, + Ranges: { Value: 70 Name: "70%" }, + Ranges: { Value: 75 Name: "75%" }, + Ranges: { Value: 80 Name: "80%" }, + Ranges: { Value: 85 Name: "85%" }, + Ranges: { Value: 90 Name: "90%" }, + Ranges: { Value: 95 Name: "95%" }, + Ranges: { Value: 100 Name: "100%" }, + }]; } enum ETxTypes { |