docs(docs): RUST.md §10.11 R4.9 record: memory bench by dimension (linear flat after init, objects and URLs released, Chromium per-export growth = the browser's raster path, bounded at a plateau, control without the core identical), full checks, report:compare dry run; Chromium 16-step series and raster control results

This commit is contained in:
bchanot committed 2026-10-20 21:14:36 +02:00
1 parent ecc8699074
commit eeae015bc4
3 files changed
+3245

No files matched your search

+129
View File
@@ -2091,3 +2091,132 @@ semantics, the determinism and count suites, the R3 layer oracle) are in
place; `documentSha256` will change once (D-R5) and every older archive will
rebase on import; `@xmldom/xmldom`, `tsx` and `prettier` on generated files
leave with them.
### 10.11 R4.9: final checks, memory bench, audits (2026-10-20)
The owner's R4.9 brief: final verification without new development, the
memory bench before any merge (the R4.6 Chromium reserve stays open until
measured), the import risks classified, the J1 / J2 recettes re-issued, the
independent verifier and security audit. Contract
`.claude/tasks/contracts/2026-10-20-rust-r4-final-1000.md`.
Memory bench (`scripts/browser/r4-memory-bench.mjs`, probes in
`lib/memory-probes.mjs`, results `scripts/browser/results/2026-10-20-r4-memory-bench*.json`;
build f36dbdd, module `faunosteo_wasm_bg-9CH7GQ4e.wasm` 1,535,289 B; i7-11700B,
16 threads, 15.8 GB; Chromium 156, Firefox 157, WebKit 27.2, headless). One
editor tab per engine and report, the start level, the init export, then
6 exports (16 for the Chromium series below), then four rest windows:
settled (5 s), after the 30 s `downloadBlob` revocation window, Home (the
editor left by its link, the page and its runtime kept), Home idle (10 s);
Chromium ends with a simulated critical memory pressure (CDP). Every reading
tells apart (1) the module's linear memory, read on the page's live
`WebAssembly.Memory`, (2) the renderer RSS (and the summed RSS of the
browser tree), (3) the live canvases, images, bitmaps, Blobs and PDF Blobs
(created − collected, FinalizationRegistry) and the object URLs (created −
revoked), plus in Chromium the precise JS heap, the DOM counters and a heap
snapshot census of the same classes, (4) the transient peak of the renderer
during each export, (5) what each rest window keeps against the level after
the init export. Chromium readings follow a forced GC; Firefox and WebKit
are read after idle only (no forced GC: their RSS figures are indicative,
their collection counts are not forced).
Renderer RSS, MiB (absolute; linear memory in the last column):
| Engine | Report | Start | After init | After 6 | Settled | After revoke | Home | Home idle | Max peak | Linear after init (then flat) |
|---|---|---|---|---|---|---|---|---|---|---|
| Chromium | demo | 150 | 190 | 204 | 202 | 197 | 198 | 188 | 302 | 18.8 |
| Chromium | L | 155 | 260 | 393 | 389 | 395 | 395 | 386 | 626 | 63.8 |
| Firefox | demo | 160 | 241 | 461 | 426 | 332 | 331 | 287 | 628 | 18.8 |
| Firefox | L | 168 | 516 | 432 | 420 | 280 | 280 | 237 | 1,147 | 63.0 |
| WebKit | demo | 319 | 466 | 820 | 820 | 813 | 815 | 813 | 944 | 18.8 |
| WebKit | L | 329 | 666 | 758 | 758 | 752 | 757 | 754 | 2,129 | 55.0 |
What each dimension shows:
1. Linear memory: the init export grows it once (demo +14.2 MiB, L +50 to
59 MiB: the file held once plus the transients, OD-2), then 0.0 MiB on
every later export in the three engines, through 16 exports in Chromium,
and nothing after the rest windows or Home (it never shrinks, by design,
until reload). One instance, never re-instantiated. The session frees
everything it holds at `free()` and the next export reuses it.
2. Renderer RSS: see below for Chromium. Firefox ends below its post-init
level on L once the revocation window passes (−279 MiB at Home idle) and
46 MiB above it on demo, a sawtooth without forced GC. WebKit climbs over
the first three demo exports, then stays flat (export 3 to 6: +0.1, +5.5,
+0.3; Home idle 813 against 820 after the sixth) and grows 54 MiB over
the last five L exports, flat over the rest windows: a high-water reached
early, not a slope per use; no forced GC there, so the figure is the
engine's lazy return.
3. Canvases, images, Blobs, object URLs: every canvas, Blob and PDF Blob the
exports created was collected in Chromium (847 / 847 on L), Firefox (L
847 / 847; demo 54 / 56 without a forced GC) and WebKit; the 4 images
still alive are the page's own (header logos); every object URL was
revoked once the 30 s window had passed (854 / 854 on L), none during it
but the downloads'. The Chromium heap census holds one canvas element and
no image beyond the page's own after the series; the precise JS heap
stays at 6.8 to 8.4 MiB (7.4 at Home). No DOM node, document or listener
accumulates (L: 3,364 nodes after every export).
4. Transient peaks: per export, the renderer rises 86 to 112 MiB on demo
and 220 to 390 MiB on L in Chromium, 350 to 600 MiB on L in Firefox and
about 1.3 GiB on L in WebKit (its rasterisation, 50 s per export), then
falls back; none approaches the harness ceiling.
5. Durable retention: Chromium is the only engine whose settled level keeps
rising with exports on L, so it got its own series and a control.
Chromium, L, 16 exports, and the raster-only control (`--mode raster`:
after the init export, each step replays the rasteriser's own steps on the
view drawings the init export drew, at its sizes, with no core call),
renderer RSS after each step (MiB):
| Run | Init | Steps 1 to 8 | Steps 9 to 16 | Last 5 | Home idle | After critical pressure |
|---|---|---|---|---|---|---|
| Export (core session + rasteriser) | 264 | 287 → 428 (+20 per step) | 439 → 436 | −7.3 | 437 | 438 |
| Control (rasteriser only, no core) | 262 | 286 → 429 (+21 per step) | 433 → 438 | +3.8 | 436 | 437 |
Reading. The growth of about 20 MiB per L export in Chromium is the
browser's raster path, not the session's: the control, which never calls
the core, grows by the same amount at every step and reaches the same
plateau (436 against 437 MiB); the module's linear memory is flat, the JS
heap flat, no canvas, Blob or URL survives. Both runs stop growing after
the eighth step and stay flat for eight more (last five: −7.3 and +3.8
MiB, inside the 10 MiB criterion of BDR-058). A simulated critical
pressure does not return it, so it is memory the renderer keeps (an
internal raster or decode cache, or allocator pages it does not release)
rather than objects the page holds. The R4.6 observation is confirmed and
now explained: bounded at about 170 MiB above the post-init level for 120
views of 1200 px per export, reached after about 8 L exports, identical
without the core; the deleted TypeScript engine showed the same figures
(§10.8 control). On demo the same path costs about 2 MiB per export.
Class: not a retention of the export (the core frees everything; the page
keeps no canvas, image, Blob or URL); not blocking. Severity: a desktop tab
that exports L eight times carries about 170 MiB more until it is closed;
a phone that exports L repeatedly is J2.7 and J2.6's object (the device
run, not the headless one, decides). Correction proposed only if a device
shows it: draw every view on one reused canvas (or an `OffscreenCanvas`)
instead of a new canvas per view, measured with this same bench against the
control before any adoption; no change made at R4.9 (no measure says it
would help, and the rasteriser's output is pinned pixel-identical).
Proof `pnpm report:compare` (J2.14 dry run): the R3 demo PDF and an R4
session export of the bilan it carries (shipped module, stub rasters):
`--diff` prints `identical v3 content`, exit 0 (first run 25 s: the tool
compiles); the single listing has no `!!` line, 0 unresolved.
Full checks (2026-10-20, f36dbdd): `pnpm check:all` green in 2 min 37 s:
rust-check (fmt, clippy -D warnings, cargo test, ts-rs, deny; advisories
ok), types drift none, wasm:build, Node typecheck + tests (app 427, core-wasm
58, domain 262, anatomy 131, supabase 40) + lint 0 + build, the application
image, the worker sandbox tests and the read-only worker image. Ledger:
301 rows, 0 pending, every target present (`node scripts/r4-ledger.mjs`
regenerates the committed TSV byte for byte). Frozen oracles and goldens:
nothing frozen at R4.1 (aada799) differs but the two R4.2 additions; the
R4 digests are unchanged since their declared R4.6 re-freeze (d492bf7).
WASM size: 519,795 B gzip -9, the 600 KB budget and the 550 KB report
line unchanged in `packages/core-wasm/tests/size.test.ts`.
Import security: the open points are classified in
`PDF_IMPORT_HARDENING.md` §6 (fixed with proof, accepted temporarily,
blocking before merge, before public exposure). J1 / J2: `R4_J1.md` and
`R4_J2.md` re-issued on this build with the OD-6 device list; every result
cell stays NON TESTÉ until the owner runs it.
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff