Skip to content
About
Main content

Compaction as bin-packing

How much rewriting does compaction cost to reach a target file size?

Here, is not the same as merging sorted runs inside an LSM-tree. The files in a table are independent of each other, and each carries min/max statistics. Compaction becomes : choose a group of small files and rewrite them as one bigger file near the target size.

What carries over from LSM-trees is the arithmetic. If each rewrite step multiplies file size by a g, then a byte is rewritten:

times.

, but they also mean a longer wait before data is compacted, and bigger jobs that clash more often with writers (Running maintenance safely). The choice between tiered and leveled compaction in an LSM-tree (merge often in small groups versus keep strictly sorted levels) is the same dial as small step versus big step here.