diff options
author | ignatloskutov <ignatloskutov@yandex-team.com> | 2024-10-07 15:08:57 +0300 |
---|---|---|
committer | ignatloskutov <ignatloskutov@yandex-team.com> | 2024-10-07 15:20:18 +0300 |
commit | c34ff415b4a1bf62ccc797637adcb0ac6f79d9aa (patch) | |
tree | 8f62f755762badced463d51f8fd18257ba4863e7 | |
parent | 1c323ac18fd708a89bce629a46b8f8956cab7eb3 (diff) | |
download | ydb-c34ff415b4a1bf62ccc797637adcb0ac6f79d9aa.tar.gz |
Store 64-bit counters for histogram buckets
* Changelog entry
Type: fix
Component: misc-server
Store 64-bit counters for histogram buckets
commit_hash:b183820320312db88fe17ebfb63310d69c0ef767
-rw-r--r-- | yt/yt/library/profiling/histogram_snapshot.h | 2 | ||||
-rw-r--r-- | yt/yt/library/profiling/solomon/cube.cpp | 12 | ||||
-rw-r--r-- | yt/yt/library/profiling/solomon/sensor.h | 2 | ||||
-rw-r--r-- | yt/yt/library/profiling/unittests/solomon_ut.cpp | 16 |
4 files changed, 24 insertions, 8 deletions
diff --git a/yt/yt/library/profiling/histogram_snapshot.h b/yt/yt/library/profiling/histogram_snapshot.h index 8fd0296942..0724c9f8d6 100644 --- a/yt/yt/library/profiling/histogram_snapshot.h +++ b/yt/yt/library/profiling/histogram_snapshot.h @@ -11,7 +11,7 @@ namespace NYT::NProfiling { struct THistogramSnapshot { // When Values.size() == Bounds.size() + 1, Values.back() stores "Inf" bucket. - std::vector<int> Values; + std::vector<i64> Values; std::vector<double> Bounds; THistogramSnapshot& operator += (const THistogramSnapshot& other); diff --git a/yt/yt/library/profiling/solomon/cube.cpp b/yt/yt/library/profiling/solomon/cube.cpp index 2dc4d93438..93b54496b2 100644 --- a/yt/yt/library/profiling/solomon/cube.cpp +++ b/yt/yt/library/profiling/solomon/cube.cpp @@ -514,7 +514,7 @@ int TCube<T>::ReadSensors( } for (size_t i = 0; i < n; ++i) { - int bucketValue = i < value.Values.size() ? value.Values[i] : 0u; + auto bucketValue = i < value.Values.size() ? value.Values[i] : 0u; (*hist)[i] = {value.Bounds[i], bucketValue / options.RateDenominator}; } @@ -525,7 +525,7 @@ int TCube<T>::ReadSensors( auto rollup = Rollup(*window, indices.back()); for (size_t i = 0; i < n; ++i) { - int bucketValue = i < rollup.Values.size() ? rollup.Values[i] : 0u; + auto bucketValue = i < rollup.Values.size() ? rollup.Values[i] : 0u; (*hist)[i] = {rollup.Bounds[i], bucketValue}; } @@ -549,7 +549,7 @@ int TCube<T>::ReadSensors( auto hist = NMonitoring::TExplicitHistogramSnapshot::New(n + 1); for (size_t i = 0; i < n; ++i) { - int bucketValue = i < value.Values.size() ? value.Values[i] : 0u; + auto bucketValue = i < value.Values.size() ? value.Values[i] : 0u; (*hist)[i] = {value.Bounds[i], bucketValue}; } @@ -576,7 +576,7 @@ int TCube<T>::ReadSensors( } for (size_t i = 0; i < n; ++i) { - int bucketValue = i < value.Values.size() ? value.Values[i] : 0u; + auto bucketValue = i < value.Values.size() ? value.Values[i] : 0u; (*hist)[i] = {value.Bounds[i], bucketValue / options.RateDenominator}; } @@ -669,11 +669,11 @@ int TCube<T>::ReadSensorValues( } ++valuesRead; } else if constexpr (std::is_same_v<T, TTimeHistogramSnapshot> || std::is_same_v<T, TGaugeHistogramSnapshot> || std::is_same_v<T, TRateHistogramSnapshot>) { - std::vector<std::pair<double, int>> hist; + std::vector<std::pair<double, i64>> hist; size_t n = value.Bounds.size(); hist.reserve(n + 1); for (size_t i = 0; i != n; ++i) { - int bucketValue = i < value.Values.size() ? value.Values[i] : 0; + auto bucketValue = i < value.Values.size() ? value.Values[i] : 0; hist.emplace_back(value.Bounds[i], bucketValue); } hist.emplace_back(Max<double>(), n < value.Values.size() ? value.Values[n] : 0u); diff --git a/yt/yt/library/profiling/solomon/sensor.h b/yt/yt/library/profiling/solomon/sensor.h index c81055ea14..391a9dbc59 100644 --- a/yt/yt/library/profiling/solomon/sensor.h +++ b/yt/yt/library/profiling/solomon/sensor.h @@ -121,7 +121,7 @@ public: private: std::vector<double> Bounds_; - std::vector<std::atomic<int>> Buckets_; + std::vector<std::atomic<i64>> Buckets_; // These two methods are not used. TSummarySnapshot<TDuration> GetSummary() override; diff --git a/yt/yt/library/profiling/unittests/solomon_ut.cpp b/yt/yt/library/profiling/unittests/solomon_ut.cpp index 62b871646a..c26d478234 100644 --- a/yt/yt/library/profiling/unittests/solomon_ut.cpp +++ b/yt/yt/library/profiling/unittests/solomon_ut.cpp @@ -371,6 +371,22 @@ TEST(TSolomonRegistry, SparseHistogram) CollectSensors(impl, 3); } +TEST(TSolomonRegistry, HistogramWithBigCounterValues) +{ + auto impl = New<TSolomonRegistry>(); + TProfiler profiler(impl, "/d"); + + auto h0 = profiler.GaugeHistogram("/histogram", {1.0}); + + h0.Add(0, 2e9); + h0.Add(0, 2e9); + + auto result = h0.GetSnapshot().Values; + + ASSERT_FALSE(result.empty()); + ASSERT_EQ(result.front(), 4e9); +} + TEST(TSolomonRegistry, SparseCounters) { auto impl = New<TSolomonRegistry>(); |