@@ -1035,7 +1035,7 @@ Status DBImpl::WriteLevel0Table(std::vector<MemTable*> &mems, VersionEdit* edit,
1035
1035
(unsigned long )m->GetLogNumber ());
1036
1036
list.push_back (m->NewIterator ());
1037
1037
}
1038
- Iterator* iter = NewMergingIterator (&internal_comparator_, &list[0 ],
1038
+ Iterator* iter = NewMergingIterator (env_, &internal_comparator_, &list[0 ],
1039
1039
list.size ());
1040
1040
const SequenceNumber newest_snapshot = snapshots_.GetNewest ();
1041
1041
const SequenceNumber earliest_seqno_in_memtable =
@@ -2519,7 +2519,7 @@ Iterator* DBImpl::NewInternalIterator(const ReadOptions& options,
2519
2519
// Collect iterators for files in L0 - Ln
2520
2520
versions_->current ()->AddIterators (options, storage_options_, &list);
2521
2521
Iterator* internal_iter =
2522
- NewMergingIterator (&internal_comparator_, &list[0 ], list.size ());
2522
+ NewMergingIterator (env_, &internal_comparator_, &list[0 ], list.size ());
2523
2523
versions_->current ()->Ref ();
2524
2524
2525
2525
cleanup->mu = &mutex_;
@@ -2555,6 +2555,8 @@ Status DBImpl::GetImpl(const ReadOptions& options,
2555
2555
Status s;
2556
2556
2557
2557
StopWatch sw (env_, options_.statistics , DB_GET);
2558
+ StopWatchNano snapshot_timer (env_, false );
2559
+ StartPerfTimer (&snapshot_timer);
2558
2560
SequenceNumber snapshot;
2559
2561
mutex_.Lock ();
2560
2562
if (options.snapshot != nullptr ) {
@@ -2583,15 +2585,23 @@ Status DBImpl::GetImpl(const ReadOptions& options,
2583
2585
// s is both in/out. When in, s could either be OK or MergeInProgress.
2584
2586
// merge_operands will contain the sequence of merges in the latter case.
2585
2587
LookupKey lkey (key, snapshot);
2588
+ BumpPerfTime (&perf_context.get_snapshot_time , &snapshot_timer);
2586
2589
if (mem->Get (lkey, value, &s, &merge_operands, options_)) {
2587
2590
// Done
2588
2591
} else if (imm.Get (lkey, value, &s, &merge_operands, options_)) {
2589
2592
// Done
2590
2593
} else {
2594
+ StopWatchNano from_files_timer (env_, false );
2595
+ StartPerfTimer (&from_files_timer);
2596
+
2591
2597
current->Get (options, lkey, value, &s, &merge_operands, &stats,
2592
2598
options_, value_found);
2593
2599
have_stat_update = true ;
2600
+ BumpPerfTime (&perf_context.get_from_output_files_time , &from_files_timer);
2594
2601
}
2602
+
2603
+ StopWatchNano post_process_timer (env_, false );
2604
+ StartPerfTimer (&post_process_timer);
2595
2605
mutex_.Lock ();
2596
2606
2597
2607
if (!options_.disable_seek_compaction &&
@@ -2607,6 +2617,8 @@ Status DBImpl::GetImpl(const ReadOptions& options,
2607
2617
// Note, tickers are atomic now - no lock protection needed any more.
2608
2618
RecordTick (options_.statistics , NUMBER_KEYS_READ);
2609
2619
RecordTick (options_.statistics , BYTES_READ, value->size ());
2620
+ BumpPerfTime (&perf_context.get_post_process_time , &post_process_timer);
2621
+
2610
2622
return s;
2611
2623
}
2612
2624
@@ -2615,6 +2627,8 @@ std::vector<Status> DBImpl::MultiGet(const ReadOptions& options,
2615
2627
std::vector<std::string>* values) {
2616
2628
2617
2629
StopWatch sw (env_, options_.statistics , DB_MULTIGET);
2630
+ StopWatchNano snapshot_timer (env_, false );
2631
+ StartPerfTimer (&snapshot_timer);
2618
2632
SequenceNumber snapshot;
2619
2633
mutex_.Lock ();
2620
2634
if (options.snapshot != nullptr ) {
@@ -2646,6 +2660,7 @@ std::vector<Status> DBImpl::MultiGet(const ReadOptions& options,
2646
2660
2647
2661
// Keep track of bytes that we read for statistics-recording later
2648
2662
uint64_t bytesRead = 0 ;
2663
+ BumpPerfTime (&perf_context.get_snapshot_time , &snapshot_timer);
2649
2664
2650
2665
// For each of the given keys, apply the entire "get" process as follows:
2651
2666
// First look in the memtable, then in the immutable memtable (if any).
@@ -2672,6 +2687,8 @@ std::vector<Status> DBImpl::MultiGet(const ReadOptions& options,
2672
2687
}
2673
2688
2674
2689
// Post processing (decrement reference counts and record statistics)
2690
+ StopWatchNano post_process_timer (env_, false );
2691
+ StartPerfTimer (&post_process_timer);
2675
2692
mutex_.Lock ();
2676
2693
if (!options_.disable_seek_compaction &&
2677
2694
have_stat_update && current->UpdateStats (stats)) {
@@ -2686,6 +2703,7 @@ std::vector<Status> DBImpl::MultiGet(const ReadOptions& options,
2686
2703
RecordTick (options_.statistics , NUMBER_MULTIGET_CALLS);
2687
2704
RecordTick (options_.statistics , NUMBER_MULTIGET_KEYS_READ, numKeys);
2688
2705
RecordTick (options_.statistics , NUMBER_MULTIGET_BYTES_READ, bytesRead);
2706
+ BumpPerfTime (&perf_context.get_post_process_time , &post_process_timer);
2689
2707
2690
2708
return statList;
2691
2709
}
@@ -2754,6 +2772,8 @@ Status DBImpl::Delete(const WriteOptions& options, const Slice& key) {
2754
2772
}
2755
2773
2756
2774
Status DBImpl::Write (const WriteOptions& options, WriteBatch* my_batch) {
2775
+ StopWatchNano pre_post_process_timer (env_, false );
2776
+ StartPerfTimer (&pre_post_process_timer);
2757
2777
Writer w (&mutex_);
2758
2778
w.batch = my_batch;
2759
2779
w.sync = options.sync ;
@@ -2800,12 +2820,13 @@ Status DBImpl::Write(const WriteOptions& options, WriteBatch* my_batch) {
2800
2820
if (options.disableWAL ) {
2801
2821
flush_on_destroy_ = true ;
2802
2822
}
2823
+ BumpPerfTime (&perf_context.write_pre_and_post_process_time ,
2824
+ &pre_post_process_timer);
2803
2825
2804
2826
if (!options.disableWAL ) {
2805
2827
StopWatchNano timer (env_);
2806
2828
StartPerfTimer (&timer);
2807
2829
status = log_->AddRecord (WriteBatchInternal::Contents (updates));
2808
- BumpPerfTime (&perf_context.wal_write_time , &timer);
2809
2830
if (status.ok () && options.sync ) {
2810
2831
if (options_.use_fsync ) {
2811
2832
StopWatch (env_, options_.statistics , WAL_FILE_SYNC_MICROS);
@@ -2815,10 +2836,14 @@ Status DBImpl::Write(const WriteOptions& options, WriteBatch* my_batch) {
2815
2836
status = log_->file ()->Sync ();
2816
2837
}
2817
2838
}
2839
+ BumpPerfTime (&perf_context.write_wal_time , &timer);
2818
2840
}
2819
2841
if (status.ok ()) {
2842
+ StopWatchNano write_memtable_timer (env_, false );
2843
+ StartPerfTimer (&write_memtable_timer);
2820
2844
status = WriteBatchInternal::InsertInto (updates, mem_, &options_, this ,
2821
2845
options_.filter_deletes );
2846
+ BumpPerfTime (&perf_context.write_memtable_time , &write_memtable_timer);
2822
2847
if (!status.ok ()) {
2823
2848
// Panic for in-memory corruptions
2824
2849
// Note that existing logic was not sound. Any partial failure writing
@@ -2828,6 +2853,7 @@ Status DBImpl::Write(const WriteOptions& options, WriteBatch* my_batch) {
2828
2853
}
2829
2854
SetTickerCount (options_.statistics , SEQUENCE_NUMBER, last_sequence);
2830
2855
}
2856
+ StartPerfTimer (&pre_post_process_timer);
2831
2857
LogFlush (options_.info_log );
2832
2858
mutex_.Lock ();
2833
2859
if (status.ok ()) {
@@ -2855,6 +2881,8 @@ Status DBImpl::Write(const WriteOptions& options, WriteBatch* my_batch) {
2855
2881
if (!writers_.empty ()) {
2856
2882
writers_.front ()->cv .Signal ();
2857
2883
}
2884
+ BumpPerfTime (&perf_context.write_pre_and_post_process_time ,
2885
+ &pre_post_process_timer);
2858
2886
return status;
2859
2887
}
2860
2888
0 commit comments