@ -8,35 +8,33 @@
# include "rocksdb/iostats_context.h"
# include "rocksdb/iostats_context.h"
# ifdef ROCKSDB_SUPPORT_THREAD_LOCAL
# ifdef ROCKSDB_SUPPORT_THREAD_LOCAL
namespace rocksdb {
extern __thread IOStatsContext iostats_context ;
} // namespace rocksdb
// increment a specific counter by the specified value
// increment a specific counter by the specified value
# define IOSTATS_ADD(metric, value) \
# define IOSTATS_ADD(metric, value) (iostats_context.metric += value)
( get_iostats_context ( ) - > metric + = value )
// Increase metric value only when it is positive
// Increase metric value only when it is positive
# define IOSTATS_ADD_IF_POSITIVE(metric, value) \
# define IOSTATS_ADD_IF_POSITIVE(metric, value) \
if ( value > 0 ) { IOSTATS_ADD ( metric , value ) ; }
if ( value > 0 ) { IOSTATS_ADD ( metric , value ) ; }
// reset a specific counter to zero
// reset a specific counter to zero
# define IOSTATS_RESET(metric) \
# define IOSTATS_RESET(metric) (iostats_context.metric = 0)
( get_iostats_context ( ) - > metric = 0 )
// reset all counters to zero
// reset all counters to zero
# define IOSTATS_RESET_ALL() \
# define IOSTATS_RESET_ALL() (iostats_context.Reset())
( get_iostats_context ( ) - > Reset ( ) )
# define IOSTATS_SET_THREAD_POOL_ID(value) \
# define IOSTATS_SET_THREAD_POOL_ID(value) \
( get_iostats_context ( ) - > thread_pool_id = value )
( iostats_context . thread_pool_id = value )
# define IOSTATS_THREAD_POOL_ID() \
# define IOSTATS_THREAD_POOL_ID() (iostats_context.thread_pool_id)
( get_iostats_context ( ) - > thread_pool_id )
# define IOSTATS(metric) \
# define IOSTATS(metric) (iostats_context.metric)
( get_iostats_context ( ) - > metric )
// Declare and set start time of the timer
// Declare and set start time of the timer
# define IOSTATS_TIMER_GUARD(metric) \
# define IOSTATS_TIMER_GUARD(metric) \
PerfStepTimer iostats_step_timer_ # # metric ( & ( get_iostats_context ( ) - > metric ) ) ; \
PerfStepTimer iostats_step_timer_ # # metric ( & ( iostats_context . metric ) ) ; \
iostats_step_timer_ # # metric . Start ( ) ;
iostats_step_timer_ # # metric . Start ( ) ;
# else // ROCKSDB_SUPPORT_THREAD_LOCAL
# else // ROCKSDB_SUPPORT_THREAD_LOCAL