From 2ff26d11608f26a129d3cdf2e173f8d39ae4b393 Mon Sep 17 00:00:00 2001 From: Piotr Sarna Date: Wed, 4 Dec 2019 15:17:14 +0100 Subject: [PATCH] table: Reduce read amplification in view update generation This commit makes sure that single-partition readers for read-before-write do not have fast-forwarding enabled, as it may lead to huge read amplification. The observed case was: 1. Creating an index. CREATE INDEX index1 ON myks2.standard1 ("C1"); 2. Running cassandra-stress in order to generate view updates. cassandra-stress write no-warmup n=1000000 cl=ONE -schema \ 'replication(factor=2) compaction(strategy=LeveledCompactionStrategy)' \ keyspace=myks2 -pop seq=4000000..8000000 -rate threads=100 -errors skip-read-validation -node 127.0.0.1; Without disabling fast-forwarding, single-partition readers were turned into scanning readers in cache, which resulted in reading 36GB (sic!) on a workload which generates less than 1GB of view updates. After applying the fix, the number dropped down to less than 1GB, as expected. Refs #5409 Fixes #4615 Fixes #5418 (cherry picked from commit 79c3a508f47177c903932556130ffb4bd719fb19) --- table.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/table.cc b/table.cc index c85f3adb0d..900ba05d90 100644 --- a/table.cc +++ b/table.cc @@ -2543,7 +2543,7 @@ future table::do_push_view_replica_updates(const schema std::move(slice), std::move(m), [base, views = std::move(views), lock = std::move(lock), this, timeout, source = std::move(source), &io_priority] (auto& pk, auto& slice, auto& m) mutable { - auto reader = source.make_reader(base, pk, slice, io_priority); + auto reader = source.make_reader(base, pk, slice, io_priority, nullptr, streamed_mutation::forwarding::no, mutation_reader::forwarding::no); return this->generate_and_propagate_view_updates(base, std::move(views), std::move(m), std::move(reader)).then([lock = std::move(lock)] () mutable { // return the local partition/row lock we have taken so it // remains locked until the caller is done modifying this