]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/db/internal_stats.h
import 14.2.4 nautilus point release
[ceph.git] / ceph / src / rocksdb / db / internal_stats.h
CommitLineData
7c673cae 1// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
11fdf7f2
TL
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).
7c673cae
FG
5//
6// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
7// Use of this source code is governed by a BSD-style license that can be
8// found in the LICENSE file. See the AUTHORS file for names of contributors.
9//
10
11#pragma once
12#include <map>
13#include <string>
14#include <vector>
15
16#include "db/version_set.h"
17
18class ColumnFamilyData;
19
20namespace rocksdb {
21
7c673cae 22class DBImpl;
11fdf7f2 23class MemTableList;
7c673cae
FG
24
25// Config for retrieving a property's value.
26struct DBPropertyInfo {
27 bool need_out_of_mutex;
28
29 // gcc had an internal error for initializing union of pointer-to-member-
30 // functions. Workaround is to populate exactly one of the following function
31 // pointers with a non-nullptr value.
32
33 // @param value Value-result argument for storing the property's string value
34 // @param suffix Argument portion of the property. For example, suffix would
35 // be "5" for the property "rocksdb.num-files-at-level5". So far, only
36 // certain string properties take an argument.
37 bool (InternalStats::*handle_string)(std::string* value, Slice suffix);
38
39 // @param value Value-result argument for storing the property's uint64 value
40 // @param db Many of the int properties rely on DBImpl methods.
41 // @param version Version is needed in case the property is retrieved without
42 // holding db mutex, which is only supported for int properties.
43 bool (InternalStats::*handle_int)(uint64_t* value, DBImpl* db,
44 Version* version);
11fdf7f2
TL
45
46 // @param props Map of general properties to populate
47 bool (InternalStats::*handle_map)(std::map<std::string, std::string>* props);
48
49 // handle the string type properties rely on DBImpl methods
50 // @param value Value-result argument for storing the property's string value
51 bool (DBImpl::*handle_string_dbimpl)(std::string* value);
7c673cae
FG
52};
53
54extern const DBPropertyInfo* GetPropertyInfo(const Slice& property);
55
56#ifndef ROCKSDB_LITE
57#undef SCORE
58enum class LevelStatType {
59 INVALID = 0,
60 NUM_FILES,
61 COMPACTED_FILES,
62 SIZE_BYTES,
63 SCORE,
64 READ_GB,
65 RN_GB,
66 RNP1_GB,
67 WRITE_GB,
68 W_NEW_GB,
69 MOVED_GB,
70 WRITE_AMP,
71 READ_MBPS,
72 WRITE_MBPS,
73 COMP_SEC,
494da23a 74 COMP_CPU_SEC,
7c673cae
FG
75 COMP_COUNT,
76 AVG_SEC,
77 KEY_IN,
78 KEY_DROP,
79 TOTAL // total number of types
80};
81
82struct LevelStat {
83 // This what will be L?.property_name in the flat map returned to the user
84 std::string property_name;
85 // This will be what we will print in the header in the cli
86 std::string header_name;
87};
88
89class InternalStats {
90 public:
91 static const std::map<LevelStatType, LevelStat> compaction_level_stats;
92
93 enum InternalCFStatsType {
11fdf7f2
TL
94 L0_FILE_COUNT_LIMIT_SLOWDOWNS,
95 LOCKED_L0_FILE_COUNT_LIMIT_SLOWDOWNS,
96 MEMTABLE_LIMIT_STOPS,
97 MEMTABLE_LIMIT_SLOWDOWNS,
98 L0_FILE_COUNT_LIMIT_STOPS,
99 LOCKED_L0_FILE_COUNT_LIMIT_STOPS,
100 PENDING_COMPACTION_BYTES_LIMIT_SLOWDOWNS,
101 PENDING_COMPACTION_BYTES_LIMIT_STOPS,
7c673cae
FG
102 WRITE_STALLS_ENUM_MAX,
103 BYTES_FLUSHED,
104 BYTES_INGESTED_ADD_FILE,
105 INGESTED_NUM_FILES_TOTAL,
106 INGESTED_LEVEL0_NUM_FILES_TOTAL,
107 INGESTED_NUM_KEYS_TOTAL,
108 INTERNAL_CF_STATS_ENUM_MAX,
109 };
110
111 enum InternalDBStatsType {
112 WAL_FILE_BYTES,
113 WAL_FILE_SYNCED,
114 BYTES_WRITTEN,
115 NUMBER_KEYS_WRITTEN,
116 WRITE_DONE_BY_OTHER,
117 WRITE_DONE_BY_SELF,
118 WRITE_WITH_WAL,
119 WRITE_STALL_MICROS,
120 INTERNAL_DB_STATS_ENUM_MAX,
121 };
122
123 InternalStats(int num_levels, Env* env, ColumnFamilyData* cfd)
124 : db_stats_{},
125 cf_stats_value_{},
126 cf_stats_count_{},
127 comp_stats_(num_levels),
494da23a 128 comp_stats_by_pri_(Env::Priority::TOTAL),
7c673cae
FG
129 file_read_latency_(num_levels),
130 bg_error_count_(0),
131 number_levels_(num_levels),
132 env_(env),
133 cfd_(cfd),
134 started_at_(env->NowMicros()) {}
135
136 // Per level compaction stats. comp_stats_[level] stores the stats for
137 // compactions that produced data for the specified "level".
138 struct CompactionStats {
139 uint64_t micros;
494da23a 140 uint64_t cpu_micros;
7c673cae
FG
141
142 // The number of bytes read from all non-output levels
143 uint64_t bytes_read_non_output_levels;
144
145 // The number of bytes read from the compaction output level.
146 uint64_t bytes_read_output_level;
147
148 // Total number of bytes written during compaction
149 uint64_t bytes_written;
150
151 // Total number of bytes moved to the output level
152 uint64_t bytes_moved;
153
154 // The number of compaction input files in all non-output levels.
155 int num_input_files_in_non_output_levels;
156
157 // The number of compaction input files in the output level.
158 int num_input_files_in_output_level;
159
160 // The number of compaction output files.
161 int num_output_files;
162
163 // Total incoming entries during compaction between levels N and N+1
164 uint64_t num_input_records;
165
166 // Accumulated diff number of entries
167 // (num input entries - num output entires) for compaction levels N and N+1
168 uint64_t num_dropped_records;
169
170 // Number of compactions done
171 int count;
172
11fdf7f2
TL
173 // Number of compactions done per CompactionReason
174 int counts[static_cast<int>(CompactionReason::kNumOfReasons)];
175
176 explicit CompactionStats()
7c673cae 177 : micros(0),
494da23a 178 cpu_micros(0),
7c673cae
FG
179 bytes_read_non_output_levels(0),
180 bytes_read_output_level(0),
181 bytes_written(0),
182 bytes_moved(0),
183 num_input_files_in_non_output_levels(0),
184 num_input_files_in_output_level(0),
185 num_output_files(0),
186 num_input_records(0),
187 num_dropped_records(0),
11fdf7f2
TL
188 count(0) {
189 int num_of_reasons = static_cast<int>(CompactionReason::kNumOfReasons);
190 for (int i = 0; i < num_of_reasons; i++) {
191 counts[i] = 0;
192 }
193 }
194
195 explicit CompactionStats(CompactionReason reason, int c)
196 : micros(0),
494da23a 197 cpu_micros(0),
11fdf7f2
TL
198 bytes_read_non_output_levels(0),
199 bytes_read_output_level(0),
200 bytes_written(0),
201 bytes_moved(0),
202 num_input_files_in_non_output_levels(0),
203 num_input_files_in_output_level(0),
204 num_output_files(0),
205 num_input_records(0),
206 num_dropped_records(0),
207 count(c) {
208 int num_of_reasons = static_cast<int>(CompactionReason::kNumOfReasons);
209 for (int i = 0; i < num_of_reasons; i++) {
210 counts[i] = 0;
211 }
212 int r = static_cast<int>(reason);
213 if (r >= 0 && r < num_of_reasons) {
214 counts[r] = c;
215 } else {
216 count = 0;
217 }
218 }
7c673cae
FG
219
220 explicit CompactionStats(const CompactionStats& c)
221 : micros(c.micros),
494da23a 222 cpu_micros(c.cpu_micros),
7c673cae
FG
223 bytes_read_non_output_levels(c.bytes_read_non_output_levels),
224 bytes_read_output_level(c.bytes_read_output_level),
225 bytes_written(c.bytes_written),
226 bytes_moved(c.bytes_moved),
227 num_input_files_in_non_output_levels(
228 c.num_input_files_in_non_output_levels),
494da23a 229 num_input_files_in_output_level(c.num_input_files_in_output_level),
7c673cae
FG
230 num_output_files(c.num_output_files),
231 num_input_records(c.num_input_records),
232 num_dropped_records(c.num_dropped_records),
11fdf7f2
TL
233 count(c.count) {
234 int num_of_reasons = static_cast<int>(CompactionReason::kNumOfReasons);
235 for (int i = 0; i < num_of_reasons; i++) {
236 counts[i] = c.counts[i];
237 }
238 }
7c673cae
FG
239
240 void Clear() {
241 this->micros = 0;
494da23a 242 this->cpu_micros = 0;
7c673cae
FG
243 this->bytes_read_non_output_levels = 0;
244 this->bytes_read_output_level = 0;
245 this->bytes_written = 0;
246 this->bytes_moved = 0;
247 this->num_input_files_in_non_output_levels = 0;
248 this->num_input_files_in_output_level = 0;
249 this->num_output_files = 0;
250 this->num_input_records = 0;
251 this->num_dropped_records = 0;
252 this->count = 0;
11fdf7f2
TL
253 int num_of_reasons = static_cast<int>(CompactionReason::kNumOfReasons);
254 for (int i = 0; i < num_of_reasons; i++) {
255 counts[i] = 0;
256 }
7c673cae
FG
257 }
258
259 void Add(const CompactionStats& c) {
260 this->micros += c.micros;
494da23a 261 this->cpu_micros += c.cpu_micros;
7c673cae
FG
262 this->bytes_read_non_output_levels += c.bytes_read_non_output_levels;
263 this->bytes_read_output_level += c.bytes_read_output_level;
264 this->bytes_written += c.bytes_written;
265 this->bytes_moved += c.bytes_moved;
266 this->num_input_files_in_non_output_levels +=
267 c.num_input_files_in_non_output_levels;
268 this->num_input_files_in_output_level +=
269 c.num_input_files_in_output_level;
270 this->num_output_files += c.num_output_files;
271 this->num_input_records += c.num_input_records;
272 this->num_dropped_records += c.num_dropped_records;
273 this->count += c.count;
11fdf7f2
TL
274 int num_of_reasons = static_cast<int>(CompactionReason::kNumOfReasons);
275 for (int i = 0; i< num_of_reasons; i++) {
276 counts[i] += c.counts[i];
277 }
7c673cae
FG
278 }
279
280 void Subtract(const CompactionStats& c) {
281 this->micros -= c.micros;
494da23a 282 this->cpu_micros -= c.cpu_micros;
7c673cae
FG
283 this->bytes_read_non_output_levels -= c.bytes_read_non_output_levels;
284 this->bytes_read_output_level -= c.bytes_read_output_level;
285 this->bytes_written -= c.bytes_written;
286 this->bytes_moved -= c.bytes_moved;
287 this->num_input_files_in_non_output_levels -=
288 c.num_input_files_in_non_output_levels;
289 this->num_input_files_in_output_level -=
290 c.num_input_files_in_output_level;
291 this->num_output_files -= c.num_output_files;
292 this->num_input_records -= c.num_input_records;
293 this->num_dropped_records -= c.num_dropped_records;
294 this->count -= c.count;
11fdf7f2
TL
295 int num_of_reasons = static_cast<int>(CompactionReason::kNumOfReasons);
296 for (int i = 0; i < num_of_reasons; i++) {
297 counts[i] -= c.counts[i];
298 }
7c673cae
FG
299 }
300 };
301
302 void Clear() {
303 for (int i = 0; i < INTERNAL_DB_STATS_ENUM_MAX; i++) {
304 db_stats_[i].store(0);
305 }
306 for (int i = 0; i < INTERNAL_CF_STATS_ENUM_MAX; i++) {
307 cf_stats_count_[i] = 0;
308 cf_stats_value_[i] = 0;
309 }
310 for (auto& comp_stat : comp_stats_) {
311 comp_stat.Clear();
312 }
313 for (auto& h : file_read_latency_) {
314 h.Clear();
315 }
316 cf_stats_snapshot_.Clear();
317 db_stats_snapshot_.Clear();
318 bg_error_count_ = 0;
319 started_at_ = env_->NowMicros();
320 }
321
494da23a
TL
322 void AddCompactionStats(int level, Env::Priority thread_pri,
323 const CompactionStats& stats) {
7c673cae 324 comp_stats_[level].Add(stats);
494da23a 325 comp_stats_by_pri_[thread_pri].Add(stats);
7c673cae
FG
326 }
327
328 void IncBytesMoved(int level, uint64_t amount) {
329 comp_stats_[level].bytes_moved += amount;
330 }
331
332 void AddCFStats(InternalCFStatsType type, uint64_t value) {
333 cf_stats_value_[type] += value;
334 ++cf_stats_count_[type];
335 }
336
11fdf7f2
TL
337 void AddDBStats(InternalDBStatsType type, uint64_t value,
338 bool concurrent = false) {
7c673cae 339 auto& v = db_stats_[type];
11fdf7f2
TL
340 if (concurrent) {
341 v.fetch_add(value, std::memory_order_relaxed);
342 } else {
343 v.store(v.load(std::memory_order_relaxed) + value,
344 std::memory_order_relaxed);
345 }
7c673cae
FG
346 }
347
348 uint64_t GetDBStats(InternalDBStatsType type) {
349 return db_stats_[type].load(std::memory_order_relaxed);
350 }
351
352 HistogramImpl* GetFileReadHist(int level) {
353 return &file_read_latency_[level];
354 }
355
356 uint64_t GetBackgroundErrorCount() const { return bg_error_count_; }
357
358 uint64_t BumpAndGetBackgroundErrorCount() { return ++bg_error_count_; }
359
360 bool GetStringProperty(const DBPropertyInfo& property_info,
361 const Slice& property, std::string* value);
362
363 bool GetMapProperty(const DBPropertyInfo& property_info,
364 const Slice& property,
11fdf7f2 365 std::map<std::string, std::string>* value);
7c673cae
FG
366
367 bool GetIntProperty(const DBPropertyInfo& property_info, uint64_t* value,
368 DBImpl* db);
369
370 bool GetIntPropertyOutOfMutex(const DBPropertyInfo& property_info,
371 Version* version, uint64_t* value);
372
11fdf7f2
TL
373 const std::vector<CompactionStats>& TEST_GetCompactionStats() const {
374 return comp_stats_;
375 }
376
7c673cae
FG
377 // Store a mapping from the user-facing DB::Properties string to our
378 // DBPropertyInfo struct used internally for retrieving properties.
379 static const std::unordered_map<std::string, DBPropertyInfo> ppt_name_to_info;
380
381 private:
382 void DumpDBStats(std::string* value);
11fdf7f2 383 void DumpCFMapStats(std::map<std::string, std::string>* cf_stats);
7c673cae
FG
384 void DumpCFMapStats(
385 std::map<int, std::map<LevelStatType, double>>* level_stats,
386 CompactionStats* compaction_stats_sum);
494da23a
TL
387 void DumpCFMapStatsByPriority(
388 std::map<int, std::map<LevelStatType, double>>* priorities_stats);
11fdf7f2 389 void DumpCFMapStatsIOStalls(std::map<std::string, std::string>* cf_stats);
7c673cae
FG
390 void DumpCFStats(std::string* value);
391 void DumpCFStatsNoFileHistogram(std::string* value);
392 void DumpCFFileHistogram(std::string* value);
393
11fdf7f2
TL
394 bool HandleBlockCacheStat(Cache** block_cache);
395
7c673cae
FG
396 // Per-DB stats
397 std::atomic<uint64_t> db_stats_[INTERNAL_DB_STATS_ENUM_MAX];
398 // Per-ColumnFamily stats
399 uint64_t cf_stats_value_[INTERNAL_CF_STATS_ENUM_MAX];
400 uint64_t cf_stats_count_[INTERNAL_CF_STATS_ENUM_MAX];
401 // Per-ColumnFamily/level compaction stats
402 std::vector<CompactionStats> comp_stats_;
494da23a 403 std::vector<CompactionStats> comp_stats_by_pri_;
7c673cae
FG
404 std::vector<HistogramImpl> file_read_latency_;
405
406 // Used to compute per-interval statistics
407 struct CFStatsSnapshot {
408 // ColumnFamily-level stats
409 CompactionStats comp_stats;
410 uint64_t ingest_bytes_flush; // Bytes written to L0 (Flush)
411 uint64_t stall_count; // Stall count
412 // Stats from compaction jobs - bytes written, bytes read, duration.
413 uint64_t compact_bytes_write;
414 uint64_t compact_bytes_read;
415 uint64_t compact_micros;
416 double seconds_up;
417
418 // AddFile specific stats
419 uint64_t ingest_bytes_addfile; // Total Bytes ingested
420 uint64_t ingest_files_addfile; // Total number of files ingested
421 uint64_t ingest_l0_files_addfile; // Total number of files ingested to L0
422 uint64_t ingest_keys_addfile; // Total number of keys ingested
423
424 CFStatsSnapshot()
11fdf7f2 425 : ingest_bytes_flush(0),
7c673cae
FG
426 stall_count(0),
427 compact_bytes_write(0),
428 compact_bytes_read(0),
429 compact_micros(0),
430 seconds_up(0),
431 ingest_bytes_addfile(0),
432 ingest_files_addfile(0),
433 ingest_l0_files_addfile(0),
434 ingest_keys_addfile(0) {}
435
436 void Clear() {
437 comp_stats.Clear();
438 ingest_bytes_flush = 0;
439 stall_count = 0;
440 compact_bytes_write = 0;
441 compact_bytes_read = 0;
442 compact_micros = 0;
443 seconds_up = 0;
444 ingest_bytes_addfile = 0;
445 ingest_files_addfile = 0;
446 ingest_l0_files_addfile = 0;
447 ingest_keys_addfile = 0;
448 }
449 } cf_stats_snapshot_;
450
451 struct DBStatsSnapshot {
452 // DB-level stats
453 uint64_t ingest_bytes; // Bytes written by user
454 uint64_t wal_bytes; // Bytes written to WAL
455 uint64_t wal_synced; // Number of times WAL is synced
456 uint64_t write_with_wal; // Number of writes that request WAL
457 // These count the number of writes processed by the calling thread or
458 // another thread.
459 uint64_t write_other;
460 uint64_t write_self;
461 // Total number of keys written. write_self and write_other measure number
462 // of write requests written, Each of the write request can contain updates
463 // to multiple keys. num_keys_written is total number of keys updated by all
464 // those writes.
465 uint64_t num_keys_written;
466 // Total time writes delayed by stalls.
467 uint64_t write_stall_micros;
468 double seconds_up;
469
470 DBStatsSnapshot()
471 : ingest_bytes(0),
472 wal_bytes(0),
473 wal_synced(0),
474 write_with_wal(0),
475 write_other(0),
476 write_self(0),
477 num_keys_written(0),
478 write_stall_micros(0),
479 seconds_up(0) {}
480
481 void Clear() {
482 ingest_bytes = 0;
483 wal_bytes = 0;
484 wal_synced = 0;
485 write_with_wal = 0;
486 write_other = 0;
487 write_self = 0;
488 num_keys_written = 0;
489 write_stall_micros = 0;
490 seconds_up = 0;
491 }
492 } db_stats_snapshot_;
493
494 // Handler functions for getting property values. They use "value" as a value-
495 // result argument, and return true upon successfully setting "value".
496 bool HandleNumFilesAtLevel(std::string* value, Slice suffix);
497 bool HandleCompressionRatioAtLevelPrefix(std::string* value, Slice suffix);
498 bool HandleLevelStats(std::string* value, Slice suffix);
499 bool HandleStats(std::string* value, Slice suffix);
11fdf7f2 500 bool HandleCFMapStats(std::map<std::string, std::string>* compaction_stats);
7c673cae
FG
501 bool HandleCFStats(std::string* value, Slice suffix);
502 bool HandleCFStatsNoFileHistogram(std::string* value, Slice suffix);
503 bool HandleCFFileHistogram(std::string* value, Slice suffix);
504 bool HandleDBStats(std::string* value, Slice suffix);
505 bool HandleSsTables(std::string* value, Slice suffix);
506 bool HandleAggregatedTableProperties(std::string* value, Slice suffix);
507 bool HandleAggregatedTablePropertiesAtLevel(std::string* value, Slice suffix);
508 bool HandleNumImmutableMemTable(uint64_t* value, DBImpl* db,
509 Version* version);
510 bool HandleNumImmutableMemTableFlushed(uint64_t* value, DBImpl* db,
511 Version* version);
512 bool HandleMemTableFlushPending(uint64_t* value, DBImpl* db,
513 Version* version);
514 bool HandleNumRunningFlushes(uint64_t* value, DBImpl* db, Version* version);
515 bool HandleCompactionPending(uint64_t* value, DBImpl* db, Version* version);
516 bool HandleNumRunningCompactions(uint64_t* value, DBImpl* db,
517 Version* version);
518 bool HandleBackgroundErrors(uint64_t* value, DBImpl* db, Version* version);
519 bool HandleCurSizeActiveMemTable(uint64_t* value, DBImpl* db,
520 Version* version);
521 bool HandleCurSizeAllMemTables(uint64_t* value, DBImpl* db, Version* version);
522 bool HandleSizeAllMemTables(uint64_t* value, DBImpl* db, Version* version);
523 bool HandleNumEntriesActiveMemTable(uint64_t* value, DBImpl* db,
524 Version* version);
525 bool HandleNumEntriesImmMemTables(uint64_t* value, DBImpl* db,
526 Version* version);
527 bool HandleNumDeletesActiveMemTable(uint64_t* value, DBImpl* db,
528 Version* version);
529 bool HandleNumDeletesImmMemTables(uint64_t* value, DBImpl* db,
530 Version* version);
531 bool HandleEstimateNumKeys(uint64_t* value, DBImpl* db, Version* version);
532 bool HandleNumSnapshots(uint64_t* value, DBImpl* db, Version* version);
533 bool HandleOldestSnapshotTime(uint64_t* value, DBImpl* db, Version* version);
534 bool HandleNumLiveVersions(uint64_t* value, DBImpl* db, Version* version);
535 bool HandleCurrentSuperVersionNumber(uint64_t* value, DBImpl* db,
536 Version* version);
537 bool HandleIsFileDeletionsEnabled(uint64_t* value, DBImpl* db,
538 Version* version);
539 bool HandleBaseLevel(uint64_t* value, DBImpl* db, Version* version);
540 bool HandleTotalSstFilesSize(uint64_t* value, DBImpl* db, Version* version);
11fdf7f2 541 bool HandleLiveSstFilesSize(uint64_t* value, DBImpl* db, Version* version);
7c673cae
FG
542 bool HandleEstimatePendingCompactionBytes(uint64_t* value, DBImpl* db,
543 Version* version);
544 bool HandleEstimateTableReadersMem(uint64_t* value, DBImpl* db,
545 Version* version);
546 bool HandleEstimateLiveDataSize(uint64_t* value, DBImpl* db,
547 Version* version);
548 bool HandleMinLogNumberToKeep(uint64_t* value, DBImpl* db, Version* version);
494da23a
TL
549 bool HandleMinObsoleteSstNumberToKeep(uint64_t* value, DBImpl* db,
550 Version* version);
7c673cae
FG
551 bool HandleActualDelayedWriteRate(uint64_t* value, DBImpl* db,
552 Version* version);
553 bool HandleIsWriteStopped(uint64_t* value, DBImpl* db, Version* version);
11fdf7f2
TL
554 bool HandleEstimateOldestKeyTime(uint64_t* value, DBImpl* db,
555 Version* version);
556 bool HandleBlockCacheCapacity(uint64_t* value, DBImpl* db, Version* version);
557 bool HandleBlockCacheUsage(uint64_t* value, DBImpl* db, Version* version);
558 bool HandleBlockCachePinnedUsage(uint64_t* value, DBImpl* db,
559 Version* version);
7c673cae
FG
560 // Total number of background errors encountered. Every time a flush task
561 // or compaction task fails, this counter is incremented. The failure can
562 // be caused by any possible reason, including file system errors, out of
563 // resources, or input file corruption. Failing when retrying the same flush
564 // or compaction will cause the counter to increase too.
565 uint64_t bg_error_count_;
566
567 const int number_levels_;
568 Env* env_;
569 ColumnFamilyData* cfd_;
570 uint64_t started_at_;
571};
572
573#else
574
575class InternalStats {
576 public:
577 enum InternalCFStatsType {
11fdf7f2
TL
578 L0_FILE_COUNT_LIMIT_SLOWDOWNS,
579 LOCKED_L0_FILE_COUNT_LIMIT_SLOWDOWNS,
580 MEMTABLE_LIMIT_STOPS,
581 MEMTABLE_LIMIT_SLOWDOWNS,
582 L0_FILE_COUNT_LIMIT_STOPS,
583 LOCKED_L0_FILE_COUNT_LIMIT_STOPS,
584 PENDING_COMPACTION_BYTES_LIMIT_SLOWDOWNS,
585 PENDING_COMPACTION_BYTES_LIMIT_STOPS,
7c673cae
FG
586 WRITE_STALLS_ENUM_MAX,
587 BYTES_FLUSHED,
588 BYTES_INGESTED_ADD_FILE,
589 INGESTED_NUM_FILES_TOTAL,
590 INGESTED_LEVEL0_NUM_FILES_TOTAL,
591 INGESTED_NUM_KEYS_TOTAL,
592 INTERNAL_CF_STATS_ENUM_MAX,
593 };
594
595 enum InternalDBStatsType {
596 WAL_FILE_BYTES,
597 WAL_FILE_SYNCED,
598 BYTES_WRITTEN,
599 NUMBER_KEYS_WRITTEN,
600 WRITE_DONE_BY_OTHER,
601 WRITE_DONE_BY_SELF,
602 WRITE_WITH_WAL,
603 WRITE_STALL_MICROS,
604 INTERNAL_DB_STATS_ENUM_MAX,
605 };
606
11fdf7f2 607 InternalStats(int /*num_levels*/, Env* /*env*/, ColumnFamilyData* /*cfd*/) {}
7c673cae
FG
608
609 struct CompactionStats {
610 uint64_t micros;
494da23a 611 uint64_t cpu_micros;
7c673cae
FG
612 uint64_t bytes_read_non_output_levels;
613 uint64_t bytes_read_output_level;
614 uint64_t bytes_written;
615 uint64_t bytes_moved;
616 int num_input_files_in_non_output_levels;
617 int num_input_files_in_output_level;
618 int num_output_files;
619 uint64_t num_input_records;
620 uint64_t num_dropped_records;
621 int count;
622
11fdf7f2 623 explicit CompactionStats() {}
7c673cae 624
11fdf7f2 625 explicit CompactionStats(CompactionReason /*reason*/, int /*c*/) {}
7c673cae 626
11fdf7f2 627 explicit CompactionStats(const CompactionStats& /*c*/) {}
7c673cae 628
11fdf7f2
TL
629 void Add(const CompactionStats& /*c*/) {}
630
631 void Subtract(const CompactionStats& /*c*/) {}
7c673cae
FG
632 };
633
494da23a
TL
634 void AddCompactionStats(int /*level*/, Env::Priority /*thread_pri*/,
635 const CompactionStats& /*stats*/) {}
7c673cae 636
11fdf7f2 637 void IncBytesMoved(int /*level*/, uint64_t /*amount*/) {}
7c673cae 638
11fdf7f2 639 void AddCFStats(InternalCFStatsType /*type*/, uint64_t /*value*/) {}
7c673cae 640
11fdf7f2
TL
641 void AddDBStats(InternalDBStatsType /*type*/, uint64_t /*value*/,
642 bool /*concurrent */ = false) {}
7c673cae 643
11fdf7f2 644 HistogramImpl* GetFileReadHist(int /*level*/) { return nullptr; }
7c673cae
FG
645
646 uint64_t GetBackgroundErrorCount() const { return 0; }
647
648 uint64_t BumpAndGetBackgroundErrorCount() { return 0; }
649
11fdf7f2
TL
650 bool GetStringProperty(const DBPropertyInfo& /*property_info*/,
651 const Slice& /*property*/, std::string* /*value*/) {
7c673cae
FG
652 return false;
653 }
654
11fdf7f2
TL
655 bool GetMapProperty(const DBPropertyInfo& /*property_info*/,
656 const Slice& /*property*/,
657 std::map<std::string, std::string>* /*value*/) {
7c673cae
FG
658 return false;
659 }
660
11fdf7f2
TL
661 bool GetIntProperty(const DBPropertyInfo& /*property_info*/, uint64_t* /*value*/,
662 DBImpl* /*db*/) const {
7c673cae
FG
663 return false;
664 }
665
11fdf7f2
TL
666 bool GetIntPropertyOutOfMutex(const DBPropertyInfo& /*property_info*/,
667 Version* /*version*/, uint64_t* /*value*/) const {
7c673cae
FG
668 return false;
669 }
670};
671#endif // !ROCKSDB_LITE
672
673} // namespace rocksdb