From bcbb39999b04c803e1e136e5ae83b980f07e554b Mon Sep 17 00:00:00 2001 From: "Raphael S. Carvalho" Date: Mon, 22 Mar 2021 12:06:55 -0300 Subject: [PATCH] LCS: Fix terrible write amplification when reshaping level 0 LCS reshape is basically 'major compacting' level 0 until it contains less than N sstables. That produces terrible write amplification, because any given byte will be compacted (initial # of sstables / max_threshold (32)) times. So if L0 initially contained 256 ssts, there would be a WA of about 8. This terrible write amplification can be reduced by performing STCS instead on L0, which will leave L0 in a good shape without hurting WA as it happens now. Fixes #8345. Signed-off-by: Raphael S. Carvalho Message-Id: <20210322150655.27011-1-raphaelsc@scylladb.com> --- sstables/leveled_compaction_strategy.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sstables/leveled_compaction_strategy.cc b/sstables/leveled_compaction_strategy.cc index 2f3489b836..1d47193b30 100644 --- a/sstables/leveled_compaction_strategy.cc +++ b/sstables/leveled_compaction_strategy.cc @@ -189,10 +189,8 @@ leveled_compaction_strategy::get_reshaping_job(std::vector input }; if (level_info[0].size() > offstrategy_threshold) { - level_info[0].resize(std::min(level_info[0].size(), max_sstables)); - compaction_descriptor desc(std::move(level_info[0]), std::optional(), iop); - desc.options = compaction_options::make_reshape(); - return desc; + size_tiered_compaction_strategy stcs(_stcs_options); + return stcs.get_reshaping_job(std::move(level_info[0]), schema, iop, mode); } for (unsigned level = leveled_manifest::MAX_LEVELS - 1; level > 0; --level) {