Skip to main content

Cache/
AssetMemoryMap.rs

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