]>
Commit | Line | Data |
---|---|---|
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 | 5 | |
11fdf7f2 | 6 | #pragma once |
7c673cae FG |
7 | |
8 | #include <atomic> | |
9 | #include <cstddef> | |
10 | #include <cstdint> | |
494da23a | 11 | #include <map> |
7c673cae | 12 | #include <memory> |
494da23a | 13 | #include <string> |
7c673cae FG |
14 | #include <vector> |
15 | ||
1e59de90 | 16 | #include "rocksdb/customizable.h" |
7c673cae FG |
17 | #include "rocksdb/status.h" |
18 | ||
f67539c2 | 19 | namespace ROCKSDB_NAMESPACE { |
7c673cae FG |
20 | |
21 | /** | |
1e59de90 TL |
22 | * Keep adding tickers here. |
23 | * 1. Any ticker should be added immediately before TICKER_ENUM_MAX, taking | |
24 | * over its old value. | |
7c673cae | 25 | * 2. Add a readable string in TickersNameMap below for the newly added ticker. |
11fdf7f2 | 26 | * 3. Add a corresponding enum value to TickerType.java in the java API |
494da23a | 27 | * 4. Add the enum conversions from Java and C++ to portal.h's toJavaTickerType |
1e59de90 | 28 | * and toCppTickers |
7c673cae FG |
29 | */ |
30 | enum Tickers : uint32_t { | |
31 | // total block cache misses | |
32 | // REQUIRES: BLOCK_CACHE_MISS == BLOCK_CACHE_INDEX_MISS + | |
33 | // BLOCK_CACHE_FILTER_MISS + | |
34 | // BLOCK_CACHE_DATA_MISS; | |
35 | BLOCK_CACHE_MISS = 0, | |
36 | // total block cache hit | |
37 | // REQUIRES: BLOCK_CACHE_HIT == BLOCK_CACHE_INDEX_HIT + | |
38 | // BLOCK_CACHE_FILTER_HIT + | |
39 | // BLOCK_CACHE_DATA_HIT; | |
40 | BLOCK_CACHE_HIT, | |
41 | // # of blocks added to block cache. | |
42 | BLOCK_CACHE_ADD, | |
43 | // # of failures when adding blocks to block cache. | |
44 | BLOCK_CACHE_ADD_FAILURES, | |
45 | // # of times cache miss when accessing index block from block cache. | |
46 | BLOCK_CACHE_INDEX_MISS, | |
47 | // # of times cache hit when accessing index block from block cache. | |
48 | BLOCK_CACHE_INDEX_HIT, | |
49 | // # of index blocks added to block cache. | |
50 | BLOCK_CACHE_INDEX_ADD, | |
51 | // # of bytes of index blocks inserted into cache | |
52 | BLOCK_CACHE_INDEX_BYTES_INSERT, | |
53 | // # of bytes of index block erased from cache | |
54 | BLOCK_CACHE_INDEX_BYTES_EVICT, | |
55 | // # of times cache miss when accessing filter block from block cache. | |
56 | BLOCK_CACHE_FILTER_MISS, | |
57 | // # of times cache hit when accessing filter block from block cache. | |
58 | BLOCK_CACHE_FILTER_HIT, | |
59 | // # of filter blocks added to block cache. | |
60 | BLOCK_CACHE_FILTER_ADD, | |
61 | // # of bytes of bloom filter blocks inserted into cache | |
62 | BLOCK_CACHE_FILTER_BYTES_INSERT, | |
63 | // # of bytes of bloom filter block erased from cache | |
64 | BLOCK_CACHE_FILTER_BYTES_EVICT, | |
65 | // # of times cache miss when accessing data block from block cache. | |
66 | BLOCK_CACHE_DATA_MISS, | |
67 | // # of times cache hit when accessing data block from block cache. | |
68 | BLOCK_CACHE_DATA_HIT, | |
69 | // # of data blocks added to block cache. | |
70 | BLOCK_CACHE_DATA_ADD, | |
71 | // # of bytes of data blocks inserted into cache | |
72 | BLOCK_CACHE_DATA_BYTES_INSERT, | |
73 | // # of bytes read from cache. | |
74 | BLOCK_CACHE_BYTES_READ, | |
75 | // # of bytes written into cache. | |
76 | BLOCK_CACHE_BYTES_WRITE, | |
77 | ||
11fdf7f2 | 78 | // # of times bloom filter has avoided file reads, i.e., negatives. |
7c673cae | 79 | BLOOM_FILTER_USEFUL, |
11fdf7f2 TL |
80 | // # of times bloom FullFilter has not avoided the reads. |
81 | BLOOM_FILTER_FULL_POSITIVE, | |
82 | // # of times bloom FullFilter has not avoided the reads and data actually | |
83 | // exist. | |
84 | BLOOM_FILTER_FULL_TRUE_POSITIVE, | |
7c673cae | 85 | |
f67539c2 TL |
86 | BLOOM_FILTER_MICROS, |
87 | ||
7c673cae FG |
88 | // # persistent cache hit |
89 | PERSISTENT_CACHE_HIT, | |
90 | // # persistent cache miss | |
91 | PERSISTENT_CACHE_MISS, | |
92 | ||
93 | // # total simulation block cache hits | |
94 | SIM_BLOCK_CACHE_HIT, | |
95 | // # total simulation block cache misses | |
96 | SIM_BLOCK_CACHE_MISS, | |
97 | ||
98 | // # of memtable hits. | |
99 | MEMTABLE_HIT, | |
100 | // # of memtable misses. | |
101 | MEMTABLE_MISS, | |
102 | ||
103 | // # of Get() queries served by L0 | |
104 | GET_HIT_L0, | |
105 | // # of Get() queries served by L1 | |
106 | GET_HIT_L1, | |
107 | // # of Get() queries served by L2 and up | |
108 | GET_HIT_L2_AND_UP, | |
109 | ||
110 | /** | |
111 | * COMPACTION_KEY_DROP_* count the reasons for key drop during compaction | |
112 | * There are 4 reasons currently. | |
113 | */ | |
114 | COMPACTION_KEY_DROP_NEWER_ENTRY, // key was written with a newer value. | |
115 | // Also includes keys dropped for range del. | |
116 | COMPACTION_KEY_DROP_OBSOLETE, // The key is obsolete. | |
117 | COMPACTION_KEY_DROP_RANGE_DEL, // key was covered by a range tombstone. | |
118 | COMPACTION_KEY_DROP_USER, // user compaction function has dropped the key. | |
7c673cae | 119 | COMPACTION_RANGE_DEL_DROP_OBSOLETE, // all keys in range were deleted. |
11fdf7f2 TL |
120 | // Deletions obsoleted before bottom level due to file gap optimization. |
121 | COMPACTION_OPTIMIZED_DEL_DROP_OBSOLETE, | |
1e59de90 | 122 | // If a compaction was canceled in sfm to prevent ENOSPC |
11fdf7f2 | 123 | COMPACTION_CANCELLED, |
7c673cae FG |
124 | |
125 | // Number of keys written to the database via the Put and Write call's | |
126 | NUMBER_KEYS_WRITTEN, | |
127 | // Number of Keys read, | |
128 | NUMBER_KEYS_READ, | |
129 | // Number keys updated, if inplace update is enabled | |
130 | NUMBER_KEYS_UPDATED, | |
131 | // The number of uncompressed bytes issued by DB::Put(), DB::Delete(), | |
132 | // DB::Merge(), and DB::Write(). | |
133 | BYTES_WRITTEN, | |
134 | // The number of uncompressed bytes read from DB::Get(). It could be | |
135 | // either from memtables, cache, or table files. | |
136 | // For the number of logical bytes read from DB::MultiGet(), | |
137 | // please use NUMBER_MULTIGET_BYTES_READ. | |
138 | BYTES_READ, | |
139 | // The number of calls to seek/next/prev | |
140 | NUMBER_DB_SEEK, | |
141 | NUMBER_DB_NEXT, | |
142 | NUMBER_DB_PREV, | |
143 | // The number of calls to seek/next/prev that returned data | |
144 | NUMBER_DB_SEEK_FOUND, | |
145 | NUMBER_DB_NEXT_FOUND, | |
146 | NUMBER_DB_PREV_FOUND, | |
147 | // The number of uncompressed bytes read from an iterator. | |
148 | // Includes size of key and value. | |
149 | ITER_BYTES_READ, | |
150 | NO_FILE_CLOSES, | |
151 | NO_FILE_OPENS, | |
152 | NO_FILE_ERRORS, | |
153 | // DEPRECATED Time system had to wait to do LO-L1 compactions | |
154 | STALL_L0_SLOWDOWN_MICROS, | |
155 | // DEPRECATED Time system had to wait to move memtable to L1. | |
156 | STALL_MEMTABLE_COMPACTION_MICROS, | |
157 | // DEPRECATED write throttle because of too many files in L0 | |
158 | STALL_L0_NUM_FILES_MICROS, | |
159 | // Writer has to wait for compaction or flush to finish. | |
160 | STALL_MICROS, | |
161 | // The wait time for db mutex. | |
162 | // Disabled by default. To enable it set stats level to kAll | |
163 | DB_MUTEX_WAIT_MICROS, | |
164 | RATE_LIMIT_DELAY_MILLIS, | |
494da23a TL |
165 | // DEPRECATED number of iterators currently open |
166 | NO_ITERATORS, | |
7c673cae FG |
167 | |
168 | // Number of MultiGet calls, keys read, and bytes read | |
169 | NUMBER_MULTIGET_CALLS, | |
170 | NUMBER_MULTIGET_KEYS_READ, | |
171 | NUMBER_MULTIGET_BYTES_READ, | |
172 | ||
173 | // Number of deletes records that were not required to be | |
174 | // written to storage because key does not exist | |
175 | NUMBER_FILTERED_DELETES, | |
176 | NUMBER_MERGE_FAILURES, | |
177 | ||
178 | // number of times bloom was checked before creating iterator on a | |
179 | // file, and the number of times the check was useful in avoiding | |
180 | // iterator creation (and thus likely IOPs). | |
181 | BLOOM_FILTER_PREFIX_CHECKED, | |
182 | BLOOM_FILTER_PREFIX_USEFUL, | |
183 | ||
184 | // Number of times we had to reseek inside an iteration to skip | |
185 | // over large number of keys with same userkey. | |
186 | NUMBER_OF_RESEEKS_IN_ITERATION, | |
187 | ||
1e59de90 | 188 | // Record the number of calls to GetUpdatesSince. Useful to keep track of |
7c673cae FG |
189 | // transaction log iterator refreshes |
190 | GET_UPDATES_SINCE_CALLS, | |
191 | BLOCK_CACHE_COMPRESSED_MISS, // miss in the compressed block cache | |
192 | BLOCK_CACHE_COMPRESSED_HIT, // hit in the compressed block cache | |
11fdf7f2 | 193 | // Number of blocks added to compressed block cache |
7c673cae FG |
194 | BLOCK_CACHE_COMPRESSED_ADD, |
195 | // Number of failures when adding blocks to compressed block cache | |
196 | BLOCK_CACHE_COMPRESSED_ADD_FAILURES, | |
197 | WAL_FILE_SYNCED, // Number of times WAL sync is done | |
198 | WAL_FILE_BYTES, // Number of bytes written to WAL | |
199 | ||
200 | // Writes can be processed by requesting thread or by the thread at the | |
201 | // head of the writers queue. | |
202 | WRITE_DONE_BY_SELF, | |
203 | WRITE_DONE_BY_OTHER, // Equivalent to writes done for others | |
204 | WRITE_TIMEDOUT, // Number of writes ending up with timed-out. | |
205 | WRITE_WITH_WAL, // Number of Write calls that request WAL | |
206 | COMPACT_READ_BYTES, // Bytes read during compaction | |
207 | COMPACT_WRITE_BYTES, // Bytes written during compaction | |
208 | FLUSH_WRITE_BYTES, // Bytes written during flush | |
209 | ||
20effc67 TL |
210 | // Compaction read and write statistics broken down by CompactionReason |
211 | COMPACT_READ_BYTES_MARKED, | |
212 | COMPACT_READ_BYTES_PERIODIC, | |
213 | COMPACT_READ_BYTES_TTL, | |
214 | COMPACT_WRITE_BYTES_MARKED, | |
215 | COMPACT_WRITE_BYTES_PERIODIC, | |
216 | COMPACT_WRITE_BYTES_TTL, | |
217 | ||
7c673cae FG |
218 | // Number of table's properties loaded directly from file, without creating |
219 | // table reader object. | |
220 | NUMBER_DIRECT_LOAD_TABLE_PROPERTIES, | |
221 | NUMBER_SUPERVERSION_ACQUIRES, | |
222 | NUMBER_SUPERVERSION_RELEASES, | |
223 | NUMBER_SUPERVERSION_CLEANUPS, | |
224 | ||
225 | // # of compressions/decompressions executed | |
226 | NUMBER_BLOCK_COMPRESSED, | |
227 | NUMBER_BLOCK_DECOMPRESSED, | |
228 | ||
229 | NUMBER_BLOCK_NOT_COMPRESSED, | |
230 | MERGE_OPERATION_TOTAL_TIME, | |
231 | FILTER_OPERATION_TOTAL_TIME, | |
232 | ||
233 | // Row cache. | |
234 | ROW_CACHE_HIT, | |
235 | ROW_CACHE_MISS, | |
236 | ||
237 | // Read amplification statistics. | |
238 | // Read amplification can be calculated using this formula | |
239 | // (READ_AMP_TOTAL_READ_BYTES / READ_AMP_ESTIMATE_USEFUL_BYTES) | |
240 | // | |
241 | // REQUIRES: ReadOptions::read_amp_bytes_per_bit to be enabled | |
242 | READ_AMP_ESTIMATE_USEFUL_BYTES, // Estimate of total bytes actually used. | |
243 | READ_AMP_TOTAL_READ_BYTES, // Total size of loaded data blocks. | |
244 | ||
245 | // Number of refill intervals where rate limiter's bytes are fully consumed. | |
246 | NUMBER_RATE_LIMITER_DRAINS, | |
247 | ||
11fdf7f2 TL |
248 | // Number of internal keys skipped by Iterator |
249 | NUMBER_ITER_SKIP, | |
250 | ||
251 | // BlobDB specific stats | |
1e59de90 | 252 | // # of Put/PutTTL/PutUntil to BlobDB. Only applicable to legacy BlobDB. |
11fdf7f2 | 253 | BLOB_DB_NUM_PUT, |
1e59de90 | 254 | // # of Write to BlobDB. Only applicable to legacy BlobDB. |
11fdf7f2 | 255 | BLOB_DB_NUM_WRITE, |
1e59de90 | 256 | // # of Get to BlobDB. Only applicable to legacy BlobDB. |
11fdf7f2 | 257 | BLOB_DB_NUM_GET, |
1e59de90 | 258 | // # of MultiGet to BlobDB. Only applicable to legacy BlobDB. |
11fdf7f2 | 259 | BLOB_DB_NUM_MULTIGET, |
1e59de90 TL |
260 | // # of Seek/SeekToFirst/SeekToLast/SeekForPrev to BlobDB iterator. Only |
261 | // applicable to legacy BlobDB. | |
11fdf7f2 | 262 | BLOB_DB_NUM_SEEK, |
1e59de90 | 263 | // # of Next to BlobDB iterator. Only applicable to legacy BlobDB. |
11fdf7f2 | 264 | BLOB_DB_NUM_NEXT, |
1e59de90 | 265 | // # of Prev to BlobDB iterator. Only applicable to legacy BlobDB. |
11fdf7f2 | 266 | BLOB_DB_NUM_PREV, |
1e59de90 | 267 | // # of keys written to BlobDB. Only applicable to legacy BlobDB. |
11fdf7f2 | 268 | BLOB_DB_NUM_KEYS_WRITTEN, |
1e59de90 | 269 | // # of keys read from BlobDB. Only applicable to legacy BlobDB. |
11fdf7f2 | 270 | BLOB_DB_NUM_KEYS_READ, |
1e59de90 TL |
271 | // # of bytes (key + value) written to BlobDB. Only applicable to legacy |
272 | // BlobDB. | |
11fdf7f2 | 273 | BLOB_DB_BYTES_WRITTEN, |
1e59de90 TL |
274 | // # of bytes (keys + value) read from BlobDB. Only applicable to legacy |
275 | // BlobDB. | |
11fdf7f2 | 276 | BLOB_DB_BYTES_READ, |
1e59de90 TL |
277 | // # of keys written by BlobDB as non-TTL inlined value. Only applicable to |
278 | // legacy BlobDB. | |
11fdf7f2 | 279 | BLOB_DB_WRITE_INLINED, |
1e59de90 TL |
280 | // # of keys written by BlobDB as TTL inlined value. Only applicable to legacy |
281 | // BlobDB. | |
11fdf7f2 | 282 | BLOB_DB_WRITE_INLINED_TTL, |
1e59de90 TL |
283 | // # of keys written by BlobDB as non-TTL blob value. Only applicable to |
284 | // legacy BlobDB. | |
11fdf7f2 | 285 | BLOB_DB_WRITE_BLOB, |
1e59de90 TL |
286 | // # of keys written by BlobDB as TTL blob value. Only applicable to legacy |
287 | // BlobDB. | |
11fdf7f2 TL |
288 | BLOB_DB_WRITE_BLOB_TTL, |
289 | // # of bytes written to blob file. | |
290 | BLOB_DB_BLOB_FILE_BYTES_WRITTEN, | |
291 | // # of bytes read from blob file. | |
292 | BLOB_DB_BLOB_FILE_BYTES_READ, | |
293 | // # of times a blob files being synced. | |
294 | BLOB_DB_BLOB_FILE_SYNCED, | |
295 | // # of blob index evicted from base DB by BlobDB compaction filter because | |
1e59de90 | 296 | // of expiration. Only applicable to legacy BlobDB. |
11fdf7f2 TL |
297 | BLOB_DB_BLOB_INDEX_EXPIRED_COUNT, |
298 | // size of blob index evicted from base DB by BlobDB compaction filter | |
1e59de90 | 299 | // because of expiration. Only applicable to legacy BlobDB. |
11fdf7f2 TL |
300 | BLOB_DB_BLOB_INDEX_EXPIRED_SIZE, |
301 | // # of blob index evicted from base DB by BlobDB compaction filter because | |
1e59de90 | 302 | // of corresponding file deleted. Only applicable to legacy BlobDB. |
11fdf7f2 TL |
303 | BLOB_DB_BLOB_INDEX_EVICTED_COUNT, |
304 | // size of blob index evicted from base DB by BlobDB compaction filter | |
1e59de90 | 305 | // because of corresponding file deleted. Only applicable to legacy BlobDB. |
11fdf7f2 | 306 | BLOB_DB_BLOB_INDEX_EVICTED_SIZE, |
1e59de90 TL |
307 | // # of blob files that were obsoleted by garbage collection. Only applicable |
308 | // to legacy BlobDB. | |
11fdf7f2 | 309 | BLOB_DB_GC_NUM_FILES, |
1e59de90 TL |
310 | // # of blob files generated by garbage collection. Only applicable to legacy |
311 | // BlobDB. | |
11fdf7f2 | 312 | BLOB_DB_GC_NUM_NEW_FILES, |
1e59de90 | 313 | // # of BlobDB garbage collection failures. Only applicable to legacy BlobDB. |
11fdf7f2 | 314 | BLOB_DB_GC_FAILURES, |
f67539c2 TL |
315 | // # of keys dropped by BlobDB garbage collection because they had been |
316 | // overwritten. DEPRECATED. | |
11fdf7f2 | 317 | BLOB_DB_GC_NUM_KEYS_OVERWRITTEN, |
f67539c2 TL |
318 | // # of keys dropped by BlobDB garbage collection because of expiration. |
319 | // DEPRECATED. | |
11fdf7f2 TL |
320 | BLOB_DB_GC_NUM_KEYS_EXPIRED, |
321 | // # of keys relocated to new blob file by garbage collection. | |
322 | BLOB_DB_GC_NUM_KEYS_RELOCATED, | |
f67539c2 TL |
323 | // # of bytes dropped by BlobDB garbage collection because they had been |
324 | // overwritten. DEPRECATED. | |
11fdf7f2 | 325 | BLOB_DB_GC_BYTES_OVERWRITTEN, |
f67539c2 TL |
326 | // # of bytes dropped by BlobDB garbage collection because of expiration. |
327 | // DEPRECATED. | |
11fdf7f2 TL |
328 | BLOB_DB_GC_BYTES_EXPIRED, |
329 | // # of bytes relocated to new blob file by garbage collection. | |
330 | BLOB_DB_GC_BYTES_RELOCATED, | |
1e59de90 TL |
331 | // # of blob files evicted because of BlobDB is full. Only applicable to |
332 | // legacy BlobDB. | |
11fdf7f2 | 333 | BLOB_DB_FIFO_NUM_FILES_EVICTED, |
1e59de90 TL |
334 | // # of keys in the blob files evicted because of BlobDB is full. Only |
335 | // applicable to legacy BlobDB. | |
11fdf7f2 | 336 | BLOB_DB_FIFO_NUM_KEYS_EVICTED, |
1e59de90 TL |
337 | // # of bytes in the blob files evicted because of BlobDB is full. Only |
338 | // applicable to legacy BlobDB. | |
11fdf7f2 TL |
339 | BLOB_DB_FIFO_BYTES_EVICTED, |
340 | ||
494da23a | 341 | // These counters indicate a performance issue in WritePrepared transactions. |
11fdf7f2 TL |
342 | // We should not seem them ticking them much. |
343 | // # of times prepare_mutex_ is acquired in the fast path. | |
344 | TXN_PREPARE_MUTEX_OVERHEAD, | |
345 | // # of times old_commit_map_mutex_ is acquired in the fast path. | |
346 | TXN_OLD_COMMIT_MAP_MUTEX_OVERHEAD, | |
347 | // # of times we checked a batch for duplicate keys. | |
348 | TXN_DUPLICATE_KEY_OVERHEAD, | |
349 | // # of times snapshot_mutex_ is acquired in the fast path. | |
350 | TXN_SNAPSHOT_MUTEX_OVERHEAD, | |
f67539c2 TL |
351 | // # of times ::Get returned TryAgain due to expired snapshot seq |
352 | TXN_GET_TRY_AGAIN, | |
11fdf7f2 | 353 | |
494da23a TL |
354 | // Number of keys actually found in MultiGet calls (vs number requested by |
355 | // caller) | |
11fdf7f2 TL |
356 | // NUMBER_MULTIGET_KEYS_READ gives the number requested by caller |
357 | NUMBER_MULTIGET_KEYS_FOUND, | |
494da23a TL |
358 | |
359 | NO_ITERATOR_CREATED, // number of iterators created | |
360 | NO_ITERATOR_DELETED, // number of iterators deleted | |
361 | ||
362 | BLOCK_CACHE_COMPRESSION_DICT_MISS, | |
363 | BLOCK_CACHE_COMPRESSION_DICT_HIT, | |
364 | BLOCK_CACHE_COMPRESSION_DICT_ADD, | |
365 | BLOCK_CACHE_COMPRESSION_DICT_BYTES_INSERT, | |
366 | BLOCK_CACHE_COMPRESSION_DICT_BYTES_EVICT, | |
20effc67 TL |
367 | |
368 | // # of blocks redundantly inserted into block cache. | |
369 | // REQUIRES: BLOCK_CACHE_ADD_REDUNDANT <= BLOCK_CACHE_ADD | |
370 | BLOCK_CACHE_ADD_REDUNDANT, | |
371 | // # of index blocks redundantly inserted into block cache. | |
372 | // REQUIRES: BLOCK_CACHE_INDEX_ADD_REDUNDANT <= BLOCK_CACHE_INDEX_ADD | |
373 | BLOCK_CACHE_INDEX_ADD_REDUNDANT, | |
374 | // # of filter blocks redundantly inserted into block cache. | |
375 | // REQUIRES: BLOCK_CACHE_FILTER_ADD_REDUNDANT <= BLOCK_CACHE_FILTER_ADD | |
376 | BLOCK_CACHE_FILTER_ADD_REDUNDANT, | |
377 | // # of data blocks redundantly inserted into block cache. | |
378 | // REQUIRES: BLOCK_CACHE_DATA_ADD_REDUNDANT <= BLOCK_CACHE_DATA_ADD | |
379 | BLOCK_CACHE_DATA_ADD_REDUNDANT, | |
380 | // # of dict blocks redundantly inserted into block cache. | |
381 | // REQUIRES: BLOCK_CACHE_COMPRESSION_DICT_ADD_REDUNDANT | |
382 | // <= BLOCK_CACHE_COMPRESSION_DICT_ADD | |
383 | BLOCK_CACHE_COMPRESSION_DICT_ADD_REDUNDANT, | |
384 | ||
385 | // # of files marked as trash by sst file manager and will be deleted | |
386 | // later by background thread. | |
387 | FILES_MARKED_TRASH, | |
388 | // # of files deleted immediately by sst file manger through delete scheduler. | |
389 | FILES_DELETED_IMMEDIATELY, | |
390 | ||
1e59de90 TL |
391 | // The counters for error handler, not that, bg_io_error is the subset of |
392 | // bg_error and bg_retryable_io_error is the subset of bg_io_error | |
393 | ERROR_HANDLER_BG_ERROR_COUNT, | |
394 | ERROR_HANDLER_BG_IO_ERROR_COUNT, | |
395 | ERROR_HANDLER_BG_RETRYABLE_IO_ERROR_COUNT, | |
396 | ERROR_HANDLER_AUTORESUME_COUNT, | |
397 | ERROR_HANDLER_AUTORESUME_RETRY_TOTAL_COUNT, | |
398 | ERROR_HANDLER_AUTORESUME_SUCCESS_COUNT, | |
399 | ||
400 | // Statistics for memtable garbage collection: | |
401 | // Raw bytes of data (payload) present on memtable at flush time. | |
402 | MEMTABLE_PAYLOAD_BYTES_AT_FLUSH, | |
403 | // Outdated bytes of data present on memtable at flush time. | |
404 | MEMTABLE_GARBAGE_BYTES_AT_FLUSH, | |
405 | ||
406 | // Secondary cache statistics | |
407 | SECONDARY_CACHE_HITS, | |
408 | ||
409 | // Bytes read by `VerifyChecksum()` and `VerifyFileChecksums()` APIs. | |
410 | VERIFY_CHECKSUM_READ_BYTES, | |
411 | ||
412 | // Bytes read/written while creating backups | |
413 | BACKUP_READ_BYTES, | |
414 | BACKUP_WRITE_BYTES, | |
415 | ||
416 | // Remote compaction read/write statistics | |
417 | REMOTE_COMPACT_READ_BYTES, | |
418 | REMOTE_COMPACT_WRITE_BYTES, | |
419 | ||
420 | // Tiered storage related statistics | |
421 | HOT_FILE_READ_BYTES, | |
422 | WARM_FILE_READ_BYTES, | |
423 | COLD_FILE_READ_BYTES, | |
424 | HOT_FILE_READ_COUNT, | |
425 | WARM_FILE_READ_COUNT, | |
426 | COLD_FILE_READ_COUNT, | |
427 | ||
428 | // Last level and non-last level read statistics | |
429 | LAST_LEVEL_READ_BYTES, | |
430 | LAST_LEVEL_READ_COUNT, | |
431 | NON_LAST_LEVEL_READ_BYTES, | |
432 | NON_LAST_LEVEL_READ_COUNT, | |
433 | ||
434 | BLOCK_CHECKSUM_COMPUTE_COUNT, | |
435 | MULTIGET_COROUTINE_COUNT, | |
436 | ||
437 | // Integrated BlobDB specific stats | |
438 | // # of times cache miss when accessing blob from blob cache. | |
439 | BLOB_DB_CACHE_MISS, | |
440 | // # of times cache hit when accessing blob from blob cache. | |
441 | BLOB_DB_CACHE_HIT, | |
442 | // # of data blocks added to blob cache. | |
443 | BLOB_DB_CACHE_ADD, | |
444 | // # of failures when adding blobs to blob cache. | |
445 | BLOB_DB_CACHE_ADD_FAILURES, | |
446 | // # of bytes read from blob cache. | |
447 | BLOB_DB_CACHE_BYTES_READ, | |
448 | // # of bytes written into blob cache. | |
449 | BLOB_DB_CACHE_BYTES_WRITE, | |
450 | ||
451 | // Time spent in the ReadAsync file system call | |
452 | READ_ASYNC_MICROS, | |
453 | // Number of errors returned to the async read callback | |
454 | ASYNC_READ_ERROR_COUNT, | |
455 | ||
7c673cae FG |
456 | TICKER_ENUM_MAX |
457 | }; | |
458 | ||
459 | // The order of items listed in Tickers should be the same as | |
460 | // the order listed in TickersNameMap | |
494da23a | 461 | extern const std::vector<std::pair<Tickers, std::string>> TickersNameMap; |
7c673cae FG |
462 | |
463 | /** | |
464 | * Keep adding histogram's here. | |
11fdf7f2 | 465 | * Any histogram should have value less than HISTOGRAM_ENUM_MAX |
7c673cae FG |
466 | * Add a new Histogram by assigning it the current value of HISTOGRAM_ENUM_MAX |
467 | * Add a string representation in HistogramsNameMap below | |
468 | * And increment HISTOGRAM_ENUM_MAX | |
11fdf7f2 | 469 | * Add a corresponding enum value to HistogramType.java in the java API |
7c673cae FG |
470 | */ |
471 | enum Histograms : uint32_t { | |
472 | DB_GET = 0, | |
473 | DB_WRITE, | |
474 | COMPACTION_TIME, | |
494da23a | 475 | COMPACTION_CPU_TIME, |
7c673cae FG |
476 | SUBCOMPACTION_SETUP_TIME, |
477 | TABLE_SYNC_MICROS, | |
478 | COMPACTION_OUTFILE_SYNC_MICROS, | |
479 | WAL_FILE_SYNC_MICROS, | |
480 | MANIFEST_FILE_SYNC_MICROS, | |
481 | // TIME SPENT IN IO DURING TABLE OPEN | |
482 | TABLE_OPEN_IO_MICROS, | |
483 | DB_MULTIGET, | |
484 | READ_BLOCK_COMPACTION_MICROS, | |
485 | READ_BLOCK_GET_MICROS, | |
486 | WRITE_RAW_BLOCK_MICROS, | |
487 | STALL_L0_SLOWDOWN_COUNT, | |
488 | STALL_MEMTABLE_COMPACTION_COUNT, | |
489 | STALL_L0_NUM_FILES_COUNT, | |
490 | HARD_RATE_LIMIT_DELAY_COUNT, | |
491 | SOFT_RATE_LIMIT_DELAY_COUNT, | |
492 | NUM_FILES_IN_SINGLE_COMPACTION, | |
493 | DB_SEEK, | |
494 | WRITE_STALL, | |
495 | SST_READ_MICROS, | |
496 | // The number of subcompactions actually scheduled during a compaction | |
497 | NUM_SUBCOMPACTIONS_SCHEDULED, | |
498 | // Value size distribution in each operation | |
499 | BYTES_PER_READ, | |
500 | BYTES_PER_WRITE, | |
501 | BYTES_PER_MULTIGET, | |
502 | ||
503 | // number of bytes compressed/decompressed | |
504 | // number of bytes is when uncompressed; i.e. before/after respectively | |
505 | BYTES_COMPRESSED, | |
506 | BYTES_DECOMPRESSED, | |
507 | COMPRESSION_TIMES_NANOS, | |
508 | DECOMPRESSION_TIMES_NANOS, | |
11fdf7f2 TL |
509 | // Number of merge operands passed to the merge operator in user read |
510 | // requests. | |
511 | READ_NUM_MERGE_OPERANDS, | |
512 | ||
513 | // BlobDB specific stats | |
1e59de90 | 514 | // Size of keys written to BlobDB. Only applicable to legacy BlobDB. |
11fdf7f2 | 515 | BLOB_DB_KEY_SIZE, |
1e59de90 | 516 | // Size of values written to BlobDB. Only applicable to legacy BlobDB. |
11fdf7f2 | 517 | BLOB_DB_VALUE_SIZE, |
1e59de90 TL |
518 | // BlobDB Put/PutWithTTL/PutUntil/Write latency. Only applicable to legacy |
519 | // BlobDB. | |
11fdf7f2 | 520 | BLOB_DB_WRITE_MICROS, |
1e59de90 | 521 | // BlobDB Get latency. Only applicable to legacy BlobDB. |
11fdf7f2 | 522 | BLOB_DB_GET_MICROS, |
1e59de90 | 523 | // BlobDB MultiGet latency. Only applicable to legacy BlobDB. |
11fdf7f2 | 524 | BLOB_DB_MULTIGET_MICROS, |
1e59de90 TL |
525 | // BlobDB Seek/SeekToFirst/SeekToLast/SeekForPrev latency. Only applicable to |
526 | // legacy BlobDB. | |
11fdf7f2 | 527 | BLOB_DB_SEEK_MICROS, |
1e59de90 | 528 | // BlobDB Next latency. Only applicable to legacy BlobDB. |
11fdf7f2 | 529 | BLOB_DB_NEXT_MICROS, |
1e59de90 | 530 | // BlobDB Prev latency. Only applicable to legacy BlobDB. |
11fdf7f2 TL |
531 | BLOB_DB_PREV_MICROS, |
532 | // Blob file write latency. | |
533 | BLOB_DB_BLOB_FILE_WRITE_MICROS, | |
534 | // Blob file read latency. | |
535 | BLOB_DB_BLOB_FILE_READ_MICROS, | |
536 | // Blob file sync latency. | |
537 | BLOB_DB_BLOB_FILE_SYNC_MICROS, | |
f67539c2 | 538 | // BlobDB garbage collection time. DEPRECATED. |
11fdf7f2 TL |
539 | BLOB_DB_GC_MICROS, |
540 | // BlobDB compression time. | |
541 | BLOB_DB_COMPRESSION_MICROS, | |
542 | // BlobDB decompression time. | |
543 | BLOB_DB_DECOMPRESSION_MICROS, | |
544 | // Time spent flushing memtable to disk | |
545 | FLUSH_TIME, | |
f67539c2 | 546 | SST_BATCH_SIZE, |
7c673cae | 547 | |
20effc67 TL |
548 | // MultiGet stats logged per level |
549 | // Num of index and filter blocks read from file system per level. | |
550 | NUM_INDEX_AND_FILTER_BLOCKS_READ_PER_LEVEL, | |
551 | // Num of data blocks read from file system per level. | |
1e59de90 | 552 | // Obsolete |
20effc67 TL |
553 | NUM_DATA_BLOCKS_READ_PER_LEVEL, |
554 | // Num of sst files read from file system per level. | |
555 | NUM_SST_READ_PER_LEVEL, | |
556 | ||
1e59de90 TL |
557 | // Error handler statistics |
558 | ERROR_HANDLER_AUTORESUME_RETRY_COUNT, | |
559 | ||
560 | // Stats related to asynchronous read requests. | |
561 | ASYNC_READ_BYTES, | |
562 | POLL_WAIT_MICROS, | |
563 | ||
564 | // Number of prefetched bytes discarded by RocksDB. | |
565 | PREFETCHED_BYTES_DISCARDED, | |
566 | ||
567 | // Number of IOs issued in parallel in a MultiGet batch | |
568 | MULTIGET_IO_BATCH_SIZE, | |
569 | ||
570 | // Number of levels requiring IO for MultiGet | |
571 | NUM_LEVEL_READ_PER_MULTIGET, | |
572 | ||
573 | // Wait time for aborting async read in FilePrefetchBuffer destructor | |
574 | ASYNC_PREFETCH_ABORT_MICROS, | |
575 | ||
494da23a | 576 | HISTOGRAM_ENUM_MAX, |
7c673cae FG |
577 | }; |
578 | ||
494da23a | 579 | extern const std::vector<std::pair<Histograms, std::string>> HistogramsNameMap; |
7c673cae FG |
580 | |
581 | struct HistogramData { | |
582 | double median; | |
583 | double percentile95; | |
584 | double percentile99; | |
585 | double average; | |
586 | double standard_deviation; | |
587 | // zero-initialize new members since old Statistics::histogramData() | |
588 | // implementations won't write them. | |
589 | double max = 0.0; | |
11fdf7f2 TL |
590 | uint64_t count = 0; |
591 | uint64_t sum = 0; | |
494da23a | 592 | double min = 0.0; |
7c673cae FG |
593 | }; |
594 | ||
f67539c2 TL |
595 | // StatsLevel can be used to reduce statistics overhead by skipping certain |
596 | // types of stats in the stats collection process. | |
597 | // Usage: | |
598 | // options.statistics->set_stats_level(StatsLevel::kExceptTimeForMutex); | |
494da23a | 599 | enum StatsLevel : uint8_t { |
20effc67 TL |
600 | // Disable all metrics |
601 | kDisableAll, | |
602 | // Disable tickers | |
603 | kExceptTickers = kDisableAll, | |
494da23a TL |
604 | // Disable timer stats, and skip histogram stats |
605 | kExceptHistogramOrTimers, | |
606 | // Skip timer stats | |
607 | kExceptTimers, | |
7c673cae FG |
608 | // Collect all stats except time inside mutex lock AND time spent on |
609 | // compression. | |
610 | kExceptDetailedTimers, | |
611 | // Collect all stats except the counters requiring to get time inside the | |
612 | // mutex lock. | |
613 | kExceptTimeForMutex, | |
614 | // Collect all stats, including measuring duration of mutex operations. | |
615 | // If getting time is expensive on the platform to run, it can | |
616 | // reduce scalability to more threads, especially for writes. | |
617 | kAll, | |
618 | }; | |
619 | ||
f67539c2 TL |
620 | // Analyze the performance of a db by providing cumulative stats over time. |
621 | // Usage: | |
622 | // Options options; | |
623 | // options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics(); | |
624 | // Status s = DB::Open(options, kDBPath, &db); | |
625 | // ... | |
626 | // options.statistics->getTickerCount(NUMBER_BLOCK_COMPRESSED); | |
627 | // HistogramData hist; | |
628 | // options.statistics->histogramData(FLUSH_TIME, &hist); | |
1e59de90 TL |
629 | // |
630 | // Exceptions MUST NOT propagate out of overridden functions into RocksDB, | |
631 | // because RocksDB is not exception-safe. This could cause undefined behavior | |
632 | // including data loss, unreported corruption, deadlocks, and more. | |
633 | class Statistics : public Customizable { | |
7c673cae | 634 | public: |
1e59de90 | 635 | ~Statistics() override {} |
f67539c2 | 636 | static const char* Type() { return "Statistics"; } |
1e59de90 TL |
637 | static Status CreateFromString(const ConfigOptions& opts, |
638 | const std::string& value, | |
639 | std::shared_ptr<Statistics>* result); | |
640 | // Default name of empty, for backwards compatibility. Derived classes should | |
641 | // override this method. | |
642 | // This default implementation will likely be removed in a future release | |
643 | const char* Name() const override { return ""; } | |
7c673cae FG |
644 | virtual uint64_t getTickerCount(uint32_t tickerType) const = 0; |
645 | virtual void histogramData(uint32_t type, | |
646 | HistogramData* const data) const = 0; | |
11fdf7f2 | 647 | virtual std::string getHistogramString(uint32_t /*type*/) const { return ""; } |
7c673cae FG |
648 | virtual void recordTick(uint32_t tickerType, uint64_t count = 0) = 0; |
649 | virtual void setTickerCount(uint32_t tickerType, uint64_t count) = 0; | |
650 | virtual uint64_t getAndResetTickerCount(uint32_t tickerType) = 0; | |
494da23a TL |
651 | virtual void reportTimeToHistogram(uint32_t histogramType, uint64_t time) { |
652 | if (get_stats_level() <= StatsLevel::kExceptTimers) { | |
653 | return; | |
654 | } | |
655 | recordInHistogram(histogramType, time); | |
656 | } | |
657 | // The function is here only for backward compatibility reason. | |
658 | // Users implementing their own Statistics class should override | |
659 | // recordInHistogram() instead and leave measureTime() as it is. | |
660 | virtual void measureTime(uint32_t /*histogramType*/, uint64_t /*time*/) { | |
661 | // This is not supposed to be called. | |
662 | assert(false); | |
663 | } | |
664 | virtual void recordInHistogram(uint32_t histogramType, uint64_t time) { | |
665 | // measureTime() is the old and inaccurate function name. | |
666 | // To keep backward compatible. If users implement their own | |
f67539c2 | 667 | // statistics, which overrides measureTime() but doesn't override |
494da23a TL |
668 | // this function. We forward to measureTime(). |
669 | measureTime(histogramType, time); | |
670 | } | |
7c673cae FG |
671 | |
672 | // Resets all ticker and histogram stats | |
494da23a | 673 | virtual Status Reset() { return Status::NotSupported("Not implemented"); } |
7c673cae | 674 | |
1e59de90 TL |
675 | #ifndef ROCKSDB_LITE |
676 | using Customizable::ToString; | |
677 | #endif // ROCKSDB_LITE | |
678 | // String representation of the statistic object. Must be thread-safe. | |
7c673cae FG |
679 | virtual std::string ToString() const { |
680 | // Do nothing by default | |
681 | return std::string("ToString(): not implemented"); | |
682 | } | |
683 | ||
494da23a TL |
684 | virtual bool getTickerMap(std::map<std::string, uint64_t>*) const { |
685 | // Do nothing by default | |
686 | return false; | |
f67539c2 | 687 | } |
494da23a | 688 | |
7c673cae FG |
689 | // Override this function to disable particular histogram collection |
690 | virtual bool HistEnabledForType(uint32_t type) const { | |
691 | return type < HISTOGRAM_ENUM_MAX; | |
692 | } | |
494da23a TL |
693 | void set_stats_level(StatsLevel sl) { |
694 | stats_level_.store(sl, std::memory_order_relaxed); | |
695 | } | |
696 | StatsLevel get_stats_level() const { | |
697 | return stats_level_.load(std::memory_order_relaxed); | |
698 | } | |
7c673cae | 699 | |
494da23a TL |
700 | private: |
701 | std::atomic<StatsLevel> stats_level_{kExceptDetailedTimers}; | |
7c673cae FG |
702 | }; |
703 | ||
704 | // Create a concrete DBStatistics object | |
705 | std::shared_ptr<Statistics> CreateDBStatistics(); | |
706 | ||
f67539c2 | 707 | } // namespace ROCKSDB_NAMESPACE |