diff --git a/db/compaction_job.cc b/db/compaction_job.cc index 58f34d165..426ab0432 100644 --- a/db/compaction_job.cc +++ b/db/compaction_job.cc @@ -1135,8 +1135,9 @@ void CompactionJob::ProcessKeyValueCompaction(SubcompactionState* sub_compact) { sub_compact->compaction_job_stats.file_prepare_write_nanos += IOSTATS(prepare_write_nanos) - prev_prepare_write_nanos; sub_compact->compaction_job_stats.cpu_micros -= - (IOSTATS(cpu_write_nanos) - prev_cpu_write_nanos - + IOSTATS(cpu_read_nanos) - prev_cpu_read_nanos) / 1000; + (IOSTATS(cpu_write_nanos) - prev_cpu_write_nanos + + IOSTATS(cpu_read_nanos) - prev_cpu_read_nanos) / + 1000; if (prev_perf_level != PerfLevel::kEnableTimeAndCPUTimeExceptForMutex) { SetPerfLevel(prev_perf_level); } diff --git a/db/db_impl.h b/db/db_impl.h index 4b663cf23..db6e2ed60 100644 --- a/db/db_impl.h +++ b/db/db_impl.h @@ -923,11 +923,13 @@ class DBImpl : public DB { // Flush the in-memory write buffer to storage. Switches to a new // log-file/memtable and writes a new descriptor iff successful. Then // installs a new super version for the column family. - Status FlushMemTableToOutputFile(ColumnFamilyData* cfd, - const MutableCFOptions& mutable_cf_options, - bool* madeProgress, JobContext* job_context, - SuperVersionContext* superversion_context, - LogBuffer* log_buffer); + Status FlushMemTableToOutputFile( + ColumnFamilyData* cfd, const MutableCFOptions& mutable_cf_options, + bool* madeProgress, JobContext* job_context, + SuperVersionContext* superversion_context, + std::vector& snapshot_seqs, + SequenceNumber earliest_write_conflict_snapshot, + SnapshotChecker* snapshot_checker, LogBuffer* log_buffer); // Argument required by background flush thread. struct BGFlushArg { diff --git a/db/db_impl_compaction_flush.cc b/db/db_impl_compaction_flush.cc index d0feb9c40..40295b840 100644 --- a/db/db_impl_compaction_flush.cc +++ b/db/db_impl_compaction_flush.cc @@ -132,16 +132,14 @@ Status DBImpl::SyncClosedLogs(JobContext* job_context) { Status DBImpl::FlushMemTableToOutputFile( ColumnFamilyData* cfd, const MutableCFOptions& mutable_cf_options, bool* made_progress, JobContext* job_context, - SuperVersionContext* superversion_context, LogBuffer* log_buffer) { + SuperVersionContext* superversion_context, + std::vector& snapshot_seqs, + SequenceNumber earliest_write_conflict_snapshot, + SnapshotChecker* snapshot_checker, LogBuffer* log_buffer) { mutex_.AssertHeld(); assert(cfd->imm()->NumNotFlushed() != 0); assert(cfd->imm()->IsFlushPending()); - std::vector snapshot_seqs; - SequenceNumber earliest_write_conflict_snapshot; - SnapshotChecker* snapshot_checker; - GetSnapshotContext(job_context, &snapshot_seqs, - &earliest_write_conflict_snapshot, &snapshot_checker); FlushJob flush_job( dbname_, cfd, immutable_db_options_, mutable_cf_options, @@ -239,14 +237,20 @@ Status DBImpl::FlushMemTablesToOutputFiles( return AtomicFlushMemTablesToOutputFiles(bg_flush_args, made_progress, job_context, log_buffer); } + std::vector snapshot_seqs; + SequenceNumber earliest_write_conflict_snapshot; + SnapshotChecker* snapshot_checker; + GetSnapshotContext(job_context, &snapshot_seqs, + &earliest_write_conflict_snapshot, &snapshot_checker); Status status; for (auto& arg : bg_flush_args) { ColumnFamilyData* cfd = arg.cfd_; MutableCFOptions mutable_cf_options = *cfd->GetLatestMutableCFOptions(); SuperVersionContext* superversion_context = arg.superversion_context_; - Status s = FlushMemTableToOutputFile(cfd, mutable_cf_options, made_progress, - job_context, superversion_context, - log_buffer); + Status s = FlushMemTableToOutputFile( + cfd, mutable_cf_options, made_progress, job_context, + superversion_context, snapshot_seqs, earliest_write_conflict_snapshot, + snapshot_checker, log_buffer); if (!s.ok()) { status = s; if (!s.IsShutdownInProgress()) {