Skip to content

Add a QuadSurface::gen() perf-regression bench (no scroll data)#1081

Open
robert-kofler42 wants to merge 1 commit into
ScrollPrize:mainfrom
robert-kofler42:test/gen-perf-regression-bench
Open

Add a QuadSurface::gen() perf-regression bench (no scroll data)#1081
robert-kofler42 wants to merge 1 commit into
ScrollPrize:mainfrom
robert-kofler42:test/gen-perf-regression-bench

Conversation

@robert-kofler42

Copy link
Copy Markdown

Why

QuadSurface::gen() generates every rendered surface tile (coords + normals + validity) and is on the renderer's hot path. Its warp helpers and per-surface caches (_normalCache, _validMaskCache, the thread_local scratch) were recently optimized and made thread-safe — but nothing guards them against a future regression. This adds a microbenchmark in the same style as the existing VC_RUN_BENCHES benches (bench_volume_sample, bench_chunked_plane_sampler).

What

bench_quadsurface_gen builds a synthetic in-memory QuadSurface (no scroll data) and times gen() with normals + a non-zero w-offset, so the bilinear coords warp, the validity warp, the nearest normal warp and the offset-along-normal pass all engage. It compares:

  • WARM — one surface reused, so the per-surface caches and scratch are built once (steady-state rendering), vs
  • COLD — a fresh surface each iteration, caches rebuilt every time.

WARM must be faster than COLD. The gap is large (~25–40× on my machine, single- and multi-threaded), so the relative assertion is robust on shared CI while still catching a broken cache reuse. The headline WARM throughput (~160 Mpixel/s here) is printed so warp regressions are visible on manual/opt-in runs.

Notes

🤖 Generated with Claude Code

gen() generates every rendered surface tile and its warp helpers / per-surface
caches were recently optimized and made thread-safe, but nothing guarded them
against a future regression. This adds bench_quadsurface_gen, mirroring the
existing VC_RUN_BENCHES microbenches (bench_volume_sample etc.): it builds a
synthetic in-memory QuadSurface — no scroll data — and times gen() with
normals + a non-zero w-offset so the bilinear coords warp, the validity warp,
the nearest normal warp and the offset-along-normal pass all engage.

It compares a WARM path (one surface reused, so _normalCache / _validMaskCache
and the thread_local scratch are built once, as in steady-state rendering)
against a COLD path (fresh surface each iteration, caches rebuilt). WARM must
be faster than COLD; the gap is large (~25-40x here), so the assertion is
robust on shared CI while still catching a broken cache reuse. The headline
WARM throughput is printed so warp regressions are visible on manual runs.

Opt-in via VC_RUN_BENCHES (out of default ctest), always built as a target.
@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the scroll Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant