Skip to main content

Module compact

Module compact 

Source
Expand description

Compaction (M2): rebuild the index without tombstoned rows and without the name bytes renames abandoned in the pools. Without it both grow forever under USN traffic and eventually eat the B/entry RAM budget.

The whole trick is the remapping order: live entries keep their relative id order (old-id ascending β†’ new ids 0..live). Every sorted structure orders by (key, id) with identical keys on both sides, so filtering the dead and renumbering the survivors preserves sortedness β€” perm_name and the FRN index copy over in O(n) with no re-sort (ADR-0009).

Swap-in goes through VolumeSlot::install_index, which bumps the structural generation: open result handles go hard-stale and the UI re-issues its query (docs/ARCHITECTURE.md, generation 2-tier).

ConstantsΒ§

COMPACT_DEAD_NAME_BYTES πŸ”’
Reclaimable pool bytes that trigger compaction regardless of ratio.
COMPACT_MIN_ENTRIES πŸ”’
Below this size the garbage can’t be worth a rebuild.
COMPACT_TOMBSTONE_RATIO πŸ”’
Tombstone share that triggers compaction (matches the OffsetTable’s stale-rebuild instinct: past ~1/8 dead weight, rebuilding wins).