mirror-coreos-chunkah/src
Jonathan Lebon ba99f6a80b packing: replace greedy merge with statistical partitioning
The old algorithm used a greedy merge approach (BinaryHeap-based,
minimizing total expected value loss per merge) which was fundamentally
unstable: small changes in input caused completely different merge
decisions, resulting in poor layer reuse across updates.

Additionally, because of its greediness, it easily fell into a local
optimum with a giant catch-all bucket with low stability and safer more
stable items in the other layers.

Replace it with a two-phase statistical partitioning approach inspired
by rpm-ostree's chunking algorithm:

- Phase 1 classifies components by size, giving large components
  (linux-firmware, kernel, firefox) their own singleton layers.
- Phase 2 assigns all remaining components to bins using stability tiers
  (high/mid/low) and deterministic name-based hashing, which ensures
  stable bin membership across builds without needing to track prior
  build state.

Also remove the stability fallback that assigned min(known)/2 to
components without stability data (xattr, bigfiles, unclaimed). These
now stay at 0.0 and are naturally handled by the stability tiers.

Benchmarked against rpm-ostree's native chunking on FCOS F43 (11
biweekly stable releases) and Silverblue F43 (3 weekly builds):

    FCOS:       46.4% reuse, 916 MiB avg download uncompressed (rpm-ostree: 34.0%, 1.2 GiB)
    Silverblue: 47.9% reuse, 2.8 GiB avg download uncompressed (rpm-ostree: 38.5%, 3.5 GiB)

Assisted-by: OpenCode (Claude Opus 4.6)
2026-04-29 22:31:17 -04:00
..
components packing: replace greedy merge with statistical partitioning 2026-04-29 22:31:17 -04:00
cmd_build.rs packing: replace greedy merge with statistical partitioning 2026-04-29 22:31:17 -04:00
main.rs cmd_build: add --trace-logfile for trace-level log output 2026-03-10 20:10:00 -04:00
ocibuilder.rs build: add support for -t/--tag switch 2026-04-08 23:02:06 -04:00
packing.rs packing: replace greedy merge with statistical partitioning 2026-04-29 22:31:17 -04:00
scan.rs scan: add file path pruning to unit test 2026-03-17 21:42:43 -04:00
tar.rs tar: use new uncompressed path in ocidir-rs 2026-03-05 13:28:11 -05:00
utils.rs Implement an ALPM component repository 2026-03-31 22:49:28 -04:00