diff --git a/docs/TEX_FIDELITY_ROADMAP.md b/docs/TEX_FIDELITY_ROADMAP.md index e8965bd..bce8f45 100644 --- a/docs/TEX_FIDELITY_ROADMAP.md +++ b/docs/TEX_FIDELITY_ROADMAP.md @@ -60,19 +60,22 @@ execution is not a goal. - `changedPages` already identifies the pages that need repainting. - Incremental bottlenecks: - 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 + (one page), arXiv late edit **p50 187 ms / p95 232 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; + - patch responses are serialised only for changed pages, and display lists + are skipped for unchanged 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; parsing and - geometry are only ~10 ms of the release pipeline, so layout is the target. + - release profiling shows the real bottleneck is **build_document**, not page + layout: for the arXiv late edit geometry ≈5 ms, paragraphs ≈6 ms, + build_document ≈196 ms, layout ≈2 ms. The next optimization must reuse or + cache paragraph units/math layout, not the page breaker. - 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. diff --git a/src/route_d.rs b/src/route_d.rs index d4c65c0..f9c6337 100755 --- a/src/route_d.rs +++ b/src/route_d.rs @@ -102,6 +102,12 @@ fn project_preview_json_with_images_mode( } let mut document = build_document(¶graphs, &geometry); apply_geometry(&mut document, &geometry); + if std::env::var_os("TEXRRA_PROFILE").is_some() { + eprintln!( + "PROFILE build_done={:.1}ms", + started.elapsed().as_secs_f64() * 1000.0 + ); + } let mut sessions = project_sessions() .lock() .map_err(|_| "route-D session lock".to_string())?; @@ -152,7 +158,7 @@ fn project_preview_json_with_images_mode( }; if std::env::var_os("TEXRRA_PROFILE").is_some() { eprintln!( - "PROFILE before_render={:.1}ms", + "PROFILE layout_done={:.1}ms", started.elapsed().as_secs_f64() * 1000.0 ); } @@ -14460,7 +14466,11 @@ fn render_json( let mut lists: Vec = engine .pages() .iter() - .map(|page| { + .enumerate() + .map(|(index, page)| { + if only_pages.is_some_and(|pages| !pages.contains(&index)) { + return DisplayList::default(); + } let mut list = page.display_list_with_layout(document.page_goal, document.text_float_sep); list.width = list.width.max(document.paper_width);