Skip to content

render-pipeline: seed label pages from the previous request's convergence (perf A) - #652

Merged
GoKubar merged 1 commit into
mainfrom
agent/kabir-claude/label-pages-seed
Sep 16, 2026
Merged

GoKubar merged 1 commit into
mainfrom
agent/kabir-claude/label-pages-seed

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Phase 2, step A of the warm-repaint work (follows #651 = step C; independent branches, no overlap).

Problem

Every request starts labels.pages/labels.toc_pages empty, so a document with \pageref or a contents list can never converge on pass 1: the whole adapt+typeset pipeline runs twice per keystroke even when no page number moved. On the 398-page #535 article with toc+\pageref that is ~700 ms per typed character — double the plain document.

Change

The converged page tables are stored in RenderCache (keyed by project) and seed the next request's first pass — the role LaTeX's .aux plays between runs. No page moved → pass 1 converges, relayout saved. A real move fails the (unchanged) convergence check and relays out with fresh tables, bounded by the same MAX_LABEL_PASSES. Nothing is stored on a non-converged (pass-limit) request; another project's tables never seed.

Verification

  • New tests (tests/label_page_seed.rs): unchanged text → 1 pass, byte-identical v2; typed char that moves nothing → 1 pass, byte-identical to a fresh-cache compile of the edited text; page-moving edit → ≥2 passes, byte-identical to a fresh compile; per-project isolation.
  • 67/67 byte-identical --v2+--pdf vs main 18bbacf0 (65 fixtures entries + the 398-page article both ways).
  • perf-bench (FT-070: engine performance harness, committed baseline and a >5% regression gate #206), interleaved base→A→base with --pin: zero digest changes, including every warm.<scenario>.<caps> digest — warm outputs through the harness are byte-identical. hyperref-toc warm improves 28–40% (noise bands 3–5%). Flagged timing "regressions" reproduce identically in the base-vs-base control leg (up to +50% on cold phases this change does not execute, at load 5–8), i.e. shared-box noise per the gate's own load warning — happy to rerun on a quiet box before merge.
  • xref_measure interleaved A/B/A/B (450 sections / 398 pages): toc+pageref no-label warm edit 2 passes / ~700 ms → 1 pass / ~435 ms handle (render ~630 → ~363 ms). renumber / move-label keep 2 passes, match base within noise; plain-document rows untouched.
  • cargo test --release --no-run clean first; suite 456 passed / 0 failed (release); cargo build --release --locked clean.

Semantics note (for the record)

Like LaTeX's .aux, the iteration now starts from the previous compile's fixed point. A contrived document with several self-consistent page assignments could settle on the seeded one where a cold compile settles on another; the gates above pin warm-equals-fresh on real documents, and the convergence check remains the correctness guard.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

…ence

A document with `\pageref` or a contents list pays a page-number relayout
on every warm keystroke: each request starts its label page tables empty,
so pass 1 can never converge and the whole adapt+typeset pipeline runs
twice even when no page number moved. On the 398-page #535 article with
\tableofcontents and one \pageref per section that is ~700 ms per typed
character, twice the plain document's cost.

The converged `labels.pages`/`labels.toc_pages` of a request are now
stored in the `RenderCache` (keyed by project) and seed the next request's
first pass -- the role LaTeX's `.aux` file plays between runs. A keystroke
that moves no page number converges on pass 1 and saves the relayout;
convergence is verified against the seed exactly as it is verified against
a pass's own output, so an edit that does move a page relays out with
fresh tables as before, bounded by the same MAX_LABEL_PASSES. Nothing is
stored when a request hits the pass limit without converging, and another
project's tables never seed a request.

Verification:
- New tests (tests/label_page_seed.rs): unchanged text converges on the
  seeded pass with byte-identical v2 output; a typed character that moves
  no page stays one pass and byte-identical to a fresh-cache compile of the
  edited text; a page-moving edit relays out (passes >= 2) and stays
  byte-identical to a fresh compile; another project id does not seed.
- 67/67 documents byte-identical `--v2` and `--pdf` against main 18bbacf
  (all 65 fixtures/ entry documents plus the 398-page article both ways;
  cold path -- the CLI renders each document once).
- perf-bench (#206), interleaved base -> change -> base on the same box
  with --pin: zero digest changes anywhere, including every
  `warm.<scenario>.<caps>` digest -- the warm outputs the seeding path
  produces are byte-identical to base. hyperref-toc warm improves 28-40%
  (far outside its 3-5% noise bands). The flagged timing regressions
  appear equally in the base-vs-base control leg (up to +50% on cold
  phases this change does not execute, at load 5-8 on the shared box), so
  they are machine noise per the FT-070 gate's own load warning.
- xref_measure (450 sections / 398 pages), interleaved A/B/A/B: the
  toc+pageref no-label warm edit drops from 2 passes / ~700 ms handle
  (~630 ms render) to 1 pass / ~435 ms handle (~363 ms render). renumber
  and move-label keep 2 passes and match base within noise; the plain
  document rows are untouched.
- `cargo test --release --no-run` clean first; suite 456 passed / 0 failed
  (release); `cargo build --release --locked` clean.

Semantics note: like LaTeX's `.aux`, the iteration now starts from the
previous compile's fixed point, so a hypothetical document with several
self-consistent page assignments could settle on the seeded one where a
cold compile settles on another. Every gate above (fixtures, warm digests,
the four new byte-identity tests) checks warm-equals-fresh on real
documents; the convergence check remains the correctness guard.

Implementation-Agent: Claude (Fable 5, render-perf lane, linux-primary)
Commit-Executor: Claude (Fable 5) (direct agent Git execution, per the
  AGENTS.md Cursor-limit fallback in force on this machine)
Co-authored-by: GoKubar <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
@GoKubar
GoKubar merged commit 7c2cbb0 into main Sep 16, 2026
11 of 22 checks passed
@GoKubar
GoKubar deleted the agent/kabir-claude/label-pages-seed branch September 16, 2026 04:17
GoKubar added a commit that referenced this pull request Sep 16, 2026
…unbreaks main) (#693)

`tests/label_page_seed.rs:36` constructs `Wire { images, device_color }`, but
`Wire` grew a third field:

    error[E0063]: missing field `diagnostics` in initializer of `Wire`

A combination break, not either change being wrong. #652 (label-page seeding)
added this test against a two-field `Wire`; #358 added `Wire.diagnostics` and
landed separately inside integration PR #658. Each was green on its own branch
and neither CI run saw the other.

This is the same failure mode as #664 and #638: a Rust test target that fails to
compile emits no `test result:` line, so summing those lines reads the crate as
green while 482 tests never run. Caught by running `cargo test --no-run` as a
separate first step before trusting any pass count -- worth keeping in the
release checklist, since this was found while verifying main for the 0.1.6 tag.

Verified in `--release` (per #667, debug is not a valid oracle for this crate):
render-pipeline 482 passed, 0 failed, with `--no-run` clean first.

Implementation-Agent: Claude Opus 5 (orchestrator-astra, linux-primary)
Commit-Executor: Claude Opus 5 via Claude Code

Co-authored-by: Claude Opus 5 <[email protected]>
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