Minimize accessing multiple objects in Version::Get()

Summary:
One of our profilings shows that Version::Get() sometimes is slow when getting pointer of user comparators or other global objects. In this patch:
(1) we keep pointers of immutable objects in Version to avoid accesses them though option objects or cfd objects
(2) table_reader is directly cached in FileMetaData so that table cache don't have to go through handle first to fetch it
(3) If level 0 has less than 3 files, skip the filtering logic based on SST tables' key range. Smallest and largest key are stored in separated memory locations, which has potential cache misses

Test Plan: make all check

Reviewers: haobo, ljin

Reviewed By: haobo

CC: igor, yhchiang, nkg-, leveldb

Differential Revision: https://reviews.facebook.net/D17739
This commit is contained in:
sdong
2014-04-17 14:07:05 -07:00
parent e37dd216f9
commit fa430bfd04
6 changed files with 69 additions and 44 deletions

View File

@@ -3219,7 +3219,7 @@ Status DBImpl::GetImpl(const ReadOptions& options,
PERF_TIMER_START(get_from_output_files_time);
sv->current->Get(options, lkey, value, &s, &merge_context, &stats,
*cfd->options(), value_found);
value_found);
have_stat_update = true;
PERF_TIMER_STOP(get_from_output_files_time);
RecordTick(options_.statistics.get(), MEMTABLE_MISS);
@@ -3334,7 +3334,7 @@ std::vector<Status> DBImpl::MultiGet(
// Done
} else {
super_version->current->Get(options, lkey, value, &s, &merge_context,
&mgd->stats, *cfd->options());
&mgd->stats);
mgd->have_stat_update = true;
}