v5 Performance
v5 performance: rendering in the browser
The plan for v5 is to run the whole engine in the visitor’s browser, with nothing to install and no server doing the work. That only makes sense if a Render stays fast. The slowest step of a Render is the Minkowski draft sum: one per character, each widening the glyph into its tapered root. So that’s what we measured first.
Result
The same 88 Minkowski sums a real Selectric I/II Render performs, spread across Web Workers in Chrome. Each worker is a separate copy of manifold’s WebAssembly geometry engine:
| Workers | Wall time | vs 1 worker | vs native (30.4 s) |
|---|---|---|---|
| 1 | 86.9 s | 1.0x | 2.86x slower |
| 2 | 45.8 s | 1.9x | 1.51x slower |
| 4 | 27.6 s | 3.1x | 1.10x faster |
| 8 | 19.1 s | 4.5x | 1.59x faster |
| 14 | 16.7 s | 5.2x | 1.82x faster |
| 16 | 16.7 s | 5.2x | 1.82x faster |
What it means
- Two workers are almost exactly twice as fast (1.9x). Each character’s sum is independent of every other, so the work splits cleanly.
- The browser beats native Python from 4 workers up. At 14-16 workers it finishes in 16.7 s against native’s 30.4 s. Native manifold parallelises inside each sum. The worker pool runs whole characters side by side, which keeps the cores busier.
- The gains flatten past 8 workers. This laptop has 8 physical cores; the other 8 threads are hyper-threads sharing them. The floor is the single slowest character (“@”, about 5 s in WebAssembly). No pool can finish before its longest job.
- The geometry is identical. Every character’s volume matches the native result to within 0.0001%. Triangle counts differ slightly because the triangulation differs, but the solid is the same.
- It needs no special hosting. Workers don’t share memory, so none of the cross-origin-isolation headers GitHub Pages can’t send are required.
Full build in the browser (phase 2)
v4’s own unmodified Python, running in the tab under Pyodide, building a complete Selectric I/II element on the same laptop. Details and how it works.
| native Python | browser | output vs native | |
|---|---|---|---|
| Preview | 2.6 s | 6.7 s | identical |
| Render, one thread | 32.0 s | 96.0 s | identical |
| Render, 16-worker pool | 32.0 s | 28.3 s | identical volume |
“Identical” means the same vertex count, face count and volume: the line v4’s own verification compares. With the worker pool, a full Render is faster in the browser than native Python. The first visit also downloads the engine, about 6 s on this connection; it’s cached after that.
Caveats
- One machine. These numbers come from one laptop. Fewer cores means a higher floor, but the 2-worker speed-up should hold almost anywhere.
- One machine type. Only the Selectric I/II has been built in the browser so far. The other machines use the same adapters and should follow.
Reproduce
v4/.venv/bin/python3 v5/spike/export_minkowski_inputs.py # captures the 88 pairs, times native
python3 -m http.server 8092 --directory v5/spike # then open:
# http://127.0.0.1:8092/bench.html one thread
# http://127.0.0.1:8092/bench_workers.html worker pool, 1..16 workers
Record a new run in v5/docs/worker_scaling.json and regenerate the chart
with python3 v5/docs/make_worker_chart.py. The raw single-thread log and
version comparison are in v5/spike/RESULTS.md.