From 9ea9007b507e5168fe62c491f5248f42cf52d177 Mon Sep 17 00:00:00 2001 From: Maysam Yabandeh Date: Wed, 12 Sep 2018 09:42:31 -0700 Subject: [PATCH] Reduce IndexBlockIter size (#4358) Summary: With #3983 the size of IndexBlockIter was increased. This had resulted in a regression on P50 latencies in one of our benchmarks. The patch reduces IndexBlockIter size be eliminating active_comparator_ field from the class. Pull Request resolved: https://github.com/facebook/rocksdb/pull/4358 Differential Revision: D9781737 Pulled By: maysamyabandeh fbshipit-source-id: 71e2b28d90ff0813db9e04b737ae73e185583c52 --- table/block.cc | 4 ++-- table/block.h | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/table/block.cc b/table/block.cc index 3d27e04d3..d11771c03 100644 --- a/table/block.cc +++ b/table/block.cc @@ -356,10 +356,10 @@ void IndexBlockIter::Seek(const Slice& target) { ok = PrefixSeek(target, &index); } else if (value_delta_encoded_) { ok = BinarySeek(seek_key, 0, num_restarts_ - 1, &index, - active_comparator_); + comparator_); } else { ok = BinarySeek(seek_key, 0, num_restarts_ - 1, &index, - active_comparator_); + comparator_); } if (!ok) { diff --git a/table/block.h b/table/block.h index ee3f07b43..83900b56f 100644 --- a/table/block.h +++ b/table/block.h @@ -468,10 +468,10 @@ class IndexBlockIter final : public BlockIter { BlockPrefixIndex* prefix_index, bool key_includes_seq, bool value_is_full, bool block_contents_pinned, DataBlockHashIndex* /*data_block_hash_index*/) { - InitializeBase(comparator, data, restarts, num_restarts, - kDisableGlobalSequenceNumber, block_contents_pinned); + InitializeBase(key_includes_seq ? comparator : user_comparator, data, + restarts, num_restarts, kDisableGlobalSequenceNumber, + block_contents_pinned); key_includes_seq_ = key_includes_seq; - active_comparator_ = key_includes_seq_ ? comparator_ : user_comparator; key_.SetIsUserKey(!key_includes_seq_); prefix_index_ = prefix_index; value_delta_encoded_ = !value_is_full; @@ -517,8 +517,6 @@ class IndexBlockIter final : public BlockIter { // Key is in InternalKey format bool key_includes_seq_; bool value_delta_encoded_; - // key_includes_seq_ ? comparator_ : user_comparator_ - const Comparator* active_comparator_; BlockPrefixIndex* prefix_index_; // Whether the value is delta encoded. In that case the value is assumed to be // BlockHandle. The first value in each restart interval is the full encoded @@ -535,11 +533,11 @@ class IndexBlockIter final : public BlockIter { inline int CompareBlockKey(uint32_t block_index, const Slice& target); inline int Compare(const Slice& a, const Slice& b) const { - return active_comparator_->Compare(a, b); + return comparator_->Compare(a, b); } inline int Compare(const IterKey& ikey, const Slice& b) const { - return active_comparator_->Compare(ikey.GetKey(), b); + return comparator_->Compare(ikey.GetKey(), b); } inline bool ParseNextIndexKey();