]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/include/rocksdb/perf_context.h
build: use dgit for download target
[ceph.git] / ceph / src / rocksdb / include / rocksdb / perf_context.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 5
11fdf7f2 6#pragma once
7c673cae
FG
7
8#include <stdint.h>
9#include <string>
10
11#include "rocksdb/perf_level.h"
12
13namespace rocksdb {
14
15// A thread local context for gathering performance counter efficiently
16// and transparently.
17// Use SetPerfLevel(PerfLevel::kEnableTime) to enable time stats.
18
19struct PerfContext {
20
21 void Reset(); // reset all performance counters to zero
22
23 std::string ToString(bool exclude_zero_counters = false) const;
24
25 uint64_t user_key_comparison_count; // total number of user key comparisons
26 uint64_t block_cache_hit_count; // total number of block cache hits
27 uint64_t block_read_count; // total number of block reads (with IO)
28 uint64_t block_read_byte; // total number of bytes from block reads
29 uint64_t block_read_time; // total nanos spent on block reads
30 uint64_t block_checksum_time; // total nanos spent on block checksum
31 uint64_t block_decompress_time; // total nanos spent on block decompression
11fdf7f2
TL
32
33 uint64_t get_read_bytes; // bytes for vals returned by Get
34 uint64_t multiget_read_bytes; // bytes for vals returned by MultiGet
35 uint64_t iter_read_bytes; // bytes for keys/vals decoded by iterator
36
7c673cae
FG
37 // total number of internal keys skipped over during iteration.
38 // There are several reasons for it:
39 // 1. when calling Next(), the iterator is in the position of the previous
40 // key, so that we'll need to skip it. It means this counter will always
41 // be incremented in Next().
42 // 2. when calling Next(), we need to skip internal entries for the previous
43 // keys that are overwritten.
44 // 3. when calling Next(), Seek() or SeekToFirst(), after previous key
45 // before calling Next(), the seek key in Seek() or the beginning for
46 // SeekToFirst(), there may be one or more deleted keys before the next
47 // valid key that the operation should place the iterator to. We need
48 // to skip both of the tombstone and updates hidden by the tombstones. The
49 // tombstones are not included in this counter, while previous updates
50 // hidden by the tombstones will be included here.
51 // 4. symmetric cases for Prev() and SeekToLast()
52 // internal_recent_skipped_count is not included in this counter.
53 //
54 uint64_t internal_key_skipped_count;
55 // Total number of deletes and single deletes skipped over during iteration
56 // When calling Next(), Seek() or SeekToFirst(), after previous position
57 // before calling Next(), the seek key in Seek() or the beginning for
58 // SeekToFirst(), there may be one or more deleted keys before the next valid
59 // key. Every deleted key is counted once. We don't recount here if there are
60 // still older updates invalidated by the tombstones.
61 //
62 uint64_t internal_delete_skipped_count;
63 // How many times iterators skipped over internal keys that are more recent
64 // than the snapshot that iterator is using.
65 //
66 uint64_t internal_recent_skipped_count;
67 // How many values were fed into merge operator by iterators.
68 //
69 uint64_t internal_merge_count;
70
71 uint64_t get_snapshot_time; // total nanos spent on getting snapshot
72 uint64_t get_from_memtable_time; // total nanos spent on querying memtables
73 uint64_t get_from_memtable_count; // number of mem tables queried
74 // total nanos spent after Get() finds a key
75 uint64_t get_post_process_time;
76 uint64_t get_from_output_files_time; // total nanos reading from output files
77 // total nanos spent on seeking memtable
78 uint64_t seek_on_memtable_time;
79 // number of seeks issued on memtable
80 // (including SeekForPrev but not SeekToFirst and SeekToLast)
81 uint64_t seek_on_memtable_count;
82 // number of Next()s issued on memtable
83 uint64_t next_on_memtable_count;
84 // number of Prev()s issued on memtable
85 uint64_t prev_on_memtable_count;
86 // total nanos spent on seeking child iters
87 uint64_t seek_child_seek_time;
88 // number of seek issued in child iterators
89 uint64_t seek_child_seek_count;
90 uint64_t seek_min_heap_time; // total nanos spent on the merge min heap
91 uint64_t seek_max_heap_time; // total nanos spent on the merge max heap
92 // total nanos spent on seeking the internal entries
93 uint64_t seek_internal_seek_time;
94 // total nanos spent on iterating internal entries to find the next user entry
95 uint64_t find_next_user_entry_time;
96
11fdf7f2
TL
97 // This group of stats provide a breakdown of time spent by Write().
98 // May be inaccurate when 2PC, two_write_queues or enable_pipelined_write
99 // are enabled.
100 //
7c673cae
FG
101 // total nanos spent on writing to WAL
102 uint64_t write_wal_time;
103 // total nanos spent on writing to mem tables
104 uint64_t write_memtable_time;
11fdf7f2 105 // total nanos spent on delaying or throttling write
7c673cae 106 uint64_t write_delay_time;
11fdf7f2
TL
107 // total nanos spent on switching memtable/wal and scheduling
108 // flushes/compactions.
109 uint64_t write_scheduling_flushes_compactions_time;
110 // total nanos spent on writing a record, excluding the above four things
7c673cae
FG
111 uint64_t write_pre_and_post_process_time;
112
11fdf7f2
TL
113 // time spent waiting for other threads of the batch group
114 uint64_t write_thread_wait_nanos;
115
116 // time spent on acquiring DB mutex.
117 uint64_t db_mutex_lock_nanos;
7c673cae
FG
118 // Time spent on waiting with a condition variable created with DB mutex.
119 uint64_t db_condition_wait_nanos;
120 // Time spent on merge operator.
121 uint64_t merge_operator_time_nanos;
122
123 // Time spent on reading index block from block cache or SST file
124 uint64_t read_index_block_nanos;
125 // Time spent on reading filter block from block cache or SST file
126 uint64_t read_filter_block_nanos;
127 // Time spent on creating data block iterator
128 uint64_t new_table_block_iter_nanos;
129 // Time spent on creating a iterator of an SST file.
130 uint64_t new_table_iterator_nanos;
131 // Time spent on seeking a key in data/index blocks
132 uint64_t block_seek_nanos;
133 // Time spent on finding or creating a table reader
134 uint64_t find_table_nanos;
135 // total number of mem table bloom hits
136 uint64_t bloom_memtable_hit_count;
137 // total number of mem table bloom misses
138 uint64_t bloom_memtable_miss_count;
139 // total number of SST table bloom hits
140 uint64_t bloom_sst_hit_count;
141 // total number of SST table bloom misses
142 uint64_t bloom_sst_miss_count;
143
11fdf7f2
TL
144 // Time spent waiting on key locks in transaction lock manager.
145 uint64_t key_lock_wait_time;
146 // number of times acquiring a lock was blocked by another transaction.
147 uint64_t key_lock_wait_count;
148
7c673cae
FG
149 // Total time spent in Env filesystem operations. These are only populated
150 // when TimedEnv is used.
151 uint64_t env_new_sequential_file_nanos;
152 uint64_t env_new_random_access_file_nanos;
153 uint64_t env_new_writable_file_nanos;
154 uint64_t env_reuse_writable_file_nanos;
155 uint64_t env_new_random_rw_file_nanos;
156 uint64_t env_new_directory_nanos;
157 uint64_t env_file_exists_nanos;
158 uint64_t env_get_children_nanos;
159 uint64_t env_get_children_file_attributes_nanos;
160 uint64_t env_delete_file_nanos;
161 uint64_t env_create_dir_nanos;
162 uint64_t env_create_dir_if_missing_nanos;
163 uint64_t env_delete_dir_nanos;
164 uint64_t env_get_file_size_nanos;
165 uint64_t env_get_file_modification_time_nanos;
166 uint64_t env_rename_file_nanos;
167 uint64_t env_link_file_nanos;
168 uint64_t env_lock_file_nanos;
169 uint64_t env_unlock_file_nanos;
170 uint64_t env_new_logger_nanos;
171};
172
11fdf7f2
TL
173// Get Thread-local PerfContext object pointer
174// if defined(NPERF_CONTEXT), then the pointer is not thread-local
175PerfContext* get_perf_context();
7c673cae
FG
176
177}