Skip to content

Storage: return shared handles from get and move the disk cache into a store wrapper #2029

Open

Description

@bplatz

Follow-up to #2018 and zonotope's review there.

Readers decide how to read by asking the store around the trait: resolve_local_path (39 call sites), resolve_cached_bytes (54), is_remote, permits_plaintext_cache, and since #2018 resolve_local_bytes. The disk cache sits outside every store and needs those answers. That is why cache_dir is threaded through 28 files and why the cache leaked local storage until #2018.

Proposed, in shippable stages:

  1. ContentStore::get returns a shared, read-only handle that derefs to [u8]: owned bytes, Arc<[u8]>, or an mmap.
  2. One synchronous, non-blocking get returning bytes or None replaces resolve_local_path, resolve_cached_bytes and resolve_local_bytes. File storage returns an mmap, memory storage an Arc clone.
  3. CachedContentStore<S> takes over the disk cache: coalesced fetches, the byte budget, eviction, write-through on put, and range reads served from the cache file. Only the code that assembles the store stack knows a store is remote. This removes is_remote, uses_disk_cache, needs_disk_copy, seed_disk_cache, fetch_cached_bytes* and the cache_dir threading.
  4. Encryption sits above the cache, so the cache holds ciphertext. permits_plaintext_cache goes away. Encrypted remote stores get a disk cache for the first time; today every miss re-fetches the whole object, because AES-GCM rules out range reads.

Performance constraints:

Out of scope: the wasm residency tier (miss register / NeedFetch).

The open annotation_hydration/scan gap from #2018 is tracked in #2030; this refactor rewrites the read path it most likely sits on, so re-measure it after stage 2.

Activity

  1. added
    enhancement
    P2
    area:storage
    performance
    on Oct 7, 2026
  2. bplatz commented on Oct 20, 2026

    @bplatz
    ContributorAuthor

    From #2130: get_local_ranged, a defaulted method on StorageRead/ContentStore that the leaf, forward-pack and reverse-leaf openers call, and costly_local_reads are reader-side probes of the same shape as permits_plaintext_cache. With encryption above the cache, stage 4 should retire them too.

  3. bplatz commented on Nov 20, 2026

    @bplatz
    ContributorAuthor

    Status: stages 1–3 landed on next in #2035 (merged 2026-10-14). Stage 4, encryption above the disk cache, remains. Encrypted remote stores stay uncached until it lands.

  4. added this to the 5.0.0 milestone on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2area:storageenhancementperformance

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions