Skip to content

Commit

Permalink
add max to histogram stats
Browse files Browse the repository at this point in the history
Summary:
Domas enlightened me about p100 (i.e., max) stats. Let's add them to our histograms.
Closes #1968

Differential Revision: D4678716

Pulled By: ajkr

fbshipit-source-id: 65e7118
  • Loading branch information
ajkr authored and facebook-github-bot committed Mar 9, 2017
1 parent d43adf2 commit 5b11124
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion db/db_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
3 changes: 3 additions & 0 deletions include/rocksdb/statistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion util/histogram.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
#define __STDC_FORMAT_MACROS
#endif

#include "util/histogram.h"

#include <inttypes.h>
#include <cassert>
#include <math.h>
#include <stdio.h>
#include "util/histogram.h"

#include "port/port.h"

namespace rocksdb {
Expand Down Expand Up @@ -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();
}
Expand Down
11 changes: 4 additions & 7 deletions util/statistics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 5b11124

Please sign in to comment.