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