compaction: LCS: Fix inefficiency when pushing SSTables to higher levels
To satisfy backlog controller, commit 28382cb25c changed LCS to
incrementally push sstables to highest level *when* there's nothing else
to be done.
That's overkill because controller will be satisfied with level L being
fanout times larger than L-1. No need to push everything to last level as
it's even worse than a major, because any file being promoted will
overlap with ~10 files in next level. At least, the cost is amortized by
multiple iterations, but terrible write amplification is still there.
Consequently, this reduces overall efficiency.
For example, it might happen that LCS in table A start pushing everything
to highest level, when table B needs resources for compaction to reduce its
backlog. Increased write amplification in A may prevent other tables
from reducing their backlog in a timely manner.
It's clear that LCS should stop promoting as soon as level L is 10x
larger than L-1, so strategy will still be satisfied while fixing the
inefficiency problem.
Now layout will look like as follow:
SSTables in each level: [0, 2, 15, 121]
Previously, it looked like once table stopped being written to:
SSTables in each level: [0, 0, 0, 138]
It's always good to have everything in a single run, but that comes
with a high write amplification cost which we cannot afford in steady
state. With this change, the layout will still be good enough to make
everybody happy.
Signed-off-by: Raphael S. Carvalho <raphaelsc@scylladb.com>
Message-Id: <20211129143606.71257-1-raphaelsc@scylladb.com>
This commit is contained in:
committed by
Avi Kivity
parent
f2ab5f4e60
commit
9de7abdc80
@@ -288,6 +288,12 @@ public:
|
||||
if (sstables_prev_level.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// stop pushing data to higher levels once L is 10x (fan out) larger than L-1.
|
||||
if (get_total_bytes(sstables) >= (get_total_bytes(sstables_prev_level) * leveled_fan_out)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto descriptor = get_descriptor_for_level(i-1, last_compacted_keys, compaction_counter);
|
||||
if (!descriptor.sstables.empty()) {
|
||||
return descriptor;
|
||||
|
||||
Reference in New Issue
Block a user