@@ -3331,8 +3331,7 @@ Status DBImpl::GetImpl(const ReadOptions& options,
3331
3331
ColumnFamilyHandle* column_family, const Slice& key,
3332
3332
std::string* value, bool * value_found) {
3333
3333
StopWatch sw (env_, options_.statistics .get (), DB_GET, false );
3334
- StopWatchNano snapshot_timer (env_, false );
3335
- StartPerfTimer (&snapshot_timer);
3334
+ PERF_TIMER_AUTO (get_snapshot_time);
3336
3335
3337
3336
auto cfh = reinterpret_cast <ColumnFamilyHandleImpl*>(column_family);
3338
3337
auto cfd = cfh->cfd ();
@@ -3404,26 +3403,24 @@ Status DBImpl::GetImpl(const ReadOptions& options,
3404
3403
// s is both in/out. When in, s could either be OK or MergeInProgress.
3405
3404
// merge_operands will contain the sequence of merges in the latter case.
3406
3405
LookupKey lkey (key, snapshot);
3407
- BumpPerfTime (&perf_context. get_snapshot_time , &snapshot_timer );
3406
+ PERF_TIMER_STOP ( get_snapshot_time);
3408
3407
if (sv->mem ->Get (lkey, value, &s, merge_context, *cfd->options ())) {
3409
3408
// Done
3410
3409
RecordTick (options_.statistics .get (), MEMTABLE_HIT);
3411
3410
} else if (sv->imm ->Get (lkey, value, &s, merge_context, *cfd->options ())) {
3412
3411
// Done
3413
3412
RecordTick (options_.statistics .get (), MEMTABLE_HIT);
3414
3413
} else {
3415
- StopWatchNano from_files_timer (env_, false );
3416
- StartPerfTimer (&from_files_timer);
3414
+ PERF_TIMER_START (get_from_output_files_time);
3417
3415
3418
3416
sv->current ->Get (options, lkey, value, &s, &merge_context, &stats,
3419
3417
*cfd->options (), value_found);
3420
3418
have_stat_update = true ;
3421
- BumpPerfTime (&perf_context. get_from_output_files_time , &from_files_timer );
3419
+ PERF_TIMER_STOP ( get_from_output_files_time);
3422
3420
RecordTick (options_.statistics .get (), MEMTABLE_MISS);
3423
3421
}
3424
3422
3425
- StopWatchNano post_process_timer (env_, false );
3426
- StartPerfTimer (&post_process_timer);
3423
+ PERF_TIMER_START (get_post_process_time);
3427
3424
3428
3425
if (!cfd->options ()->disable_seek_compaction && have_stat_update) {
3429
3426
mutex_.Lock ();
@@ -3464,7 +3461,7 @@ Status DBImpl::GetImpl(const ReadOptions& options,
3464
3461
3465
3462
RecordTick (options_.statistics .get (), NUMBER_KEYS_READ);
3466
3463
RecordTick (options_.statistics .get (), BYTES_READ, value->size ());
3467
- BumpPerfTime (&perf_context. get_post_process_time , &post_process_timer );
3464
+ PERF_TIMER_STOP ( get_post_process_time);
3468
3465
return s;
3469
3466
}
3470
3467
@@ -3474,8 +3471,7 @@ std::vector<Status> DBImpl::MultiGet(
3474
3471
const std::vector<Slice>& keys, std::vector<std::string>* values) {
3475
3472
3476
3473
StopWatch sw (env_, options_.statistics .get (), DB_MULTIGET, false );
3477
- StopWatchNano snapshot_timer (env_, false );
3478
- StartPerfTimer (&snapshot_timer);
3474
+ PERF_TIMER_AUTO (get_snapshot_time);
3479
3475
3480
3476
SequenceNumber snapshot;
3481
3477
@@ -3519,7 +3515,7 @@ std::vector<Status> DBImpl::MultiGet(
3519
3515
3520
3516
// Keep track of bytes that we read for statistics-recording later
3521
3517
uint64_t bytes_read = 0 ;
3522
- BumpPerfTime (&perf_context. get_snapshot_time , &snapshot_timer );
3518
+ PERF_TIMER_STOP ( get_snapshot_time);
3523
3519
3524
3520
// For each of the given keys, apply the entire "get" process as follows:
3525
3521
// First look in the memtable, then in the immutable memtable (if any).
@@ -3555,8 +3551,7 @@ std::vector<Status> DBImpl::MultiGet(
3555
3551
}
3556
3552
3557
3553
// Post processing (decrement reference counts and record statistics)
3558
- StopWatchNano post_process_timer (env_, false );
3559
- StartPerfTimer (&post_process_timer);
3554
+ PERF_TIMER_START (get_post_process_time);
3560
3555
autovector<SuperVersion*> superversions_to_delete;
3561
3556
3562
3557
bool schedule_flush_or_compaction = false ;
@@ -3589,7 +3584,7 @@ std::vector<Status> DBImpl::MultiGet(
3589
3584
RecordTick (options_.statistics .get (), NUMBER_MULTIGET_CALLS);
3590
3585
RecordTick (options_.statistics .get (), NUMBER_MULTIGET_KEYS_READ, num_keys);
3591
3586
RecordTick (options_.statistics .get (), NUMBER_MULTIGET_BYTES_READ, bytes_read);
3592
- BumpPerfTime (&perf_context. get_post_process_time , &post_process_timer );
3587
+ PERF_TIMER_STOP ( get_post_process_time);
3593
3588
3594
3589
return stat_list;
3595
3590
}
@@ -3803,8 +3798,7 @@ Status DBImpl::Delete(const WriteOptions& options,
3803
3798
}
3804
3799
3805
3800
Status DBImpl::Write (const WriteOptions& options, WriteBatch* my_batch) {
3806
- StopWatchNano pre_post_process_timer (env_, false );
3807
- StartPerfTimer (&pre_post_process_timer);
3801
+ PERF_TIMER_AUTO (write_pre_and_post_process_time);
3808
3802
Writer w (&mutex_);
3809
3803
w.batch = my_batch;
3810
3804
w.sync = options.sync ;
@@ -3883,12 +3877,10 @@ Status DBImpl::Write(const WriteOptions& options, WriteBatch* my_batch) {
3883
3877
if (options.disableWAL ) {
3884
3878
flush_on_destroy_ = true ;
3885
3879
}
3886
- BumpPerfTime (&perf_context.write_pre_and_post_process_time ,
3887
- &pre_post_process_timer);
3880
+ PERF_TIMER_STOP (write_pre_and_post_process_time);
3888
3881
3889
3882
if (!options.disableWAL ) {
3890
- StopWatchNano timer (env_);
3891
- StartPerfTimer (&timer);
3883
+ PERF_TIMER_START (write_wal_time);
3892
3884
Slice log_entry = WriteBatchInternal::Contents (updates);
3893
3885
status = log_->AddRecord (log_entry);
3894
3886
RecordTick (options_.statistics .get (), WAL_FILE_SYNCED, 1 );
@@ -3902,15 +3894,13 @@ Status DBImpl::Write(const WriteOptions& options, WriteBatch* my_batch) {
3902
3894
status = log_->file ()->Sync ();
3903
3895
}
3904
3896
}
3905
- BumpPerfTime (&perf_context. write_wal_time , &timer );
3897
+ PERF_TIMER_STOP ( write_wal_time);
3906
3898
}
3907
3899
if (status.ok ()) {
3908
- StopWatchNano write_memtable_timer (env_, false );
3909
-
3910
- StartPerfTimer (&write_memtable_timer);
3900
+ PERF_TIMER_START (write_memtable_time);
3911
3901
status = WriteBatchInternal::InsertInto (
3912
3902
updates, column_family_memtables_.get (), false , 0 , this , false );
3913
- BumpPerfTime (&perf_context. write_memtable_time , &write_memtable_timer );
3903
+ PERF_TIMER_STOP ( write_memtable_time);
3914
3904
3915
3905
if (!status.ok ()) {
3916
3906
// Iteration failed (either in-memory writebatch corruption (very
@@ -3924,7 +3914,7 @@ Status DBImpl::Write(const WriteOptions& options, WriteBatch* my_batch) {
3924
3914
SetTickerCount (options_.statistics .get (), SEQUENCE_NUMBER,
3925
3915
last_sequence);
3926
3916
}
3927
- StartPerfTimer (&pre_post_process_timer );
3917
+ PERF_TIMER_START (write_pre_and_post_process_time );
3928
3918
if (updates == &tmp_batch_) tmp_batch_.Clear ();
3929
3919
mutex_.Lock ();
3930
3920
if (status.ok ()) {
@@ -3952,8 +3942,7 @@ Status DBImpl::Write(const WriteOptions& options, WriteBatch* my_batch) {
3952
3942
writers_.front ()->cv .Signal ();
3953
3943
}
3954
3944
mutex_.Unlock ();
3955
- BumpPerfTime (&perf_context.write_pre_and_post_process_time ,
3956
- &pre_post_process_timer);
3945
+ PERF_TIMER_STOP (write_pre_and_post_process_time);
3957
3946
return status;
3958
3947
}
3959
3948
0 commit comments