]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/monitoring/iostats_context_imp.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rocksdb / monitoring / iostats_context_imp.h
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 #include "monitoring/perf_step_timer.h"
8 #include "rocksdb/iostats_context.h"
9
10 #if !defined(NIOSTATS_CONTEXT)
11 namespace ROCKSDB_NAMESPACE {
12 extern thread_local IOStatsContext iostats_context;
13 } // namespace ROCKSDB_NAMESPACE
14
15 // increment a specific counter by the specified value
16 #define IOSTATS_ADD(metric, value) \
17 if (!iostats_context.disable_iostats) { \
18 iostats_context.metric += value; \
19 }
20
21 // reset a specific counter to zero
22 #define IOSTATS_RESET(metric) (iostats_context.metric = 0)
23
24 // reset all counters to zero
25 #define IOSTATS_RESET_ALL() (iostats_context.Reset())
26
27 #define IOSTATS_SET_THREAD_POOL_ID(value) \
28 (iostats_context.thread_pool_id = value)
29
30 #define IOSTATS_THREAD_POOL_ID() (iostats_context.thread_pool_id)
31
32 #define IOSTATS(metric) (iostats_context.metric)
33
34 // Declare and set start time of the timer
35 #define IOSTATS_TIMER_GUARD(metric) \
36 PerfStepTimer iostats_step_timer_##metric(&(iostats_context.metric)); \
37 iostats_step_timer_##metric.Start();
38
39 // Declare and set start time of the timer
40 #define IOSTATS_CPU_TIMER_GUARD(metric, clock) \
41 PerfStepTimer iostats_step_timer_##metric( \
42 &(iostats_context.metric), clock, true, \
43 PerfLevel::kEnableTimeAndCPUTimeExceptForMutex); \
44 iostats_step_timer_##metric.Start();
45
46 #define IOSTATS_SET_DISABLE(disable) (iostats_context.disable_iostats = disable)
47
48 #else // !NIOSTATS_CONTEXT
49
50 #define IOSTATS_ADD(metric, value)
51 #define IOSTATS_ADD_IF_POSITIVE(metric, value)
52 #define IOSTATS_RESET(metric)
53 #define IOSTATS_RESET_ALL()
54 #define IOSTATS_SET_THREAD_POOL_ID(value)
55 #define IOSTATS_THREAD_POOL_ID()
56 #define IOSTATS(metric) 0
57 #define IOSTATS_SET_DISABLE(disable)
58
59 #define IOSTATS_TIMER_GUARD(metric)
60 #define IOSTATS_CPU_TIMER_GUARD(metric, clock) static_cast<void>(clock)
61
62 #endif // !NIOSTATS_CONTEXT