From 5b11124e39e102da3d7d90d3d6caf93854f81b26 Mon Sep 17 00:00:00 2001 From: Andrew Kryczka Date: Wed, 8 Mar 2017 22:13:15 -0800 Subject: [PATCH] add max to histogram stats Summary: Domas enlightened me about p100 (i.e., max) stats. Let's add them to our histograms. Closes https://github.com/facebook/rocksdb/pull/1968 Differential Revision: D4678716 Pulled By: ajkr fbshipit-source-id: 65e7118 --- db/db_test.cc | 2 +- include/rocksdb/statistics.h | 3 +++ util/histogram.cc | 5 ++++- util/statistics.cc | 11 ++++------- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/db/db_test.cc b/db/db_test.cc index 4f3472d7a..36f57a627 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -2158,7 +2158,7 @@ TEST_F(DBTest, GroupCommitTest) { ASSERT_TRUE(!itr->Valid()); delete itr; - HistogramData hist_data = {0, 0, 0, 0, 0}; + HistogramData hist_data; options.statistics->histogramData(DB_WRITE, &hist_data); ASSERT_GT(hist_data.average, 0.0); } while (ChangeOptions(kSkipNoSeekToLast)); diff --git a/include/rocksdb/statistics.h b/include/rocksdb/statistics.h index a77b9817d..7f343bb23 100644 --- a/include/rocksdb/statistics.h +++ b/include/rocksdb/statistics.h @@ -411,6 +411,9 @@ struct HistogramData { double percentile99; double average; double standard_deviation; + // zero-initialize new members since old Statistics::histogramData() + // implementations won't write them. + double max = 0.0; }; enum StatsLevel { diff --git a/util/histogram.cc b/util/histogram.cc index 87373c588..d81a149ff 100644 --- a/util/histogram.cc +++ b/util/histogram.cc @@ -11,11 +11,13 @@ #define __STDC_FORMAT_MACROS #endif +#include "util/histogram.h" + #include #include #include #include -#include "util/histogram.h" + #include "port/port.h" namespace rocksdb { @@ -233,6 +235,7 @@ void HistogramStat::Data(HistogramData * const data) const { data->median = Median(); data->percentile95 = Percentile(95); data->percentile99 = Percentile(99); + data->max = max(); data->average = Average(); data->standard_deviation = StandardDeviation(); } diff --git a/util/statistics.cc b/util/statistics.cc index 051956839..4d83d4815 100644 --- a/util/statistics.cc +++ b/util/statistics.cc @@ -200,13 +200,10 @@ std::string StatisticsImpl::ToString() const { HistogramData hData; histogramData(h.first, &hData); snprintf( - buffer, - kBufferSize, - "%s statistics Percentiles :=> 50 : %f 95 : %f 99 : %f\n", - h.second.c_str(), - hData.median, - hData.percentile95, - hData.percentile99); + buffer, kBufferSize, + "%s statistics Percentiles :=> 50 : %f 95 : %f 99 : %f 100 : %f\n", + h.second.c_str(), hData.median, hData.percentile95, + hData.percentile99, hData.max); res.append(buffer); } }