Skip to main content

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