Expand description
Memory-mapped asset cache for the bundled workbench (and any other
static-disk asset served via vscode-file://, tauri://, or
land:// scheme handlers).
§Why MemoryMap and not Vec<u8>
The bundled workbench under
Element/Sky/Target/Static/Application/ ships ~80 MB of .js,
.css, .svg, and font assets. Per-request fs::read pays a
read(2) + alloc + memcpy of the full file; a
LRU<String, Vec<u8>> cache duplicates the kernel page cache.
memmap2::Mmap hands the webview a borrowed slice of file-backed
pages the OS can evict under pressure.
§Brotli sibling
Each entry transparently picks up an optional <file>.br produced
by Maintain/Build/Brotli/Pre-Bake.ts. Scheme handlers serve the
pre-compressed bytes with Content-Encoding: br when the client
offers it.
§Concurrency / eviction
DashMap shards are wait-free for read; first-load races on one
shard lock. No eviction today - the bundle is bounded by ~80 MB.
Modules§
- Cache
Stats - Snapshot of asset-cache occupancy. Returned by
super::Stats::Fn. - Clear
- Clear the entire asset cache. Called on shutdown or on an explicit flush signal.
- Entry
- Single MemoryMap-backed asset cache entry. Holds the file-backed mapping plus metadata computed once at load time.
- Invalidate
- Drop a single cached entry. Useful for hot-reload during dev when the bundler rewrites a chunk.
- Load
OrInsert - Load
Pathinto the cache (or return the existing entry). - Map 🔒
- Process-global asset cache backing store. Lazily initialised on first request.
- Mime
From 🔒Extension - Map a file extension to its IANA media type. Mirrors the inline
helper Mountain uses in
Binary/Build/Scheme.rsso the cache layer is self-contained. - Stats
- Snapshot of asset-cache stats for diagnostics.