Pre
Pre-Suite
Cold prepare() + Hot Pure-Math
20 Zero-Reflow Browser & JS Engines · v1.1.0

Compile Once. Run Every Frame in Pure Math.

Pioneered by Cheng Lou's Pretext, the Cold prepare() + Hot Pure-Math pattern eliminates synchronous DOM reflows, C++ boundary crossings, object-graph rebuilds, and structured-clone stalls — packing state once into flat TypedArrays so every interactive frame executes in microseconds.

⚡ All-20 Live Cockpit — Run all 20 engines simultaneously (5×4) →
20
Live Engines
0
Runtime Deps
12×–17,400×
Verified Speedups
Real-time 60fps text layout & dynamic obstacle reflow bypassing DOM getBoundingClientRect(). prepareWithSegments() → layoutNextLine()
Zero DOM Reflow · 60 FPS Open full screen ↗

Verified Benchmark Matrix

Empirical measurements from Headless Chromium and Node.js v22 (`--expose-gc`), comparing hot pure-math execution against native/conventional paths.

Engine What It Bypasses Cold prepare() Cost Verified Hot Speedup Memory / Allocations Demo
Pretext @chenglou/pretext (Cheng Lou) DOM text measurement & forced layout reflow (offsetHeight, getBoundingClientRect) One-time Canvas glyph width segmentation 60fps obstacle & resize reflow (sub-ms pure math) Zero DOM reads on hot path pretext.html ↗
PrePath SVG Geometry & CSR Grid Blink/Skia C++ SVG DOM calls (getPointAtLength, isPointInStroke, getBBox) 16.4 ms (500 paths) · 115.5 ms (2,000 paths) 135×–267× point · 1,113×–7,447× hit-test 0 B/query via reusable out structs prepath.html ↗
PreDAG Flat-CSR Sugiyama DAG Full object-graph Sugiyama rebuilds (rank, dummies, crossings) on every node resize 1.39 ms (500 nodes) · 17.5 ms (2,000 nodes) 68×–78× (PAVA) · 297×–516× (center) 0.0 KB/call vs 3.88 MB/call predag.html ↗
StreamDiff Streaming LLM Code Diff O(N³) per-token full-file Myers diffing & red-deletion tail flicker 1.96 ms (1.2k lines) · 4.67 ms (3k lines) 787×–4,162× hot vs per-line (180×–833× vs 5-line) 95%+ O(1) FNV-1a fast-path · 0 flicker streamdiff.html ↗
WorkerSlab Zero-Copy Columnar Slab postMessage V8 Structured Clone stalls & O(N log N) JS Array.sort Direct-to-slab on Worker (7.81 MB / 100k rows) 479×–656× E2E transfer · 17×–41× sort +0.027 MB main heap vs +29.7 MB workerslab.html ↗
PreMasonry Pretext + Float32 Masonry DOM masonry height probes (offsetHeight forced reflow) & full 5k-node DOM trees 697 ms (5,000 mixed image+text cards via Pretext) 181.0× faster (4.20 ms vs 760.38 ms avg) ~9–15 mounted DOM nodes · O(cols·log N) search premasonry.html ↗
PreTimeline LOD Mipmap Flamegraph O(N) full-span canvas draws & linear hit-testing across 100,000 intervals (24 lanes) Flat TypedArrays + maxEndPrefix + 6-level LOD 134.2× (10h LOD) · 42.4× (10m) · 6.7× (1ms) 0 hot-path allocs · <1.5px sub-pixel clustering pretimeline.html ↗
PreHit 2D Affine OBB + CSR Grid DOM getBoundingClientRect() thrash & AABB corner false positives on rotated cards 16.40 ms (2,000 rotated cards + 27×16 CSR grid) 40.3× determ. (0.20 vs 8.05 ms) · 56.8× live 0 allocs · Uint32Array dedup · exact SAT OBB prehit.html ↗
PreScroll Fenwick Virtual Scroll O(N) prefix-sum rebuilds & scroll jitter under live streaming variable-height mutations O(N) bottom-up Float64Array Fenwick Tree (100k rows) 468×–573× Chromium · 2,053× Node (0.02 ms) 0 hot-path allocs · O(log N) binary lifting prescroll.html ↗
PreSyntax Stateful Incremental Lexer Full-file O(N) re-tokenization on every keystroke across 5,000-line TypeScript files Bit-packed Uint32Array (30,628 tokens) + EOL states 1,168× single-line edit (0.010 vs 11.68 ms) 1/5,000 lines touched · exact 17-line /* exit presyntax.html ↗
PreCalc 100k-Cell RPN Spreadsheet DAG Recursive AST formula evaluation & diamond re-evals across 100,000 spreadsheet cells Kahn topo-permuted RPN bytecode + CSR edges (128k edges) 63.2× Chromium (0.77 vs 48.48 ms · 14k dirty cone) 0 hot-path allocs · L1 2-level bitset PQ precalc.html ↗
PreGrep Flat-CSR Trigram Log Search O(N) .includes() & RegExp.test() full scans across 200,000 log lines 1,188 ms (200k lines · 46.4 MB UTF-8 arena + 18-bit CSR) 145.1× substr (0.88 vs 128.2 ms) · 97.7× regex 0 hot-path allocs · 4-line superblock postings pregrep.html ↗
PrePoly CSR Grid + Y-Slab Choropleth O(N·V) GeoJSON polygon scans & divisions on 5,000 concave polygons w/ 1,000 holes 83–91 ms (18.6 MB CSR grid + division-free Y-slabs) 4,496×–5,213× Chromium · 10,058× Node (2.98 ms / 10k pts) 0 hot-path allocs · unified outer+hole parity prepoly.html ↗
PreFacet Bitset + Prefix-XOR BI Engine Full-table .filter() & recount stalls across 250k BI rows, 6 cat dims & 2 ranges 150.7 ms (250k rows · 4-pass LSD radix + prefix-XOR) 78.8× Chromium (1.77 vs 139.3 ms) · 70.9× Node 0 hot-path allocs · 16-bit POP16 bitset AND prefacet.html ↗
PreWave 10M-Sample Min/Max Pyramid O(N) linear min/max scans over 10,000,000 Float32 audio/market samples per zoom frame 253.4 ms (9.54 MB 21-level pyramid · 25% overhead) 436.6× mip (0.106 vs 46.3 ms) · 660.1× Node 0 hot-path allocs · 0 dropped peaks · 12.2 µs update prewave.html ↗
PreLabel Tile-CSR + Bitmask Labeler O(N log N) sort + O(N²) overlap checks across 50,000 map & star-catalog labels 58 ms (64×64 World-Tile Priority CSR + 8×8 bitmasks) 97.9× Chromium (0.53 vs 51.9 ms) · 132.6× Node 0 hot-path allocs · mask + priority overrides prelabel.html ↗
PreBin Zero-Parse Binary & Shards JSON.parse() startup stalls, GC heap bloat & monolithic payload downloads (35k rows) One-time packColumnar() / 256-bucket packShards() 529× boot (0.10 vs 52.88 ms) · 233× less shard I/O +0.003 MB heap (0 JS objs) · 58% smaller payload prebin.html ↗
PreBatch2D Color-Bucketed 2D Canvas Per-node beginPath/arc/fill C++ state thrash across 35,000 2D nodes & idle rAF burn 17.3 ms (35k nodes · 20 color buckets + 20×16 CSR tiles) 120.1× full-view (4.70 vs 564.7 ms · 20 vs 35k draws) 1,749× fewer draw calls · 0% idle CPU sleep prebatch2d.html ↗
PreGraph CSR Bi-BFS & Ego-Nets Naive Map/Set BFS allocations & full-component scans on 30k-node graphs 17.4 ms (30k V · 55k E · flat CSR + 1,051 compIds) 23.5× Bi-BFS (0.27 vs 8.5 ms) · 17,400× disc. guard 0 hot-path allocs · gen-stamped scratch + masks pregraph.html ↗
PreArc Analytic Quadratic Bezier SVG d-string re-serialization & 28-segment polyline flattening on dynamic arc hubs 0.068 ms (250-arc dynamic hub recompile · 68 KB flat) 12.4× recompile (0.068 vs 0.844 ms) · 4.7× combined 0 hot-path allocs · exact depressed-cubic hit-test prearc.html ↗

The Cold / Hot Architecture Pattern

Every engine in Pre-Suite isolates expensive structural or browser work into a one-time cold phase so the interactive hot loop touches only flat numbers.

Pretext Text
Cold · prepare() Segments text and measures word/grapheme advances once via Canvas 2D.
Hot · layoutNextLine() Wraps lines around dynamic widths & moving obstacles in pure arithmetic.
PrePath SVG
Cold · prepareScene() Adaptively flattens all 20 SVG commands into Float64Arrays + CSR spatial grid.
Hot · hitTestScene() O(1) grid cell lookup, closest-point snap, and O(log N) arc-length evaluation.
PreDAG Graphs
Cold · prepareDAG() Cycle breaking, layering, virtual bendpoints, and crossing sweeps packed into CSR Int32Arrays.
Hot · layoutDAG() Zero-alloc O(L) PAVA barycenter coordinate pass on every resize or accordion frame.
StreamDiff Streaming
Cold · prepareBaseline() FNV-1a hashes every baseline line into Uint32Array + strong anchor map.
Hot · pushToken() O(1) cursor hash match + bounded local Myers on resync with calm dimmed tail.
WorkerSlab Workers
Cold · createSlabWriter() Packs typed columns + UTF-8 arena into one transferable ArrayBuffer on the Worker.
Hot · openSlab() + sort() Zero-copy ownership transfer, lazy viewport flyweight decode, O(N) LSD radix & dict sort.
PreMasonry Masonry
Cold · prepareMasonry() Pre-measures 5,000 mixed image+text cards via Pretext into flat Float32Arrays.
Hot · layoutMasonry() 4.2 ms pure-math column packing & O(cols·log N) binary-search DOM virtualization.
PreTimeline Timeline
Cold · prepareTimeline() Packs 100k spans into flat TypedArrays with maxEndPrefix & 6-level LOD mipmaps.
Hot · queryViewport() Zero-alloc LOD run-merging, O(log N) binary search, and sub-pixel clustering.
PreHit Hit-Test
Cold · prepareTransformTree() Flattens 2D affine trees into Float64Arrays, OBB SAT vectors, and a CSR spatial grid.
Hot · hitTestPoint() / marquee Zero-alloc CSR lookup + exact inverse-affine & SAT rotated-OBB intersection.
PreScroll Virtualize
Cold · prepareScroll() Builds flat Float64Array heights + O(N) bottom-up Fenwick Tree for 100k rows.
Hot · updateHeight() / window Zero-alloc O(log N) height updates & single-pass Fenwick binary lifting at 60 FPS.
PreSyntax Lexer
Cold · prepareSyntax() Lexes 5,000 TS lines once into bit-packed Uint32Array token spans + Uint8Array states.
Hot · editLine() Re-lexes only mutated lines and early-exits the instant end-of-line state converges.
PreCalc Sheet DAG
Cold · prepareSheet() Compiles 100k formulas into Kahn topo-permuted RPN bytecode + CSR dependency edges.
Hot · setCell() L1 2-level bitset PQ evaluates only the dirty cone once with 1e-12 delta pruning.
PreGrep Trigram
Cold · prepareGrep() Packs 200k log lines into a flat UTF-8 byte arena + 18-bit CSR trigram superblock index.
Hot · searchSubstring() Intersects postings in zero allocs, verifies bytes in-place, and fills 64-bin minimap.
PrePoly Geo PiP
Cold · preparePolygons() Builds 128×128 CSR spatial grid + division-free Y-slab edge strips for 5k concave polys.
Hot · classifyPointsBatch() Zero-alloc O(1) cell + Y-slab ray parity classifies 10k GPS particles with holes live.
PreFacet BI Filter
Cold · prepareFacets() Packs 250k rows into categorical bitsets + LSD radix-sorted prefix-XOR range checkpoints.
Hot · queryFacets() Zero-alloc bitset AND + POP16 disjunctive recount & 32-bin histogram in 1.7 ms.
PreWave Waveform
Cold · prepareWave() Builds a 21-level min/max mipmap pyramid over 10M Float32 samples (25% overhead).
Hot · queryRangeMip() O(pixels) mip lookup with zero dropped peaks & O(log N) 12 µs live sample updates.
PreLabel Placement
Cold · prepareLabels() Packs 50k prioritized labels into 64×64 World-Tile Priority CSR + 8×8 occupancy bitmasks.
Hot · placeLabels() Zero-alloc K-way heap + bitmask filter & priority overrides place crisp non-overlapping labels.
PreBin Binary
Cold · packColumnar() Packs typed columns + UTF-8 arena into aligned ArrayBuffers & 256 FNV-1a static shards.
Hot · openColumnar() O(1) zero-parse TypedArray views in 0.10 ms with 0 JS objects allocated & lazy UTF-8 decode.
PreBatch2D Canvas 2D
Cold · prepareBatch2D() Sorts 35k nodes by colorId into flat contiguous buckets + uniform 20×16 spatial tile CSR.
Hot · renderBatch2D() 1 batched fill per color bucket (20 vs 35k draws), bitset mask culling & idle-sleep rAF loop.
PreGraph Graph CSR
Cold · prepareGraph() Packs 30k V / 55k E into flat Uint32Array CSR + O(V+E) connected component IDs & scratch.
Hot · shortestPath() O(1) component early-reject (17,400×) + gen-stamped Bi-BFS & k-hop ego-net extraction.
PreArc Bezier
Cold · createArcBuffer() Pre-allocates flat Float64Arrays for polynomial invariants & tight analytic quadratic AABBs.
Hot · hitTestArcs() AABB-culled closed-form depressed-cubic closest-point solver & exact tangent/length evals.