Skip to content

Commit aaf9c62

Browse files
committed
[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
1 parent f37a597 commit aaf9c62

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

db/db_impl.cc

+4-3
Original file line numberDiff line numberDiff line change
@@ -2515,9 +2515,10 @@ static void CleanupIteratorState(void* arg1, void* arg2) {
25152515
deletion_state.memtables_to_free.push_back(m);
25162516
}
25172517
}
2518-
state->version->Unref();
2519-
// fast path FindObsoleteFiles
2520-
state->db->FindObsoleteFiles(deletion_state, false, true);
2518+
if (state->version->Unref()) {
2519+
// fast path FindObsoleteFiles
2520+
state->db->FindObsoleteFiles(deletion_state, false, true);
2521+
}
25212522
state->mu->Unlock();
25222523
state->db->PurgeObsoleteFiles(deletion_state);
25232524
delete state;

db/version_set.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -591,13 +591,15 @@ void Version::Ref() {
591591
++refs_;
592592
}
593593

594-
void Version::Unref() {
594+
bool Version::Unref() {
595595
assert(this != &vset_->dummy_versions_);
596596
assert(refs_ >= 1);
597597
--refs_;
598598
if (refs_ == 0) {
599599
delete this;
600+
return true;
600601
}
602+
return false;
601603
}
602604

603605
bool Version::OverlapInLevel(int level,

db/version_set.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ class Version {
8989
// Reference count management (so Versions do not disappear out from
9090
// under live iterators)
9191
void Ref();
92-
void Unref();
92+
// Decrease reference count. Delete the object if no reference left
93+
// and return true. Otherwise, return false.
94+
bool Unref();
9395

9496
void GetOverlappingInputs(
9597
int level,

0 commit comments

Comments
 (0)