Serialise only changed pages for patch previews

render_json now accepts an optional page whitelist. The new
project_preview_patch_json_with_images path passes changedPages before building
page SVGs, instead of serialising all pages and filtering afterwards in the
server. Cache hits still use the old filter helper.

Add scripts/bench-preview.py: repeated buffer edits against a running server,
reporting HTTP/server latency, bytes and changedPages. Measure release builds:
article-basic 37.5 ms (one page), arXiv late edit p50 199 ms / p95 222 ms with
one changed page at 175 KB, arXiv heading edit ~480 ms. This is a solid
improvement over the debug numbers previously quoted, but the 10-page <100 ms
target remains unmet.

TEXRRA_PROFILE=1 now gates the geometry/paragraph/before-render timings. Test
count is 1073 (67 server).
This commit is contained in:
gloamxun committed 2026-10-27 21:36:01 +08:00
1 parent 9231c3a7d6
commit d124c646a1
4 files changed
+162 -14

No files matched your search

+16 -5
View File
@@ -59,12 +59,23 @@ execution is not a goal.
- the web client applies sparse page patches by their `index`;
- `changedPages` already identifies the pages that need repainting.
- Incremental bottlenecks:
- measured warm buffer previews are still about 430 ms for article-basic
and 2.1 s for the arXiv template; the <100 ms target is not met;
- a heading edit reflows page 0 and page 1, so the patch still carried two of
three pages (315 KB of a 396 KB full response) and took 2.66 s;
- release-mode measurements: article-basic warm buffer edit **37.5 ms**
(one page), arXiv late edit **p50 199 ms / p95 222 ms** (one to two of
three pages changed), arXiv early/heading edit about **480 ms**; a
one-page simple document meets the <100 ms target, the 3-page arXiv
template and the 10-page target do not;
- patch responses are now serialised only for changed pages; the arXiv late
edit still carried one page at 175 KB, and a heading edit carried two at
315 KB of a 396 KB full response; cache hits return ~170 bytes and 10–40 ms;
- the `scripts/bench-preview.py` harness reproduces these numbers: initial
full, then repeated small buffer edits with HTTP/server latency, bytes and
changedPages;
- there is no WebSocket/SSE stream yet, only request/response patches;
- layout is still full-document after parsing the whole buffer.
- layout is still full-document after parsing the whole buffer; parsing and
geometry are only ~10 ms of the release pipeline, so layout is the target.
- Developer profiling: `TEXRRA_PROFILE=1` prints geometry/paragraph/before-render
timings from the project preview path. Earlier notes in this document used a
debug binary (430 ms/2.1 s) and overstate the release latency.
## Architecture