Skip to content

Commit d84e0b7

Browse files
author
caijieming
committed
issue #934: multithread compactiong support
1 parent b66c065 commit d84e0b7

File tree

10 files changed

+672
-397
lines changed

10 files changed

+672
-397
lines changed

src/leveldb/db/db_impl.cc

Lines changed: 152 additions & 98 deletions
Large diffs are not rendered by default.

src/leveldb/db/db_impl.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class DBImpl : public DB {
114114
Status CompactMemTable()
115115
EXCLUSIVE_LOCKS_REQUIRED(mutex_);
116116

117-
Status WriteLevel0Table(MemTable* mem, VersionEdit* edit, Version* base)
117+
Status WriteLevel0Table(MemTable* mem, VersionEdit* edit, Version* base, uint64_t* number = NULL)
118118
EXCLUSIVE_LOCKS_REQUIRED(mutex_);
119119

120120
Status MakeRoomForWrite(bool force /* compact even if there is room? */)
@@ -193,17 +193,24 @@ class DBImpl : public DB {
193193
std::set<uint64_t> pending_outputs_;
194194

195195
// Has a background compaction been scheduled or is running?
196-
bool bg_compaction_scheduled_;
197-
double bg_compaction_score_;
198-
int64_t bg_schedule_id_;
196+
int bg_compaction_scheduled_;
197+
std::vector<double> bg_compaction_score_;
198+
std::vector<int64_t> bg_schedule_id_;
199199

200200
// Information for a manual compaction
201+
enum ManualCompactState {
202+
kManualCompactIdle,
203+
kManualCompactConflict,
204+
kManualCompactWakeup,
205+
};
201206
struct ManualCompaction {
202207
int level;
203208
bool done;
209+
bool being_sched;
204210
const InternalKey* begin; // NULL means beginning of key range
205211
const InternalKey* end; // NULL means end of key range
206212
InternalKey tmp_storage; // Used to keep track of compaction progress
213+
int compaction_conflict; // 0 == idle, 1 == conflict, 2 == wake
207214
};
208215
ManualCompaction* manual_compaction_;
209216

0 commit comments

Comments
 (0)