Linora

0506. E2 engine memory: f32 chunk metadata and smaller scratch

Status: Accepted (2026-11-28, EN2). Implements the engine part of ADR 0024’s E2 (chunk metadata 2.4 -> 1.4 B/primitive).

Context

ADR 0024 planned to store chunk metadata in Float32 in E2. ADR 0502 already removed the per-chunk LOD group bounds, so at E1 the metadata was 0.16 B/primitive (1.7 MB for the 4,000-page site), well below the planned 1.4. The engine’s CPU memory at E1 was 7.9 MB (website) and 26.5 MB (5M shapes):

Decision

  1. Chunk bounds in f32, rounded outward. Render and geometric bounds and the LOD sub-area are Float32Array. Every write rounds min down and max up (f32Down / f32Up), so culling, hit candidates and selection boxes stay conservative. Widening (ADR 0503) and bake shifts (ADR 0505) round the same way.
  2. u16 counts and chunk-relative big indexes. Live, selected and remote counts and the big-instance count fit in 16 bits (at most 1,024 per chunk). Big-instance indexes are stored relative to their chunk (u16), so they need no fix-up when chunks move (ADR 0504).
  3. Smaller scratch. The derivation stage covers 32 chunks instead of 64: half the size, and twice as many (still large) uploads. Owner and lock arrays, which only queries read, cover one chunk.
  4. Per-node arrays unchanged. primStart stays an Int32 per node; the selection bitset stays as it is. Scratch arrays grown by one big edit (widen queue, bake ranges, moved nodes) are dropped back to small ones afterwards, so a 5M-node edit leaves no 20-40 MB buffer behind.

Measured (node tools/bench/run.ts --memory, harness page, against docs/perf/memory-baseline.json)

| Scene | E1 total | EN2 total | Ratio (gate <= 1.00x) | Engine CPU E1 -> EN2 | Chunk metadata E1 -> EN2 | |—|—:|—:|—:|—:|—:| | website, 4,000 pages | 617.2 MB | 614.9 MB | 0.510x | 7.9 -> 5.3 MB | 1.69 -> 0.91 MB (0.08 B/prim) | | 5M shapes | 607.5 MB | 605.6 MB | 0.689x | 26.5 -> 24.4 MB | 0.77 -> 0.41 MB |

GPU memory is unchanged: 499.8 MB (website) and 227.1 MB (shapes). The doc’s columns are DC2’s part of E2 (run-length ids).

Alternatives

Consequences