diff --git a/db/db_test.cc b/db/db_test.cc index 4f3472d7a76..36f57a6279c 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 a77b9817d22..7f343bb2392 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 87373c588dd..d81a149ffd3 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 051956839b0..4d83d481563 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); } }