From 6dc940d4c9951487281677b77d4d3e18f7032bc8 Mon Sep 17 00:00:00 2001 From: Lei Jin Date: Wed, 19 Mar 2014 10:54:32 -0700 Subject: [PATCH] avoid shared_ptr assignment in Version::Get() Summary: This is a 500ns operation while the whole Get() call takes only a few micro! Test Plan: ran db_bench, for a DB with 50M keys, QPS jumps from 5.2M/s to 7.2M/s Reviewers: haobo, igor, dhruba Reviewed By: haobo CC: leveldb Differential Revision: https://reviews.facebook.net/D17007 --- db/version_set.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/version_set.cc b/db/version_set.cc index 3b7a74afd..f8cbbf52f 100644 --- a/db/version_set.cc +++ b/db/version_set.cc @@ -485,7 +485,7 @@ void Version::Get(const ReadOptions& options, const Comparator* ucmp = vset_->icmp_.user_comparator(); auto merge_operator = db_options.merge_operator.get(); - auto logger = db_options.info_log; + auto logger = db_options.info_log.get(); assert(status->ok() || status->IsMergeInProgress()); Saver saver; @@ -496,7 +496,7 @@ void Version::Get(const ReadOptions& options, saver.value = value; saver.merge_operator = merge_operator; saver.merge_context = merge_context; - saver.logger = logger.get(); + saver.logger = logger; saver.didIO = false; saver.statistics = db_options.statistics.get(); @@ -618,7 +618,7 @@ void Version::Get(const ReadOptions& options, // do a final merge of nullptr and operands; if (merge_operator->FullMerge(user_key, nullptr, saver.merge_context->GetOperands(), - value, logger.get())) { + value, logger)) { *status = Status::OK(); } else { RecordTick(db_options.statistics.get(), NUMBER_MERGE_FAILURES);