mirror of
https://github.com/restic/restic.git
synced 2026-07-17 04:34:53 +00:00
Each blob in a repository requires one index entry in memory, which is one of the largest contributors to restic's memory usage. The indexEntry.packIndex field, an index into the per-Index packs slice, was stored as a machine-word int (8 bytes on amd64) although the value is always a small array index. Store it as a uint32 instead. This shrinks indexEntry from 64 to 56 bytes on 64-bit platforms (56 % 8 == 0, so no padding is added), reducing index memory by roughly 12% -- about 100 MB for a repository with ~13 million blobs, as confirmed by profiling. uint32 allows 4.29 billion packs (>30 billion blobs at the assumed 8 blobs/pack), far beyond any real repository; addToPacks guards against overflow defensively. The on-disk repository format is unaffected.