Move level0 sorting logic from Version::SaveTo() to Version::Finalize()
Summary: I realized that "D14409 Avoid sorting in Version::Get() by presorting them in VersionSet::Builder::SaveTo()" is not done in an optimized place. SaveTo() is usually inside mutex. Move it to Finalize(), which is called out of mutex. Test Plan: make all check Reviewers: dhruba, haobo, kailiu Reviewed By: dhruba CC: igor, leveldb Differential Revision: https://reviews.facebook.net/D14607
This commit is contained in:
parent
a8b8b11dc4
commit
14995a8ff3
@ -1110,12 +1110,6 @@ class VersionSet::Builder {
|
||||
MaybeAddFile(v, level, *base_iter);
|
||||
}
|
||||
}
|
||||
// Pre-sort level0 for Get()
|
||||
if (vset_->options_->compaction_style == kCompactionStyleUniversal) {
|
||||
std::sort(v->files_[0].begin(), v->files_[0].end(), NewestFirstBySeqNo);
|
||||
} else {
|
||||
std::sort(v->files_[0].begin(), v->files_[0].end(), NewestFirst);
|
||||
}
|
||||
|
||||
CheckConsistency(v);
|
||||
}
|
||||
@ -1681,6 +1675,12 @@ void VersionSet::MarkFileNumberUsed(uint64_t number) {
|
||||
|
||||
void VersionSet::Finalize(Version* v,
|
||||
std::vector<uint64_t>& size_being_compacted) {
|
||||
// Pre-sort level0 for Get()
|
||||
if (options_->compaction_style == kCompactionStyleUniversal) {
|
||||
std::sort(v->files_[0].begin(), v->files_[0].end(), NewestFirstBySeqNo);
|
||||
} else {
|
||||
std::sort(v->files_[0].begin(), v->files_[0].end(), NewestFirst);
|
||||
}
|
||||
|
||||
double max_score = 0;
|
||||
int max_score_level = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user