From 880411f54cdcb8da216722bc2f7bbe9ae6859e00 Mon Sep 17 00:00:00 2001 From: Andrew Kryczka Date: Mon, 2 Oct 2017 20:40:23 -0700 Subject: [PATCH] disable populating block cache for in-place updates Summary: There's no point populating the block cache during this read. The key we read is guaranteed to be overwritten with a new `kValueType` key immediately afterwards, so can't be accessed again. A user was seeing high turnover of data blocks, at least partially due to this. Closes https://github.com/facebook/rocksdb/pull/2959 Differential Revision: D5961672 Pulled By: ajkr fbshipit-source-id: e7cb27c156c5db3b32af355c780efb99dbdf087c --- db/write_batch.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/db/write_batch.cc b/db/write_batch.cc index 8e7a537cd..c35499e0b 100644 --- a/db/write_batch.cc +++ b/db/write_batch.cc @@ -848,10 +848,8 @@ class MemTableInserter : public WriteBatch::Handler { // cause memory allocations though unused. // Make creation optional but do not incur // unique_ptr additional allocation - using - MemPostInfoMap = std::map; - using - PostMapType = std::aligned_storage::type; + using MemPostInfoMap = std::map; + using PostMapType = std::aligned_storage::type; PostMapType mem_post_info_map_; // current recovered transaction we are rebuilding (recovery) WriteBatch* rebuilding_trx_; @@ -1002,6 +1000,9 @@ class MemTableInserter : public WriteBatch::Handler { SnapshotImpl read_from_snapshot; read_from_snapshot.number_ = sequence_; ReadOptions ropts; + // it's going to be overwritten for sure, so no point caching data block + // containing the old version + ropts.fill_cache = false; ropts.snapshot = &read_from_snapshot; std::string prev_value;