Mountain/Cache/AssetMemoryMap.rs
1
2//! Memory-mapped asset cache for the bundled workbench (and any other
3//! static-disk asset served via `vscode-file://`, `tauri://`, or `land://`
4//! scheme handlers).
5//!
6//! ## Why MemoryMap and not `Vec<u8>`
7//!
8//! The bundled workbench under `Element/Sky/Target/Static/Application/` ships
9//! ~80 MB of `.js`, `.css`, `.svg`, and font assets. Per-request `fs::read`
10//! pays a `read(2)` + alloc + memcpy of the full file; a `LRU<String,
11//! Vec<u8>>` cache duplicates the kernel page cache (memory held twice).
12//! `memmap2::Mmap` hands the webview a borrowed slice of file-backed pages
13//! that the OS evicts under pressure.
14//!
15//! ## Brotli sibling
16//!
17//! Each entry transparently picks up an optional `<file>.br` produced by
18//! `Maintain/Build/Brotli/Pre-Bake.ts`. Scheme handlers can serve the
19//! pre-compressed bytes with `Content-Encoding: br` when the client offers it.
20//!
21//! ## Concurrency / eviction
22//!
23//! `DashMap` shards are wait-free for read; first-load races on one shard
24//! lock. No eviction today - bundle is bounded by ~80 MB.
25
26pub mod CacheStats;
27
28pub mod Clear;
29
30pub mod Entry;
31
32pub mod Invalidate;
33
34pub mod LoadOrInsert;
35
36pub mod Stats;
37
38pub(crate) mod Map;
39
40pub(crate) mod MimeFromExtension;