1
0
Fork 0

Bugfix: Correct rocksdb statistics to report column family sums. (#9705)

* Update rocksdb statistics to properly report sums from column families.  Add throttle statistic.

* add cstddef include to allow clean compile with gcc 6.3.0 20170516
This commit is contained in:
Matthew Von-Maszewski 2019-08-13 14:35:09 -04:00 committed by GitHub
parent 6b3e11dd40
commit 77fb9df2c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 21 deletions

View File

@ -24,6 +24,7 @@
#ifndef ARANGOD_AQL_SHORT_STRING_STORAGE_H
#define ARANGOD_AQL_SHORT_STRING_STORAGE_H 1
#include <cstddef>
#include <vector>
#include "Basics/Common.h"

View File

@ -2142,6 +2142,23 @@ void RocksDBEngine::getStatistics(VPackBuilder& builder) const {
}
};
// get string property from each column family and return sum;
auto addIntAllCf = [&](std::string const& s) {
int64_t sum = 0;
for (auto cfh : RocksDBColumnFamily::_allHandles) {
std::string v;
if (_db->GetProperty(cfh, s, &v)) {
int64_t temp=basics::StringUtils::int64(v);
// -1 returned for somethings that are valid property but no value
if (0 < temp) {
sum += temp;
} // if
} // if
} // for
builder.add(s, VPackValue(sum));
};
// add column family properties
auto addCf = [&](std::string const& name, rocksdb::ColumnFamilyHandle* c) {
std::string v;
@ -2169,40 +2186,43 @@ void RocksDBEngine::getStatistics(VPackBuilder& builder) const {
builder.openObject();
for (int i = 0; i < _options.num_levels; ++i) {
addStr(rocksdb::DB::Properties::kNumFilesAtLevelPrefix + std::to_string(i));
addStr(rocksdb::DB::Properties::kCompressionRatioAtLevelPrefix + std::to_string(i));
addIntAllCf(rocksdb::DB::Properties::kNumFilesAtLevelPrefix + std::to_string(i));
// ratio needs new calculation with all cf, not a simple add operation
addIntAllCf(rocksdb::DB::Properties::kCompressionRatioAtLevelPrefix + std::to_string(i));
}
addInt(rocksdb::DB::Properties::kNumImmutableMemTable);
addInt(rocksdb::DB::Properties::kNumImmutableMemTableFlushed);
addInt(rocksdb::DB::Properties::kMemTableFlushPending);
addInt(rocksdb::DB::Properties::kCompactionPending);
// caution: you must read rocksdb/db/interal_stats.cc carefully to
// determine if a property is for whole database or one column family
addIntAllCf(rocksdb::DB::Properties::kNumImmutableMemTable);
addIntAllCf(rocksdb::DB::Properties::kNumImmutableMemTableFlushed);
addIntAllCf(rocksdb::DB::Properties::kMemTableFlushPending);
addIntAllCf(rocksdb::DB::Properties::kCompactionPending);
addInt(rocksdb::DB::Properties::kBackgroundErrors);
addInt(rocksdb::DB::Properties::kCurSizeActiveMemTable);
addInt(rocksdb::DB::Properties::kCurSizeAllMemTables);
addInt(rocksdb::DB::Properties::kSizeAllMemTables);
addInt(rocksdb::DB::Properties::kNumEntriesActiveMemTable);
addInt(rocksdb::DB::Properties::kNumEntriesImmMemTables);
addInt(rocksdb::DB::Properties::kNumDeletesActiveMemTable);
addInt(rocksdb::DB::Properties::kNumDeletesImmMemTables);
addInt(rocksdb::DB::Properties::kEstimateNumKeys);
addInt(rocksdb::DB::Properties::kEstimateTableReadersMem);
addIntAllCf(rocksdb::DB::Properties::kCurSizeActiveMemTable);
addIntAllCf(rocksdb::DB::Properties::kCurSizeAllMemTables);
addIntAllCf(rocksdb::DB::Properties::kSizeAllMemTables);
addIntAllCf(rocksdb::DB::Properties::kNumEntriesActiveMemTable);
addIntAllCf(rocksdb::DB::Properties::kNumEntriesImmMemTables);
addIntAllCf(rocksdb::DB::Properties::kNumDeletesActiveMemTable);
addIntAllCf(rocksdb::DB::Properties::kNumDeletesImmMemTables);
addIntAllCf(rocksdb::DB::Properties::kEstimateNumKeys);
addIntAllCf(rocksdb::DB::Properties::kEstimateTableReadersMem);
addInt(rocksdb::DB::Properties::kNumSnapshots);
addInt(rocksdb::DB::Properties::kOldestSnapshotTime);
addInt(rocksdb::DB::Properties::kNumLiveVersions);
addIntAllCf(rocksdb::DB::Properties::kNumLiveVersions);
addInt(rocksdb::DB::Properties::kMinLogNumberToKeep);
addInt(rocksdb::DB::Properties::kEstimateLiveDataSize);
addInt(rocksdb::DB::Properties::kLiveSstFilesSize);
addIntAllCf(rocksdb::DB::Properties::kEstimateLiveDataSize);
addIntAllCf(rocksdb::DB::Properties::kLiveSstFilesSize);
addStr(rocksdb::DB::Properties::kDBStats);
addStr(rocksdb::DB::Properties::kSSTables);
addInt(rocksdb::DB::Properties::kNumRunningCompactions);
addInt(rocksdb::DB::Properties::kNumRunningFlushes);
addInt(rocksdb::DB::Properties::kIsFileDeletionsEnabled);
addInt(rocksdb::DB::Properties::kEstimatePendingCompactionBytes);
addIntAllCf(rocksdb::DB::Properties::kEstimatePendingCompactionBytes);
addInt(rocksdb::DB::Properties::kBaseLevel);
addInt(rocksdb::DB::Properties::kBlockCacheCapacity);
addInt(rocksdb::DB::Properties::kBlockCacheUsage);
addInt(rocksdb::DB::Properties::kBlockCachePinnedUsage);
addInt(rocksdb::DB::Properties::kTotalSstFilesSize);
addIntAllCf(rocksdb::DB::Properties::kTotalSstFilesSize);
addInt(rocksdb::DB::Properties::kActualDelayedWriteRate);
addInt(rocksdb::DB::Properties::kIsWriteStopped);
@ -2233,6 +2253,7 @@ void RocksDBEngine::getStatistics(VPackBuilder& builder) const {
}
// print column family statistics
// warning: output format limits numbers to 3 digits of precision or less.
builder.add("columnFamilies", VPackValue(VPackValueType::Object));
addCf("definitions", RocksDBColumnFamily::definitions());
addCf("documents", RocksDBColumnFamily::documents());
@ -2243,6 +2264,10 @@ void RocksDBEngine::getStatistics(VPackBuilder& builder) const {
addCf("fulltext", RocksDBColumnFamily::fulltext());
builder.close();
if (_listener) {
builder.add("rocksdbengine.throttle.bps", VPackValue(_listener->GetThrottle()));
} // if
builder.close();
}

View File

@ -87,6 +87,8 @@ class RocksDBThrottle : public rocksdb::EventListener {
void StopThread();
uint64_t GetThrottle() const {return _throttleBps;};
protected:
void Startup(rocksdb::DB* db);
@ -139,7 +141,7 @@ class RocksDBThrottle : public rocksdb::EventListener {
ThrottleData_t _throttleData[THROTTLE_INTERVALS];
size_t _replaceIdx;
uint64_t _throttleBps;
std::atomic<uint64_t> _throttleBps;
bool _firstThrottle;
std::unique_ptr<WriteControllerToken> _delayToken;