Skip to content

[Performance] Memory-Mapped Metadata Cache (memmap2) #86

@yashksaini-coder

Description

@yashksaini-coder

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:

  1. Memory-map the cache file on startup instead of reading it fully into a String
  2. Deserialize directly from the mmap'd bytes using serde_json::from_slice
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions