[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
This commit is contained in:
Siying Dong 2013-12-11 11:56:36 -08:00
parent f37a59769b
commit aaf9c6203c
3 changed files with 10 additions and 5 deletions

View File

@ -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;

View File

@ -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,

View File

@ -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,