From d0798f67f4033f0617eacc7a73f22cfe3e828eb1 Mon Sep 17 00:00:00 2001 From: Dhruba Borthakur Date: Wed, 20 Mar 2013 15:14:10 -0700 Subject: [PATCH] Run compactions even if workload is readonly or read-mostly. Summary: The events that trigger compaction: * opening the database * Get -> only if seek compaction is not disabled and other checks are true * MakeRoomForWrite -> when memtable is full * BackgroundCall -> If the background thread is about to do a compaction run, it schedules a new background task to trigger a possible compaction. This will cause additional background threads to find and process other compactions that can run concurrently. Test Plan: ran db_bench with overwrite and readonly alternatively. Reviewers: sheki, MarkCallaghan Reviewed By: sheki CC: leveldb Differential Revision: https://reviews.facebook.net/D9579 --- db/db_impl.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/db/db_impl.cc b/db/db_impl.cc index 8e49af5906..9d68f70106 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -1294,6 +1294,7 @@ Status DBImpl::BackgroundCompaction(bool* madeProgress, versions_->ReleaseCompactionFiles(c.get(), status); *madeProgress = true; } else { + MaybeScheduleCompaction(); // do more compaction work in parallel. CompactionState* compact = new CompactionState(c.get()); status = DoCompactionWork(compact); CleanupCompaction(compact);