Skip to content

Commit

Permalink
issue #934: multithread compactiong support
Browse files Browse the repository at this point in the history
  • Loading branch information
caijieming committed Aug 25, 2016
1 parent 55ea4ce commit b38af4b
Show file tree
Hide file tree
Showing 10 changed files with 702 additions and 395 deletions.
245 changes: 149 additions & 96 deletions src/leveldb/db/db_impl.cc

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions src/leveldb/db/db_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class DBImpl : public DB {
Status CompactMemTable()
EXCLUSIVE_LOCKS_REQUIRED(mutex_);

Status WriteLevel0Table(MemTable* mem, VersionEdit* edit, Version* base)
Status WriteLevel0Table(MemTable* mem, VersionEdit* edit, Version* base, uint64_t* number = NULL)
EXCLUSIVE_LOCKS_REQUIRED(mutex_);

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

// Has a background compaction been scheduled or is running?
bool bg_compaction_scheduled_;
double bg_compaction_score_;
int64_t bg_schedule_id_;
int bg_compaction_scheduled_;
std::vector<double> bg_compaction_score_;
std::vector<int64_t> bg_schedule_id_;

// Information for a manual compaction
enum ManualCompactState {
kManualCompactIdle,
kManualCompactConflict,
kManualCompactWakeup,
};
struct ManualCompaction {
int level;
bool done;
bool being_sched;
const InternalKey* begin; // NULL means beginning of key range
const InternalKey* end; // NULL means end of key range
InternalKey tmp_storage; // Used to keep track of compaction progress
int compaction_conflict; // 0 == idle, 1 == conflict, 2 == wake
};
ManualCompaction* manual_compaction_;

Expand Down
Loading

0 comments on commit b38af4b

Please sign in to comment.