Skip to content

Commit a17d619

Browse files
craig[bot]ajkr
andcommitted
Merge #36196
36196: storage: debug page for RocksDB tickers/histograms r=tbg a=ajkr Set up a debug page at "/_status/enginestats/<node_id>" that contains values of all RocksDB ticker stats and histograms. It is also included in debug zip. A portion of the debug page (including both tickers and histograms) looks like this: ![tickershistograms](https://user-images.githubusercontent.com/4780362/55138005-aa88ab00-50ef-11e9-83d6-cc335cc10e6e.png) The debug zip file contains a JSON file named "debug/nodes/<node_id>/enginestats" with all the tickers/histograms, and looks like this: ``` { "stats": [ { "storeId": 1, "tickersAndHistograms": { "tickers": { "rocksdb.blobdb.blob.file.bytes.read": "0", ... "rocksdb.write.wal": "296" }, "histograms": { "rocksdb.blobdb.blob.file.read.micros": { "mean": 0, "p50": 0, "p95": 0, "p99": 0, "max": 0, "count": "0", "sum": "0" }, ... "rocksdb.write.raw.block.micros": { "mean": 1.8235294117647058, "p50": 0.6071428571428571, "p95": 10.749999999999993, "p99": 12, "max": 12, "count": "17", "sum": "31" } } } } ] } ``` Release Note: None Co-authored-by: Andrew Kryczka <andrew.kryczka2@gmail.com>
2 parents 2851c7d + 166015e commit a17d619

File tree

21 files changed

+3413
-533
lines changed

21 files changed

+3413
-533
lines changed

c-deps/libroach/batch.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,8 @@ DBIterator* DBBatch::NewIter(DBIterOptions iter_options) {
557557

558558
DBStatus DBBatch::GetStats(DBStatsResult* stats) { return FmtStatus("unsupported"); }
559559

560+
DBStatus DBBatch::GetTickersAndHistograms(DBTickersAndHistogramsResult* stats) { return FmtStatus("unsupported"); }
561+
560562
DBString DBBatch::GetCompactionStats() { return ToDBString("unsupported"); }
561563

562564
DBStatus DBBatch::GetEnvStats(DBEnvStatsResult* stats) { return FmtStatus("unsupported"); }
@@ -654,6 +656,8 @@ DBIterator* DBWriteOnlyBatch::NewIter(DBIterOptions) { return NULL; }
654656

655657
DBStatus DBWriteOnlyBatch::GetStats(DBStatsResult* stats) { return FmtStatus("unsupported"); }
656658

659+
DBStatus DBWriteOnlyBatch::GetTickersAndHistograms(DBTickersAndHistogramsResult* stats) { return FmtStatus("unsupported"); }
660+
657661
DBString DBWriteOnlyBatch::GetCompactionStats() { return ToDBString("unsupported"); }
658662

659663
DBStatus DBWriteOnlyBatch::GetEnvStats(DBEnvStatsResult* stats) { return FmtStatus("unsupported"); }

c-deps/libroach/batch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ struct DBBatch : public DBEngine {
4040
virtual DBStatus Get(DBKey key, DBString* value);
4141
virtual DBIterator* NewIter(DBIterOptions);
4242
virtual DBStatus GetStats(DBStatsResult* stats);
43+
virtual DBStatus GetTickersAndHistograms(DBTickersAndHistogramsResult* stats);
4344
virtual DBString GetCompactionStats();
4445
virtual DBStatus GetEnvStats(DBEnvStatsResult* stats);
4546
virtual DBStatus GetEncryptionRegistries(DBEncryptionRegistries* result);
@@ -72,6 +73,7 @@ struct DBWriteOnlyBatch : public DBEngine {
7273
virtual DBStatus Get(DBKey key, DBString* value);
7374
virtual DBIterator* NewIter(DBIterOptions);
7475
virtual DBStatus GetStats(DBStatsResult* stats);
76+
virtual DBStatus GetTickersAndHistograms(DBTickersAndHistogramsResult* stats);
7577
virtual DBString GetCompactionStats();
7678
virtual DBString GetEnvStats(DBEnvStatsResult* stats);
7779
virtual DBStatus GetEncryptionRegistries(DBEncryptionRegistries* result);

c-deps/libroach/db.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,17 @@ DBStatus DBPartialMergeOne(DBSlice existing, DBSlice update, DBString* new_value
658658
// write them to the provided DBStatsResult instance.
659659
DBStatus DBGetStats(DBEngine* db, DBStatsResult* stats) { return db->GetStats(stats); }
660660

661+
// `DBGetTickersAndHistograms` retrieves maps of all RocksDB tickers and histograms.
662+
// It differs from `DBGetStats` by getting _every_ ticker and histogram, and by not
663+
// getting anything else (DB properties, for example).
664+
//
665+
// In addition to freeing the `DBString`s in the result, the caller is also
666+
// responsible for freeing `DBTickersAndHistogramsResult::tickers` and
667+
// `DBTickersAndHistogramsResult::histograms`.
668+
DBStatus DBGetTickersAndHistograms(DBEngine* db, DBTickersAndHistogramsResult* stats) {
669+
return db->GetTickersAndHistograms(stats);
670+
}
671+
661672
DBString DBGetCompactionStats(DBEngine* db) { return db->GetCompactionStats(); }
662673

663674
DBStatus DBGetEnvStats(DBEngine* db, DBEnvStatsResult* stats) { return db->GetEnvStats(stats); }

c-deps/libroach/engine.cc

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,50 @@ DBStatus DBImpl::GetStats(DBStatsResult* stats) {
219219
return kSuccess;
220220
}
221221

222+
// `GetTickersAndHistograms` retrieves maps of all RocksDB tickers and histograms.
223+
// It differs from `GetStats` by getting _every_ ticker and histogram, and by not
224+
// getting anything else (DB properties, for example).
225+
//
226+
// In addition to freeing the `DBString`s in the result, the caller is also
227+
// responsible for freeing `DBTickersAndHistogramsResult::tickers` and
228+
// `DBTickersAndHistogramsResult::histograms`.
229+
DBStatus DBImpl::GetTickersAndHistograms(DBTickersAndHistogramsResult* stats) {
230+
const rocksdb::Options& opts = rep->GetOptions();
231+
const std::shared_ptr<rocksdb::Statistics>& s = opts.statistics;
232+
stats->tickers_len = rocksdb::TickersNameMap.size();
233+
// We malloc the result so it can be deallocated by the caller using free().
234+
stats->tickers = static_cast<TickerInfo*>(
235+
malloc(stats->tickers_len * sizeof(TickerInfo)));
236+
if (stats->tickers == nullptr) {
237+
return FmtStatus("malloc failed");
238+
}
239+
for (size_t i = 0; i < stats->tickers_len; ++i) {
240+
stats->tickers[i].name = ToDBString(rocksdb::TickersNameMap[i].second);
241+
stats->tickers[i].value = s->getTickerCount(static_cast<uint32_t>(i));
242+
}
243+
244+
stats->histograms_len = rocksdb::HistogramsNameMap.size();
245+
// We malloc the result so it can be deallocated by the caller using free().
246+
stats->histograms = static_cast<HistogramInfo*>(
247+
malloc(stats->histograms_len * sizeof(HistogramInfo)));
248+
if (stats->histograms == nullptr) {
249+
return FmtStatus("malloc failed");
250+
}
251+
for (size_t i = 0; i < stats->histograms_len; ++i) {
252+
stats->histograms[i].name = ToDBString(rocksdb::HistogramsNameMap[i].second);
253+
rocksdb::HistogramData data;
254+
s->histogramData(static_cast<uint32_t>(i), &data);
255+
stats->histograms[i].mean = data.average;
256+
stats->histograms[i].p50 = data.median;
257+
stats->histograms[i].p95 = data.percentile95;
258+
stats->histograms[i].p99 = data.percentile99;
259+
stats->histograms[i].max = data.max;
260+
stats->histograms[i].count = data.count;
261+
stats->histograms[i].sum = data.sum;
262+
}
263+
return kSuccess;
264+
}
265+
222266
DBString DBImpl::GetCompactionStats() {
223267
std::string tmp;
224268
rep->GetProperty("rocksdb.cfstats-no-file-histogram", &tmp);

c-deps/libroach/engine.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ struct DBEngine {
4141
virtual DBStatus Get(DBKey key, DBString* value) = 0;
4242
virtual DBIterator* NewIter(DBIterOptions) = 0;
4343
virtual DBStatus GetStats(DBStatsResult* stats) = 0;
44+
virtual DBStatus GetTickersAndHistograms(DBTickersAndHistogramsResult* stats) = 0;
4445
virtual DBString GetCompactionStats() = 0;
4546
virtual DBString GetEnvStats(DBEnvStatsResult* stats) = 0;
4647
virtual DBStatus GetEncryptionRegistries(DBEncryptionRegistries* result) = 0;
@@ -89,6 +90,7 @@ struct DBImpl : public DBEngine {
8990
virtual DBStatus Get(DBKey key, DBString* value);
9091
virtual DBIterator* NewIter(DBIterOptions);
9192
virtual DBStatus GetStats(DBStatsResult* stats);
93+
virtual DBStatus GetTickersAndHistograms(DBTickersAndHistogramsResult* stats);
9294
virtual DBString GetCompactionStats();
9395
virtual DBStatus GetEnvStats(DBEnvStatsResult* stats);
9496
virtual DBStatus GetEncryptionRegistries(DBEncryptionRegistries* result);

c-deps/libroach/include/libroach.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,29 @@ typedef struct {
350350
int64_t pending_compaction_bytes_estimate;
351351
} DBStatsResult;
352352

353+
typedef struct {
354+
DBString name;
355+
uint64_t value;
356+
} TickerInfo;
357+
358+
typedef struct {
359+
DBString name;
360+
double mean;
361+
double p50;
362+
double p95;
363+
double p99;
364+
double max;
365+
uint64_t count;
366+
uint64_t sum;
367+
} HistogramInfo;
368+
369+
typedef struct {
370+
TickerInfo* tickers;
371+
size_t tickers_len;
372+
HistogramInfo* histograms;
373+
size_t histograms_len;
374+
} DBTickersAndHistogramsResult;
375+
353376
// DBEnvStatsResult contains Env stats (filesystem layer).
354377
typedef struct {
355378
// Basic file encryption stats:
@@ -375,6 +398,7 @@ typedef struct {
375398
} DBEncryptionRegistries;
376399

377400
DBStatus DBGetStats(DBEngine* db, DBStatsResult* stats);
401+
DBStatus DBGetTickersAndHistograms(DBEngine* db, DBTickersAndHistogramsResult* stats);
378402
DBString DBGetCompactionStats(DBEngine* db);
379403
DBStatus DBGetEnvStats(DBEngine* db, DBEnvStatsResult* stats);
380404
DBStatus DBGetEncryptionRegistries(DBEngine* db, DBEncryptionRegistries* result);

0 commit comments

Comments
 (0)