1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. 2 // This source code is licensed under both the GPLv2 (found in the 3 // COPYING file in the root directory) and Apache 2.0 License 4 // (found in the LICENSE.Apache file in the root directory). 5 6 #pragma once 7 8 #include <atomic> 9 #include <cstddef> 10 #include <cstdint> 11 #include <map> 12 #include <memory> 13 #include <string> 14 #include <vector> 15 16 #include "rocksdb/status.h" 17 18 namespace ROCKSDB_NAMESPACE { 19 20 /** 21 * Keep adding ticker's here. 22 * 1. Any ticker should be added before TICKER_ENUM_MAX. 23 * 2. Add a readable string in TickersNameMap below for the newly added ticker. 24 * 3. Add a corresponding enum value to TickerType.java in the java API 25 * 4. Add the enum conversions from Java and C++ to portal.h's toJavaTickerType 26 * and toCppTickers 27 */ 28 enum Tickers : uint32_t { 29 // total block cache misses 30 // REQUIRES: BLOCK_CACHE_MISS == BLOCK_CACHE_INDEX_MISS + 31 // BLOCK_CACHE_FILTER_MISS + 32 // BLOCK_CACHE_DATA_MISS; 33 BLOCK_CACHE_MISS = 0, 34 // total block cache hit 35 // REQUIRES: BLOCK_CACHE_HIT == BLOCK_CACHE_INDEX_HIT + 36 // BLOCK_CACHE_FILTER_HIT + 37 // BLOCK_CACHE_DATA_HIT; 38 BLOCK_CACHE_HIT, 39 // # of blocks added to block cache. 40 BLOCK_CACHE_ADD, 41 // # of failures when adding blocks to block cache. 42 BLOCK_CACHE_ADD_FAILURES, 43 // # of times cache miss when accessing index block from block cache. 44 BLOCK_CACHE_INDEX_MISS, 45 // # of times cache hit when accessing index block from block cache. 46 BLOCK_CACHE_INDEX_HIT, 47 // # of index blocks added to block cache. 48 BLOCK_CACHE_INDEX_ADD, 49 // # of bytes of index blocks inserted into cache 50 BLOCK_CACHE_INDEX_BYTES_INSERT, 51 // # of bytes of index block erased from cache 52 BLOCK_CACHE_INDEX_BYTES_EVICT, 53 // # of times cache miss when accessing filter block from block cache. 54 BLOCK_CACHE_FILTER_MISS, 55 // # of times cache hit when accessing filter block from block cache. 56 BLOCK_CACHE_FILTER_HIT, 57 // # of filter blocks added to block cache. 58 BLOCK_CACHE_FILTER_ADD, 59 // # of bytes of bloom filter blocks inserted into cache 60 BLOCK_CACHE_FILTER_BYTES_INSERT, 61 // # of bytes of bloom filter block erased from cache 62 BLOCK_CACHE_FILTER_BYTES_EVICT, 63 // # of times cache miss when accessing data block from block cache. 64 BLOCK_CACHE_DATA_MISS, 65 // # of times cache hit when accessing data block from block cache. 66 BLOCK_CACHE_DATA_HIT, 67 // # of data blocks added to block cache. 68 BLOCK_CACHE_DATA_ADD, 69 // # of bytes of data blocks inserted into cache 70 BLOCK_CACHE_DATA_BYTES_INSERT, 71 // # of bytes read from cache. 72 BLOCK_CACHE_BYTES_READ, 73 // # of bytes written into cache. 74 BLOCK_CACHE_BYTES_WRITE, 75 76 // # of times bloom filter has avoided file reads, i.e., negatives. 77 BLOOM_FILTER_USEFUL, 78 // # of times bloom FullFilter has not avoided the reads. 79 BLOOM_FILTER_FULL_POSITIVE, 80 // # of times bloom FullFilter has not avoided the reads and data actually 81 // exist. 82 BLOOM_FILTER_FULL_TRUE_POSITIVE, 83 84 BLOOM_FILTER_MICROS, 85 86 // # persistent cache hit 87 PERSISTENT_CACHE_HIT, 88 // # persistent cache miss 89 PERSISTENT_CACHE_MISS, 90 91 // # total simulation block cache hits 92 SIM_BLOCK_CACHE_HIT, 93 // # total simulation block cache misses 94 SIM_BLOCK_CACHE_MISS, 95 96 // # of memtable hits. 97 MEMTABLE_HIT, 98 // # of memtable misses. 99 MEMTABLE_MISS, 100 101 // # of Get() queries served by L0 102 GET_HIT_L0, 103 // # of Get() queries served by L1 104 GET_HIT_L1, 105 // # of Get() queries served by L2 and up 106 GET_HIT_L2_AND_UP, 107 108 /** 109 * COMPACTION_KEY_DROP_* count the reasons for key drop during compaction 110 * There are 4 reasons currently. 111 */ 112 COMPACTION_KEY_DROP_NEWER_ENTRY, // key was written with a newer value. 113 // Also includes keys dropped for range del. 114 COMPACTION_KEY_DROP_OBSOLETE, // The key is obsolete. 115 COMPACTION_KEY_DROP_RANGE_DEL, // key was covered by a range tombstone. 116 COMPACTION_KEY_DROP_USER, // user compaction function has dropped the key. 117 COMPACTION_RANGE_DEL_DROP_OBSOLETE, // all keys in range were deleted. 118 // Deletions obsoleted before bottom level due to file gap optimization. 119 COMPACTION_OPTIMIZED_DEL_DROP_OBSOLETE, 120 // If a compaction was cancelled in sfm to prevent ENOSPC 121 COMPACTION_CANCELLED, 122 123 // Number of keys written to the database via the Put and Write call's 124 NUMBER_KEYS_WRITTEN, 125 // Number of Keys read, 126 NUMBER_KEYS_READ, 127 // Number keys updated, if inplace update is enabled 128 NUMBER_KEYS_UPDATED, 129 // The number of uncompressed bytes issued by DB::Put(), DB::Delete(), 130 // DB::Merge(), and DB::Write(). 131 BYTES_WRITTEN, 132 // The number of uncompressed bytes read from DB::Get(). It could be 133 // either from memtables, cache, or table files. 134 // For the number of logical bytes read from DB::MultiGet(), 135 // please use NUMBER_MULTIGET_BYTES_READ. 136 BYTES_READ, 137 // The number of calls to seek/next/prev 138 NUMBER_DB_SEEK, 139 NUMBER_DB_NEXT, 140 NUMBER_DB_PREV, 141 // The number of calls to seek/next/prev that returned data 142 NUMBER_DB_SEEK_FOUND, 143 NUMBER_DB_NEXT_FOUND, 144 NUMBER_DB_PREV_FOUND, 145 // The number of uncompressed bytes read from an iterator. 146 // Includes size of key and value. 147 ITER_BYTES_READ, 148 NO_FILE_CLOSES, 149 NO_FILE_OPENS, 150 NO_FILE_ERRORS, 151 // DEPRECATED Time system had to wait to do LO-L1 compactions 152 STALL_L0_SLOWDOWN_MICROS, 153 // DEPRECATED Time system had to wait to move memtable to L1. 154 STALL_MEMTABLE_COMPACTION_MICROS, 155 // DEPRECATED write throttle because of too many files in L0 156 STALL_L0_NUM_FILES_MICROS, 157 // Writer has to wait for compaction or flush to finish. 158 STALL_MICROS, 159 // The wait time for db mutex. 160 // Disabled by default. To enable it set stats level to kAll 161 DB_MUTEX_WAIT_MICROS, 162 RATE_LIMIT_DELAY_MILLIS, 163 // DEPRECATED number of iterators currently open 164 NO_ITERATORS, 165 166 // Number of MultiGet calls, keys read, and bytes read 167 NUMBER_MULTIGET_CALLS, 168 NUMBER_MULTIGET_KEYS_READ, 169 NUMBER_MULTIGET_BYTES_READ, 170 171 // Number of deletes records that were not required to be 172 // written to storage because key does not exist 173 NUMBER_FILTERED_DELETES, 174 NUMBER_MERGE_FAILURES, 175 176 // number of times bloom was checked before creating iterator on a 177 // file, and the number of times the check was useful in avoiding 178 // iterator creation (and thus likely IOPs). 179 BLOOM_FILTER_PREFIX_CHECKED, 180 BLOOM_FILTER_PREFIX_USEFUL, 181 182 // Number of times we had to reseek inside an iteration to skip 183 // over large number of keys with same userkey. 184 NUMBER_OF_RESEEKS_IN_ITERATION, 185 186 // Record the number of calls to GetUpadtesSince. Useful to keep track of 187 // transaction log iterator refreshes 188 GET_UPDATES_SINCE_CALLS, 189 BLOCK_CACHE_COMPRESSED_MISS, // miss in the compressed block cache 190 BLOCK_CACHE_COMPRESSED_HIT, // hit in the compressed block cache 191 // Number of blocks added to compressed block cache 192 BLOCK_CACHE_COMPRESSED_ADD, 193 // Number of failures when adding blocks to compressed block cache 194 BLOCK_CACHE_COMPRESSED_ADD_FAILURES, 195 WAL_FILE_SYNCED, // Number of times WAL sync is done 196 WAL_FILE_BYTES, // Number of bytes written to WAL 197 198 // Writes can be processed by requesting thread or by the thread at the 199 // head of the writers queue. 200 WRITE_DONE_BY_SELF, 201 WRITE_DONE_BY_OTHER, // Equivalent to writes done for others 202 WRITE_TIMEDOUT, // Number of writes ending up with timed-out. 203 WRITE_WITH_WAL, // Number of Write calls that request WAL 204 COMPACT_READ_BYTES, // Bytes read during compaction 205 COMPACT_WRITE_BYTES, // Bytes written during compaction 206 FLUSH_WRITE_BYTES, // Bytes written during flush 207 208 // Number of table's properties loaded directly from file, without creating 209 // table reader object. 210 NUMBER_DIRECT_LOAD_TABLE_PROPERTIES, 211 NUMBER_SUPERVERSION_ACQUIRES, 212 NUMBER_SUPERVERSION_RELEASES, 213 NUMBER_SUPERVERSION_CLEANUPS, 214 215 // # of compressions/decompressions executed 216 NUMBER_BLOCK_COMPRESSED, 217 NUMBER_BLOCK_DECOMPRESSED, 218 219 NUMBER_BLOCK_NOT_COMPRESSED, 220 MERGE_OPERATION_TOTAL_TIME, 221 FILTER_OPERATION_TOTAL_TIME, 222 223 // Row cache. 224 ROW_CACHE_HIT, 225 ROW_CACHE_MISS, 226 227 // Read amplification statistics. 228 // Read amplification can be calculated using this formula 229 // (READ_AMP_TOTAL_READ_BYTES / READ_AMP_ESTIMATE_USEFUL_BYTES) 230 // 231 // REQUIRES: ReadOptions::read_amp_bytes_per_bit to be enabled 232 READ_AMP_ESTIMATE_USEFUL_BYTES, // Estimate of total bytes actually used. 233 READ_AMP_TOTAL_READ_BYTES, // Total size of loaded data blocks. 234 235 // Number of refill intervals where rate limiter's bytes are fully consumed. 236 NUMBER_RATE_LIMITER_DRAINS, 237 238 // Number of internal keys skipped by Iterator 239 NUMBER_ITER_SKIP, 240 241 // BlobDB specific stats 242 // # of Put/PutTTL/PutUntil to BlobDB. 243 BLOB_DB_NUM_PUT, 244 // # of Write to BlobDB. 245 BLOB_DB_NUM_WRITE, 246 // # of Get to BlobDB. 247 BLOB_DB_NUM_GET, 248 // # of MultiGet to BlobDB. 249 BLOB_DB_NUM_MULTIGET, 250 // # of Seek/SeekToFirst/SeekToLast/SeekForPrev to BlobDB iterator. 251 BLOB_DB_NUM_SEEK, 252 // # of Next to BlobDB iterator. 253 BLOB_DB_NUM_NEXT, 254 // # of Prev to BlobDB iterator. 255 BLOB_DB_NUM_PREV, 256 // # of keys written to BlobDB. 257 BLOB_DB_NUM_KEYS_WRITTEN, 258 // # of keys read from BlobDB. 259 BLOB_DB_NUM_KEYS_READ, 260 // # of bytes (key + value) written to BlobDB. 261 BLOB_DB_BYTES_WRITTEN, 262 // # of bytes (keys + value) read from BlobDB. 263 BLOB_DB_BYTES_READ, 264 // # of keys written by BlobDB as non-TTL inlined value. 265 BLOB_DB_WRITE_INLINED, 266 // # of keys written by BlobDB as TTL inlined value. 267 BLOB_DB_WRITE_INLINED_TTL, 268 // # of keys written by BlobDB as non-TTL blob value. 269 BLOB_DB_WRITE_BLOB, 270 // # of keys written by BlobDB as TTL blob value. 271 BLOB_DB_WRITE_BLOB_TTL, 272 // # of bytes written to blob file. 273 BLOB_DB_BLOB_FILE_BYTES_WRITTEN, 274 // # of bytes read from blob file. 275 BLOB_DB_BLOB_FILE_BYTES_READ, 276 // # of times a blob files being synced. 277 BLOB_DB_BLOB_FILE_SYNCED, 278 // # of blob index evicted from base DB by BlobDB compaction filter because 279 // of expiration. 280 BLOB_DB_BLOB_INDEX_EXPIRED_COUNT, 281 // size of blob index evicted from base DB by BlobDB compaction filter 282 // because of expiration. 283 BLOB_DB_BLOB_INDEX_EXPIRED_SIZE, 284 // # of blob index evicted from base DB by BlobDB compaction filter because 285 // of corresponding file deleted. 286 BLOB_DB_BLOB_INDEX_EVICTED_COUNT, 287 // size of blob index evicted from base DB by BlobDB compaction filter 288 // because of corresponding file deleted. 289 BLOB_DB_BLOB_INDEX_EVICTED_SIZE, 290 // # of blob files that were obsoleted by garbage collection. 291 BLOB_DB_GC_NUM_FILES, 292 // # of blob files generated by garbage collection. 293 BLOB_DB_GC_NUM_NEW_FILES, 294 // # of BlobDB garbage collection failures. 295 BLOB_DB_GC_FAILURES, 296 // # of keys dropped by BlobDB garbage collection because they had been 297 // overwritten. DEPRECATED. 298 BLOB_DB_GC_NUM_KEYS_OVERWRITTEN, 299 // # of keys dropped by BlobDB garbage collection because of expiration. 300 // DEPRECATED. 301 BLOB_DB_GC_NUM_KEYS_EXPIRED, 302 // # of keys relocated to new blob file by garbage collection. 303 BLOB_DB_GC_NUM_KEYS_RELOCATED, 304 // # of bytes dropped by BlobDB garbage collection because they had been 305 // overwritten. DEPRECATED. 306 BLOB_DB_GC_BYTES_OVERWRITTEN, 307 // # of bytes dropped by BlobDB garbage collection because of expiration. 308 // DEPRECATED. 309 BLOB_DB_GC_BYTES_EXPIRED, 310 // # of bytes relocated to new blob file by garbage collection. 311 BLOB_DB_GC_BYTES_RELOCATED, 312 // # of blob files evicted because of BlobDB is full. 313 BLOB_DB_FIFO_NUM_FILES_EVICTED, 314 // # of keys in the blob files evicted because of BlobDB is full. 315 BLOB_DB_FIFO_NUM_KEYS_EVICTED, 316 // # of bytes in the blob files evicted because of BlobDB is full. 317 BLOB_DB_FIFO_BYTES_EVICTED, 318 319 // These counters indicate a performance issue in WritePrepared transactions. 320 // We should not seem them ticking them much. 321 // # of times prepare_mutex_ is acquired in the fast path. 322 TXN_PREPARE_MUTEX_OVERHEAD, 323 // # of times old_commit_map_mutex_ is acquired in the fast path. 324 TXN_OLD_COMMIT_MAP_MUTEX_OVERHEAD, 325 // # of times we checked a batch for duplicate keys. 326 TXN_DUPLICATE_KEY_OVERHEAD, 327 // # of times snapshot_mutex_ is acquired in the fast path. 328 TXN_SNAPSHOT_MUTEX_OVERHEAD, 329 // # of times ::Get returned TryAgain due to expired snapshot seq 330 TXN_GET_TRY_AGAIN, 331 332 // Number of keys actually found in MultiGet calls (vs number requested by 333 // caller) 334 // NUMBER_MULTIGET_KEYS_READ gives the number requested by caller 335 NUMBER_MULTIGET_KEYS_FOUND, 336 337 NO_ITERATOR_CREATED, // number of iterators created 338 NO_ITERATOR_DELETED, // number of iterators deleted 339 340 BLOCK_CACHE_COMPRESSION_DICT_MISS, 341 BLOCK_CACHE_COMPRESSION_DICT_HIT, 342 BLOCK_CACHE_COMPRESSION_DICT_ADD, 343 BLOCK_CACHE_COMPRESSION_DICT_BYTES_INSERT, 344 BLOCK_CACHE_COMPRESSION_DICT_BYTES_EVICT, 345 TICKER_ENUM_MAX 346 }; 347 348 // The order of items listed in Tickers should be the same as 349 // the order listed in TickersNameMap 350 extern const std::vector<std::pair<Tickers, std::string>> TickersNameMap; 351 352 /** 353 * Keep adding histogram's here. 354 * Any histogram should have value less than HISTOGRAM_ENUM_MAX 355 * Add a new Histogram by assigning it the current value of HISTOGRAM_ENUM_MAX 356 * Add a string representation in HistogramsNameMap below 357 * And increment HISTOGRAM_ENUM_MAX 358 * Add a corresponding enum value to HistogramType.java in the java API 359 */ 360 enum Histograms : uint32_t { 361 DB_GET = 0, 362 DB_WRITE, 363 COMPACTION_TIME, 364 COMPACTION_CPU_TIME, 365 SUBCOMPACTION_SETUP_TIME, 366 TABLE_SYNC_MICROS, 367 COMPACTION_OUTFILE_SYNC_MICROS, 368 WAL_FILE_SYNC_MICROS, 369 MANIFEST_FILE_SYNC_MICROS, 370 // TIME SPENT IN IO DURING TABLE OPEN 371 TABLE_OPEN_IO_MICROS, 372 DB_MULTIGET, 373 READ_BLOCK_COMPACTION_MICROS, 374 READ_BLOCK_GET_MICROS, 375 WRITE_RAW_BLOCK_MICROS, 376 STALL_L0_SLOWDOWN_COUNT, 377 STALL_MEMTABLE_COMPACTION_COUNT, 378 STALL_L0_NUM_FILES_COUNT, 379 HARD_RATE_LIMIT_DELAY_COUNT, 380 SOFT_RATE_LIMIT_DELAY_COUNT, 381 NUM_FILES_IN_SINGLE_COMPACTION, 382 DB_SEEK, 383 WRITE_STALL, 384 SST_READ_MICROS, 385 // The number of subcompactions actually scheduled during a compaction 386 NUM_SUBCOMPACTIONS_SCHEDULED, 387 // Value size distribution in each operation 388 BYTES_PER_READ, 389 BYTES_PER_WRITE, 390 BYTES_PER_MULTIGET, 391 392 // number of bytes compressed/decompressed 393 // number of bytes is when uncompressed; i.e. before/after respectively 394 BYTES_COMPRESSED, 395 BYTES_DECOMPRESSED, 396 COMPRESSION_TIMES_NANOS, 397 DECOMPRESSION_TIMES_NANOS, 398 // Number of merge operands passed to the merge operator in user read 399 // requests. 400 READ_NUM_MERGE_OPERANDS, 401 402 // BlobDB specific stats 403 // Size of keys written to BlobDB. 404 BLOB_DB_KEY_SIZE, 405 // Size of values written to BlobDB. 406 BLOB_DB_VALUE_SIZE, 407 // BlobDB Put/PutWithTTL/PutUntil/Write latency. 408 BLOB_DB_WRITE_MICROS, 409 // BlobDB Get lagency. 410 BLOB_DB_GET_MICROS, 411 // BlobDB MultiGet latency. 412 BLOB_DB_MULTIGET_MICROS, 413 // BlobDB Seek/SeekToFirst/SeekToLast/SeekForPrev latency. 414 BLOB_DB_SEEK_MICROS, 415 // BlobDB Next latency. 416 BLOB_DB_NEXT_MICROS, 417 // BlobDB Prev latency. 418 BLOB_DB_PREV_MICROS, 419 // Blob file write latency. 420 BLOB_DB_BLOB_FILE_WRITE_MICROS, 421 // Blob file read latency. 422 BLOB_DB_BLOB_FILE_READ_MICROS, 423 // Blob file sync latency. 424 BLOB_DB_BLOB_FILE_SYNC_MICROS, 425 // BlobDB garbage collection time. DEPRECATED. 426 BLOB_DB_GC_MICROS, 427 // BlobDB compression time. 428 BLOB_DB_COMPRESSION_MICROS, 429 // BlobDB decompression time. 430 BLOB_DB_DECOMPRESSION_MICROS, 431 // Time spent flushing memtable to disk 432 FLUSH_TIME, 433 SST_BATCH_SIZE, 434 435 HISTOGRAM_ENUM_MAX, 436 }; 437 438 extern const std::vector<std::pair<Histograms, std::string>> HistogramsNameMap; 439 440 struct HistogramData { 441 double median; 442 double percentile95; 443 double percentile99; 444 double average; 445 double standard_deviation; 446 // zero-initialize new members since old Statistics::histogramData() 447 // implementations won't write them. 448 double max = 0.0; 449 uint64_t count = 0; 450 uint64_t sum = 0; 451 double min = 0.0; 452 }; 453 454 // StatsLevel can be used to reduce statistics overhead by skipping certain 455 // types of stats in the stats collection process. 456 // Usage: 457 // options.statistics->set_stats_level(StatsLevel::kExceptTimeForMutex); 458 enum StatsLevel : uint8_t { 459 // Disable timer stats, and skip histogram stats 460 kExceptHistogramOrTimers, 461 // Skip timer stats 462 kExceptTimers, 463 // Collect all stats except time inside mutex lock AND time spent on 464 // compression. 465 kExceptDetailedTimers, 466 // Collect all stats except the counters requiring to get time inside the 467 // mutex lock. 468 kExceptTimeForMutex, 469 // Collect all stats, including measuring duration of mutex operations. 470 // If getting time is expensive on the platform to run, it can 471 // reduce scalability to more threads, especially for writes. 472 kAll, 473 }; 474 475 // Analyze the performance of a db by providing cumulative stats over time. 476 // Usage: 477 // Options options; 478 // options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics(); 479 // Status s = DB::Open(options, kDBPath, &db); 480 // ... 481 // options.statistics->getTickerCount(NUMBER_BLOCK_COMPRESSED); 482 // HistogramData hist; 483 // options.statistics->histogramData(FLUSH_TIME, &hist); 484 class Statistics { 485 public: ~Statistics()486 virtual ~Statistics() {} Type()487 static const char* Type() { return "Statistics"; } 488 virtual uint64_t getTickerCount(uint32_t tickerType) const = 0; 489 virtual void histogramData(uint32_t type, 490 HistogramData* const data) const = 0; getHistogramString(uint32_t)491 virtual std::string getHistogramString(uint32_t /*type*/) const { return ""; } 492 virtual void recordTick(uint32_t tickerType, uint64_t count = 0) = 0; 493 virtual void setTickerCount(uint32_t tickerType, uint64_t count) = 0; 494 virtual uint64_t getAndResetTickerCount(uint32_t tickerType) = 0; reportTimeToHistogram(uint32_t histogramType,uint64_t time)495 virtual void reportTimeToHistogram(uint32_t histogramType, uint64_t time) { 496 if (get_stats_level() <= StatsLevel::kExceptTimers) { 497 return; 498 } 499 recordInHistogram(histogramType, time); 500 } 501 // The function is here only for backward compatibility reason. 502 // Users implementing their own Statistics class should override 503 // recordInHistogram() instead and leave measureTime() as it is. measureTime(uint32_t,uint64_t)504 virtual void measureTime(uint32_t /*histogramType*/, uint64_t /*time*/) { 505 // This is not supposed to be called. 506 assert(false); 507 } recordInHistogram(uint32_t histogramType,uint64_t time)508 virtual void recordInHistogram(uint32_t histogramType, uint64_t time) { 509 // measureTime() is the old and inaccurate function name. 510 // To keep backward compatible. If users implement their own 511 // statistics, which overrides measureTime() but doesn't override 512 // this function. We forward to measureTime(). 513 measureTime(histogramType, time); 514 } 515 516 // Resets all ticker and histogram stats Reset()517 virtual Status Reset() { return Status::NotSupported("Not implemented"); } 518 519 // String representation of the statistic object. ToString()520 virtual std::string ToString() const { 521 // Do nothing by default 522 return std::string("ToString(): not implemented"); 523 } 524 getTickerMap(std::map<std::string,uint64_t> *)525 virtual bool getTickerMap(std::map<std::string, uint64_t>*) const { 526 // Do nothing by default 527 return false; 528 } 529 530 // Override this function to disable particular histogram collection HistEnabledForType(uint32_t type)531 virtual bool HistEnabledForType(uint32_t type) const { 532 return type < HISTOGRAM_ENUM_MAX; 533 } set_stats_level(StatsLevel sl)534 void set_stats_level(StatsLevel sl) { 535 stats_level_.store(sl, std::memory_order_relaxed); 536 } get_stats_level()537 StatsLevel get_stats_level() const { 538 return stats_level_.load(std::memory_order_relaxed); 539 } 540 541 private: 542 std::atomic<StatsLevel> stats_level_{kExceptDetailedTimers}; 543 }; 544 545 // Create a concrete DBStatistics object 546 std::shared_ptr<Statistics> CreateDBStatistics(); 547 548 } // namespace ROCKSDB_NAMESPACE 549