[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
main
Siying Dong 11 years ago
parent f37a59769b
commit aaf9c6203c
  1. 3
      db/db_impl.cc
  2. 4
      db/version_set.cc
  3. 4
      db/version_set.h

@ -2515,9 +2515,10 @@ static void CleanupIteratorState(void* arg1, void* arg2) {
deletion_state.memtables_to_free.push_back(m);
}
}
state->version->Unref();
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,

Loading…
Cancel
Save