issue #934: multi-thread compaction support#976
issue #934: multi-thread compaction support#976caijieming-ng wants to merge 1 commit intobaidu:masterfrom
Conversation
|
build |
9c789c6 to
b38af4b
Compare
4ee16ed to
d84e0b7
Compare
| // check filesystem, and then check pending_outputs_ | ||
| std::vector<std::string> filenames; | ||
| mutex_.Unlock(); | ||
| env_->GetChildren(dbname_, &filenames); // Ignoring errors on purpose |
There was a problem hiding this comment.
why Ignoring errors on purpose
There was a problem hiding this comment.
即使本次删除旧sst失败,下一次compact也会继续删除,所以没有必要因为此处失败,而认为本次compact失败,compact重做的话,io开销很重。
f28504a to
e61e91b
Compare
src/leveldb/db/db_table.cc
Outdated
| std::map<uint64_t, uint64_t> rollbacks = options_.rollbacks; | ||
| for (std::set<uint32_t>::iterator it = options_.exist_lg_list->begin(); | ||
| it != options_.exist_lg_list->end() && s.ok(); ++it) { | ||
| it != options_.exist_lg_list->end() && s.ok(); ++it) { |
59b896b to
1741aa5
Compare
|
@baidu/tera_dev 请都瞧一瞧。 LGTM |
1741aa5 to
bc1ff22
Compare
|
build |
1 similar comment
|
build |
bc1ff22 to
8585854
Compare
src/leveldb/db/db_impl.h
Outdated
| 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 |
There was a problem hiding this comment.
enum内部也是个int吧
|
commit log里,multithread中间加个-,compactiong拼错了 |
5ec0c93 to
549443c
Compare
|
已修改 |
549443c to
58cb9cf
Compare
|
build |
58cb9cf to
691adcf
Compare
|
build |
2 similar comments
|
build |
|
build |
691adcf to
0dc050b
Compare
|
在看ing,需要点时间。。稍安勿躁! |
| } | ||
| imm_->SetBeingFlushed(true); | ||
|
|
||
| if (imm_->ApproximateMemoryUsage() <= 0) { // imm is empty, do nothing |
There was a problem hiding this comment.
代码完整性检查:memtablet没有数据时,不做内存的dump
src/leveldb/db/db_impl.h
Outdated
| struct CompactionTask { | ||
| int64_t id; | ||
| double score; | ||
| uint64_t timeout; |
| // Compact the in-memory write buffer to disk. Switches to a new | ||
| // log-file/memtable and writes a new descriptor iff successful. | ||
| Status CompactMemTable() | ||
| Status CompactMemTable(bool* sched_idle = NULL) |
There was a problem hiding this comment.
描述改函数是否真正干活,避免空调度
src/leveldb/db/db_impl.cc
Outdated
|
|
||
| // end of tera-specific | ||
|
|
||
| bool ScoreSortDesc(std::pair<double, uint64_t> i, std::pair<double, uint64_t> j) { |
src/leveldb/db/db_impl.cc
Outdated
| versions_->ReleaseCompaction(c, status); // current_version has reference to c->inputs_[0,1] | ||
| c->ReleaseInputs(); | ||
| DeleteObsoleteFiles(); | ||
| DeleteObsoleteFiles();// delete any sst not in version set. if comapct and flush mem handle in multi-thread, may delete new data |
| std::vector<int64_t> bg_schedule_id_; | ||
|
|
||
| // Information for a manual compaction | ||
| enum ManualCompactState { |
src/leveldb/db/db_impl.h
Outdated
| uint64_t bg_compaction_timeout_; | ||
| int64_t bg_schedule_id_; | ||
| std::vector<CompactionTask*> bg_compaction_tasks_; | ||
| int bg_compaction_scheduled_; |
There was a problem hiding this comment.
bg_compaction_scheduled_不需要了吧? bg_compaction_score_可以计算出来?
| std::vector<CompactionTask*> bg_compaction_tasks_; | ||
| int bg_compaction_scheduled_; | ||
| std::vector<double> bg_compaction_score_; | ||
| std::vector<int64_t> bg_schedule_id_; |
There was a problem hiding this comment.
bg_compaction_score_和bg_schedule_id_ 放在一个结构体里?
There was a problem hiding this comment.
score和id不是同时产生的,没有必要放到同一个结构体里面
| 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 | ||
| ManualCompactState compaction_conflict; // 0 == idle, 1 == conflict, 2 == wake |
There was a problem hiding this comment.
compaction_conflict变量命名有点奇怪? 猜不出什么含义?
There was a problem hiding this comment.
就是手动compact并发冲突
|
|
||
| bool BeingFlushed() { return being_flushed_;} | ||
| void SetBeingFlushed(bool flag) { | ||
| assert(flag ? !being_flushed_ |
There was a problem hiding this comment.
放置后续同学改次块代码改错
| @@ -314,6 +314,14 @@ struct Options { | |||
| // Default: 10 % | |||
| uint64_t del_percentage; | |||
There was a problem hiding this comment.
注释中的default值是10, 然而实际的default值是20
src/leveldb/db/db_impl.cc
Outdated
| s = versions_->LogAndApply(&edit, &mutex_); | ||
| pending_outputs_.erase(number); | ||
| } else { | ||
| // TODO: dump memtable error, delete temp file |
src/leveldb/db/db_impl.cc
Outdated
| MutexLock lock(&mutex_); | ||
| Status s; | ||
| if (recover_mem_ == NULL) { | ||
| DeleteObsoleteFiles(); |
|
|
||
| bg_compaction_scheduled_ = false; | ||
| bg_compaction_scheduled_--; | ||
| std::vector<CompactionTask*>::iterator task_id = std::find(bg_compaction_tasks_.begin(), |
src/leveldb/db/db_impl.cc
Outdated
| versions_->ReleaseCompaction(c, status); // current_version has reference to c->inputs_[0,1] | ||
| c->ReleaseInputs(); | ||
| DeleteObsoleteFiles(); | ||
| DeleteObsoleteFiles();// delete any sst not in version set. if comapct and flush mem handle in multi-thread, may delete new data |
| for (size_t i = 0; i < compact->outputs.size(); i++) { | ||
| const CompactionState::Output& out = compact->outputs[i]; | ||
| pending_outputs_.erase(BuildFullFileNumber(dbname_, out.number)); | ||
| Log(options_.info_log, "[%s] erase pending_output #%lu", dbname_.c_str(), out.number); |
There was a problem hiding this comment.
日志里最好都写filename, 便于追查问题, 另外这个日志会不会输出量较大?
There was a problem hiding this comment.
追查问题就是用sst number
|
db_test里面基本能覆盖多线程compact的测试 |
|
LGTM |
17702ce to
b45434e
Compare
#934 compact优化,story3, 多线程compact