Files
greptimedb/src/mito2
Lei, HUANG 9cfbc42126 refactor(mito2): prioritize file count in TWCS picker (#8765)
* refactor(mito2): prioritize file count in TWCS picker

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>

* test(mito2): migrate TWCS tests to async picker API

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>

* refactor(mito2): remove legacy reduce_runs and merge_seq_files pickers

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>

* feat(mito2): balance TWCS picks by file group

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>

* refactor(mito2): treat multi-SST groups as barriers in TWCS pick_count_first

Previously pick_count_first filtered out multi-SST file groups and could
pick singleton groups across them in one interval. Now multi-SST groups
split the candidates into independent segments, so a single pick never
crosses a multi-SST group.

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>

* refactor(mito2): remove redundant overlaps_files_left_behind check

The rebase onto main kept both the upstream fix (#8872) and the branch's
selected_overlaps_unselected check for the same deletion-marker problem.
The upstream check is fully subsumed: files_to_merge only differs from
the window files in append mode, where filter_deleted is already false,
and selected_overlaps_unselected treats partially-selected groups as
unselected, making it strictly stronger.

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>

* perf(mito2): pre-filter by selection time span in selected_overlaps_unselected

A window group outside the overall time span of the selected groups
cannot overlap any of them, so skip the precise overlap check (and the
per-group file id set lookup) for it. In typical TWCS windows the pick
is clustered in one segment, so most unselected groups are rejected in
O(1).

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>

* refactor(mito2): remove FileGroup abstraction from TWCS picker

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>

* feat(mito2): drain compactable backlog after successful compaction

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>

* refactor(mito2): score TWCS candidates by predicted progress

Redefine what a pick candidate is worth: an interval is only eligible if
compacting it makes progress on at least one axis — it reduces the
physical file count given the max_output_file_size split threshold
(predicted output = ceil(input bytes / threshold)), or it resolves at
least one overlap between sorted runs. A pure rewrite that achieves
neither (e.g. 32 large balanced files whose output would split back into
just as many SSTs) is skipped instead of burning I/O.

The candidate metrics are accumulated in a Candidate struct as the
interval expands, and the score ranks by predicted file reduction, then
overlap participants, then smaller input bytes. With no output size
limit the behavior degenerates to the previous count-first rule.

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>

* fix(mito2): make TWCS input limit configurable

Allow operators to tune the maximum SST inputs through a hidden environment variable while keeping 32 as the validated default.

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>

* fix(mito2): apply TWCS trigger at window level

Check the total physical SST count before candidate selection so trigger values above the per-task input limit still allow bounded compactions.

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>

---------

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
2026-08-29 06:51:48 +00:00
..

Mito

Mito is GreptimeDB's default region engine.

About Mito

The Alfa Romeo MiTo is a front-wheel drive, three-door supermini designed by Centro Stile Alfa Romeo.

"You can't be a true petrolhead until you've owned an Alfa Romeo."

-- by Jeremy Clarkson

Benchmarks

Run benchmarks in this crate:

cargo bench -p mito2 -F test