Goal
Handle very large package caches (millions of entries) without high memory overhead.
Description
If the JSON details cache grows very large (e.g., on systems with thousands of packages across multiple backends), standard File::read_to_string becomes expensive.
Investigate and implement memory-mapped file access using the memmap2 crate:
- Memory-map the cache file on startup instead of reading it fully into a
String
- Deserialize directly from the mmap'd bytes using
serde_json::from_slice
- Benchmark the improvement for cache files > 10MB using
std::time::Instant or criterion
Important: memmap2 is unsafe — document the invariants carefully and consider whether the complexity is worth it vs. other approaches (e.g., sqlite via rusqlite).
Tech
Rust, memmap2, Memory Management
Difficulty
Level 3 – Advanced
Goal
Handle very large package caches (millions of entries) without high memory overhead.
Description
If the JSON details cache grows very large (e.g., on systems with thousands of packages across multiple backends), standard
File::read_to_stringbecomes expensive.Investigate and implement memory-mapped file access using the
memmap2crate:Stringserde_json::from_slicestd::time::InstantorcriterionImportant:
memmap2isunsafe— document the invariants carefully and consider whether the complexity is worth it vs. other approaches (e.g.,sqliteviarusqlite).Tech
Rust,
memmap2, Memory ManagementDifficulty
Level 3 – Advanced