Still use SystemClock* instead of shared_ptr in StepPerfTimer (#8006)
Summary: This is likely a temp fix before we figure out a better way. PerfStepTimer is used intensively in certain benchmarking/testings. https://github.com/facebook/rocksdb/issues/7858 stores a `shared_ptr` to system clock in PerfStepTimer which gets created each time a `PerfStepTimer` object is created. The atomic operations in `shared_ptr` may add overhead in CPU cycles. Therefore, we change it back to a raw `SystemClock*` for now. Pull Request resolved: https://github.com/facebook/rocksdb/pull/8006 Test Plan: make check Reviewed By: pdillinger Differential Revision: D26703560 Pulled By: riversand963 fbshipit-source-id: 519d0769b28da2334bea7d86c848fcc26ee8a17f
This commit is contained in:
parent
a8b3b9a20c
commit
9fdc9fbeea
@ -40,7 +40,7 @@ extern __thread IOStatsContext iostats_context;
|
|||||||
// Declare and set start time of the timer
|
// Declare and set start time of the timer
|
||||||
#define IOSTATS_CPU_TIMER_GUARD(metric, clock) \
|
#define IOSTATS_CPU_TIMER_GUARD(metric, clock) \
|
||||||
PerfStepTimer iostats_step_timer_##metric( \
|
PerfStepTimer iostats_step_timer_##metric( \
|
||||||
&(iostats_context.metric), clock, true, \
|
&(iostats_context.metric), clock.get(), true, \
|
||||||
PerfLevel::kEnableTimeAndCPUTimeExceptForMutex); \
|
PerfLevel::kEnableTimeAndCPUTimeExceptForMutex); \
|
||||||
iostats_step_timer_##metric.Start();
|
iostats_step_timer_##metric.Start();
|
||||||
|
|
||||||
|
@ -46,14 +46,14 @@ extern thread_local PerfContext perf_context;
|
|||||||
perf_step_timer_##metric.Start();
|
perf_step_timer_##metric.Start();
|
||||||
|
|
||||||
// Declare and set start time of the timer
|
// Declare and set start time of the timer
|
||||||
#define PERF_TIMER_GUARD_WITH_CLOCK(metric, clock) \
|
#define PERF_TIMER_GUARD_WITH_CLOCK(metric, clock) \
|
||||||
PerfStepTimer perf_step_timer_##metric(&(perf_context.metric), clock); \
|
PerfStepTimer perf_step_timer_##metric(&(perf_context.metric), clock.get()); \
|
||||||
perf_step_timer_##metric.Start();
|
perf_step_timer_##metric.Start();
|
||||||
|
|
||||||
// Declare and set start time of the timer
|
// Declare and set start time of the timer
|
||||||
#define PERF_CPU_TIMER_GUARD(metric, clock) \
|
#define PERF_CPU_TIMER_GUARD(metric, clock) \
|
||||||
PerfStepTimer perf_step_timer_##metric( \
|
PerfStepTimer perf_step_timer_##metric( \
|
||||||
&(perf_context.metric), clock, true, \
|
&(perf_context.metric), clock.get(), true, \
|
||||||
PerfLevel::kEnableTimeAndCPUTimeExceptForMutex); \
|
PerfLevel::kEnableTimeAndCPUTimeExceptForMutex); \
|
||||||
perf_step_timer_##metric.Start();
|
perf_step_timer_##metric.Start();
|
||||||
|
|
||||||
|
@ -13,14 +13,13 @@ namespace ROCKSDB_NAMESPACE {
|
|||||||
class PerfStepTimer {
|
class PerfStepTimer {
|
||||||
public:
|
public:
|
||||||
explicit PerfStepTimer(
|
explicit PerfStepTimer(
|
||||||
uint64_t* metric, const std::shared_ptr<SystemClock>& clock = nullptr,
|
uint64_t* metric, SystemClock* clock = nullptr, bool use_cpu_time = false,
|
||||||
bool use_cpu_time = false,
|
|
||||||
PerfLevel enable_level = PerfLevel::kEnableTimeExceptForMutex,
|
PerfLevel enable_level = PerfLevel::kEnableTimeExceptForMutex,
|
||||||
Statistics* statistics = nullptr, uint32_t ticker_type = 0)
|
Statistics* statistics = nullptr, uint32_t ticker_type = 0)
|
||||||
: perf_counter_enabled_(perf_level >= enable_level),
|
: perf_counter_enabled_(perf_level >= enable_level),
|
||||||
use_cpu_time_(use_cpu_time),
|
use_cpu_time_(use_cpu_time),
|
||||||
clock_((perf_counter_enabled_ || statistics != nullptr)
|
clock_((perf_counter_enabled_ || statistics != nullptr)
|
||||||
? ((clock.get() != nullptr) ? clock : SystemClock::Default())
|
? (clock ? clock : SystemClock::Default().get())
|
||||||
: nullptr),
|
: nullptr),
|
||||||
start_(0),
|
start_(0),
|
||||||
metric_(metric),
|
metric_(metric),
|
||||||
@ -70,7 +69,7 @@ class PerfStepTimer {
|
|||||||
|
|
||||||
const bool perf_counter_enabled_;
|
const bool perf_counter_enabled_;
|
||||||
const bool use_cpu_time_;
|
const bool use_cpu_time_;
|
||||||
std::shared_ptr<SystemClock> clock_;
|
SystemClock* const clock_;
|
||||||
uint64_t start_;
|
uint64_t start_;
|
||||||
uint64_t* metric_;
|
uint64_t* metric_;
|
||||||
Statistics* statistics_;
|
Statistics* statistics_;
|
||||||
|
Loading…
Reference in New Issue
Block a user