Repository navigation
render-pipeline: refuse an over-limit compile_result without serialising it (perf C) - #651
Merged
Merged
Conversation
…ing it On a 398-page document (#535's generated article) the worker built and serialised a 25 MB v1 envelope on every warm keystroke, compared its length to the 16 MB reply limit, and threw it away: ~34 ms per edit spent producing a line whose only use was its length, before replying `failed`. The refusal now comes first, the same shape as the display_list oversize gate: `V1Payload::envelope_len` computes the exact byte length of the envelope `write_envelope` would produce -- length arithmetic mirroring the writer field for field, strings via the same escape rules, `jpt`/`ji` milli-rounding reproduced -- without allocating the line. When that length exceeds the reply limit the worker answers with the refusal it always sent, carrying the same exact byte count, and never serialises the envelope. The pre-check runs only when the item-count heuristic puts the limit in reach (approx > limit/4), so small replies pay neither pass; a line that fits is written exactly as before, and the old post-write check stays as the last word, so an underestimate could only cost the optimisation, never change a reply. Output is unchanged by construction and by measurement: - `envelope_len_matches_write_envelope` pins length == serialised length over every writer field shape (escapes, control characters, hints, both item kinds, null sources, suggestions, non-finite and huge coordinates) plus the whole jpt milli-grid near zero and a pseudo-random sweep. - `oversize_compile_result_refusal_names_the_exact_line_length` (e2e) pins that the refused reply names exactly the byte count a permissive run's envelope actually has. - 67/67 documents byte-identical `--v2` and `--pdf` against main 18bbacf (all 65 fixtures/ entry documents plus the 398-page #535 article with and without \tableofcontents+\pageref). - perf-bench full run against the committed baseline: zero digest changes. The 152 flagged timings were uniform +5-6% across every metric including phases this change cannot execute (cold parse, PDF export), at load 5.2 vs the baseline's 1.4, and an interleaved base-vs-base control run on the same box "fails" the same gate the same way (+14% on a cold phase, noise band 8.9%), so the deltas are machine noise, not the change. Suite: 454 passed / 0 failed (release), `cargo test --release --no-run` clean first, `cargo build --release --locked` clean. Measured effect (xref_measure, 450 sections / 398 pages, interleaved A/B/A/B): handle_line minus render drops from ~73-78 ms to ~50-58 ms per warm edit (the 21 ms serialisation is gone; the 13 ms v1 fallback build and now ~3 ms exact length pass remain). Render time itself is untouched. 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
added a commit
that referenced
this pull request
Sep 15, 2026
…ntegration queue) - protocol.rs: #651's size-first envelope refusal kept whole; this branch's contribution grafted in — the refusal's capability echo also filters -only and -window, since nothing sibling-shaped was accepted. - memsize.rs / memprofile.rs: this branch's window-aware versions are supersets of the #232 versions main landed; kept ours. - typeset.rs: comment-only (derived-carets note on the math assembly). Implementation-Agent: fable-ft070 Commit-Executor: fable-ft070 (direct; Cursor usage limit)
GoKubar
added a commit
that referenced
this pull request
Sep 15, 2026
…ted-latex docs Only conflict was docs/user/compiler.md (generated); resolved by re-running crates/compiler/scripts/render_supported_latex.sh, never hand-merged. apps/mac/scripts/sync-supported-latex.sh reports the bundled copy current. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar
added a commit
that referenced
this pull request
Sep 15, 2026
This was referenced Sep 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 2, step C of the warm-repaint investigation (Phase 1 report: the 398-page warm keystroke spends ~34 ms building+serialising a 25 MB v1 envelope that is discarded against the 16 MB reply limit, replying
failedwith only its length).What changes
V1Payload::envelope_len(id): the exact byte lengthwrite_envelope(id)would produce, computed by length arithmetic that mirrors the writer field for field (same escape rules, samejpt/jimilli-rounding) without allocating the line.protocol::handle_line: when the item-count heuristic puts the reply limit in reach (approx > limit/4), the exact length is computed first; if it exceeds the limit the worker sends the refusal it always sent — with the same exact byte count in the message — and never serialises the envelope. A line that fits is written exactly as before, and the old post-write check remains as the last word (an underestimate could only cost the optimisation, never change a reply). Small replies skip both passes.Output preservation
envelope_len_matches_write_envelope(new unit test): length == serialised length across every writer field shape — escapes, control chars, font hints, both item kinds, null sources, suggestions, non-finite/huge coordinates — plus the wholejptmilli-grid near zero and a pseudo-random sweep.oversize_compile_result_refusal_names_the_exact_line_length(new e2e): the refused reply names exactly the byte count a permissive run's envelope actually has.--v2and--pdfvs main18bbacf0: all 65fixtures/entry documents + the 398-page compiler: 3x faster large-document compile — shaping memo, glyph-table index, lent cleveref config (#65) #535 article with and without toc/pageref.--pinrun (base→C→base) flagged only cold phases with overlapping noise bands and no warm/v1 metric.cargo test --release --no-runclean first; suite 454 passed / 0 failed (release);cargo build --release --lockedclean.Measured effect
xref_measure (450 sections / 398 pages), interleaved A/B/A/B: handle−render drops ~73–78 ms →
50–58 ms per warm edit (−20 ms: the 21 ms serialisation is gone; the 13 ms v1 fallback build and ~3 ms length pass remain). Render time untouched, cache counters identical.Next (separate PRs, per plan): A — seed
labels.pages/toc_pagesacross requests; B — stop cloning cached blocks intoLaid.🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu