#222·lore

max_size is compared against packstore size only, not total store size

Author: goldyfruitCreated Sep 21, 2026Updated Sep 21, 2026

On v0.10.0, immutable_store.local.max_size is documented as "Maximum total store size in bytes before background compaction reclaims space", but the compactor compares it against packstore_total_size(), which only sums group.packstore.total_size(). Loose fragments and the index aren't counted.

So the number it checks doesn't match what's on disk. On a store that was 2.3 MB across 285 files I got:

Packstore compactor skipping, current size 1661 is below threshold 1048576

1,661 bytes vs 2.3 MB actually on disk. With max_size = 1 MiB the pass never ran even though the store was more than twice the cap.

The other direction is the problem in practice: a store can sit way above max_size on disk while the packstore stays under it, so compaction never fires and the cap does nothing.

The relevant bit in lore-storage/src/local/immutable_store.rs:

rust
pub async fn packstore_total_size(&self) -> usize {
    let mut total_size = 0;
    for group in self.group.iter() {
        total_size += group.packstore.total_size().await.unwrap_or_default();
    }
    total_size
}

and compact_packfiles comparing total_size < max_size to decide whether to run.

Either the trigger should account for the whole store, or the docs should say the cap is packstore-only. As it stands, sizing max_size against expected disk usage gives you a threshold that doesn't correspond to it.