提交 aaf9c620 编写于 作者: S Siying Dong

[RocksDB][Performance Branch]Iterator Cleanup method only tries to find...

[RocksDB][Performance Branch]Iterator Cleanup method only tries to find obsolete files if it has the last reference to a version

Summary: When deconstructing an iterator, no need to check obsolete file if it doesn't hold last reference of any version.

Test Plan: make all check

Reviewers: haobo, igor, dhruba, kailiu

Reviewed By: haobo

CC: leveldb

Differential Revision: https://reviews.facebook.net/D14595
上级 f37a5976
......@@ -2515,9 +2515,10 @@ static void CleanupIteratorState(void* arg1, void* arg2) {
deletion_state.memtables_to_free.push_back(m);
}
}
state->version->Unref();
// fast path FindObsoleteFiles
state->db->FindObsoleteFiles(deletion_state, false, true);
if (state->version->Unref()) {
// fast path FindObsoleteFiles
state->db->FindObsoleteFiles(deletion_state, false, true);
}
state->mu->Unlock();
state->db->PurgeObsoleteFiles(deletion_state);
delete state;
......
......@@ -591,13 +591,15 @@ void Version::Ref() {
++refs_;
}
void Version::Unref() {
bool Version::Unref() {
assert(this != &vset_->dummy_versions_);
assert(refs_ >= 1);
--refs_;
if (refs_ == 0) {
delete this;
return true;
}
return false;
}
bool Version::OverlapInLevel(int level,
......
......@@ -89,7 +89,9 @@ class Version {
// Reference count management (so Versions do not disappear out from
// under live iterators)
void Ref();
void Unref();
// Decrease reference count. Delete the object if no reference left
// and return true. Otherwise, return false.
bool Unref();
void GetOverlappingInputs(
int level,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册