Skip display lists for unchanged pages and profile the build

Patch previews now pass onlyPages into render_json before display-list
construction, so unchanged pages skip both glyph-list building and SVG
serialization. Late arXiv edits drop to p50 187 ms / p95 232 ms; article-basic
stays at 37.5 ms.

The gated profiler now reports build_done/layout_done. Release numbers show the
real bottleneck is build_document (~196 ms), while page layout is ~2 ms;
optimizing the page breaker will not reach <100 ms. Record that finding in the
roadmap. Test count stays 1073.
This commit is contained in:
gloamxun committed 2026-10-27 21:41:56 +08:00
1 parent d124c646a1
commit da30705cd0
2 files changed
+21 -8

No files matched your search

+12 -2
View File
@@ -102,6 +102,12 @@ fn project_preview_json_with_images_mode(
}
let mut document = build_document(&paragraphs, &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<DisplayList> = 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);