Background
Currently, when entries shrink or move between pages, trailing pages may remain empty but uncollected, leading to unnecessary file growth and memory-mapped region expansion. This impacts both disk space and RSS without providing functional benefits.
Goal
Reduce file size and memory footprint by trimming trailing unused pages.
Proposal
Introduce a post-write and post-delete check to detect and truncate trailing empty pages. If the last page (or consecutive pages at the end) has no live entries, unmap and remove it from memory, then truncate the underlying file. Ensure truncation triggers only after all pending writes complete to maintain mmap safety.
Background
Currently, when entries shrink or move between pages, trailing pages may remain empty but uncollected, leading to unnecessary file growth and memory-mapped region expansion. This impacts both disk space and RSS without providing functional benefits.
Goal
Reduce file size and memory footprint by trimming trailing unused pages.
Proposal
Introduce a post-write and post-delete check to detect and truncate trailing empty pages. If the last page (or consecutive pages at the end) has no live entries, unmap and remove it from memory, then truncate the underlying file. Ensure truncation triggers only after all pending writes complete to maintain mmap safety.