Only execute flush from compaction if max_background_flushes = 0

Summary: As title. We shouldn't need to execute flush from compaction if there are dedicated threads doing flushes.

Test Plan: make check

Reviewers: rven, yhchiang, sdong

Reviewed By: sdong

Subscribers: dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D30579
main
Igor Canadi 10 years ago
parent 0acc738810
commit 4fd26f287c
  1. 9
      db/db_impl.cc

@ -2018,8 +2018,9 @@ Status DBImpl::BackgroundCompaction(bool* madeProgress, JobContext* job_context,
return Status::OK();
}
// FLUSH preempts compaction
// TODO(icanadi) we should only do this if max_background_flushes == 0
// If there are no flush threads, then compaction thread needs to execute the
// flushes
if (db_options_.max_background_flushes == 0) {
// BackgroundFlush() will only execute a single flush. We keep calling it as
// long as there's more flushes to be done
while (!flush_queue_.empty()) {
@ -2029,7 +2030,8 @@ Status DBImpl::BackgroundCompaction(bool* madeProgress, JobContext* job_context,
"%d, compaction slots available %d",
db_options_.max_background_flushes - bg_flush_scheduled_,
db_options_.max_background_compactions - bg_compaction_scheduled_);
auto flush_status = BackgroundFlush(madeProgress, job_context, log_buffer);
auto flush_status =
BackgroundFlush(madeProgress, job_context, log_buffer);
if (!flush_status.ok()) {
if (is_manual) {
manual_compaction_->status = flush_status;
@ -2040,6 +2042,7 @@ Status DBImpl::BackgroundCompaction(bool* madeProgress, JobContext* job_context,
return flush_status;
}
}
}
unique_ptr<Compaction> c;
InternalKey manual_end_storage;

Loading…
Cancel
Save