Repository navigation
fix: streaming stays linear with JSX in code, five frames that drew otherwise, a crate abort on wide tables - #1
Merged
Conversation
…se reads otherwise A tag that only code leaves open joined every block after its fence: `htmlOpen` read the raw text of the pieces, fences and all, and took a render prop's `=>` for the end of an open `<List` tag, an `<li>` a snippet leaves to the parser for one that never closes, a `<!--` in a template for an open comment. The rest of the reply was then one block, read again whole on every token: 80,000 characters after one such fence streamed in 54 s in Chrome on two cores, 0.8 s now. A piece that opens with a fence is code to the cut (`markupOf`), as the scan already knows it is, and a closing tag in code no longer ends the HTML block around it (`</details>` in an example drew the text after it outside the `<details>`). Four more places a block-by-block draw differed from one parse, three found by the fuzz once its lines held code that looks like tags (CODE_TAG_LINES, a sweep of its own so the documents the golden digest holds stay the same): - an item that opens empty holds at most one blank line: the indented code under that line, and the fence under it, are not in it; - a tabs marker's heading under a blank line in the same piece (a lone `$$` above keeps the scan from cutting there) is read as the marker's, so the blocks after it stay in the last tab; - a closing tag with nothing open is dropped, as the HTML parser drops it, and does not close the tag opened after it; - a fence still being written, drawn by its own path, now names its file on its `<code>` (`data-title`) as a finished one does, on React and on the shared renderer. The golden digest moves for that last one only: 182 streaming digests of documents with a titled fence still open, every prefix of which now draws what one parse draws (checked, 546 prefixes). The opening and closing checks of a fence, written four times over, are two helpers. Size: 0.2 KB on the entries that cut a reply, with the reasons in scripts/size.ts. Checked: `bun run test` (921 pass), `FUZZ=300000 bun test blocks-fuzz` (4 sweeps), golden. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011qcwzcvC2yxKDfLTRyCg6U
…hey mean something Three ends of a stream showed their syntax as text for a token or two before it turned into what it is: - the row of dashes under a table's header (`|--`, `| --- | -`) printed under the header, and both became a table a token later. It is held back while it is the line being typed, under a line with a pipe in it: a row of dashes is never prose; - a footnote reference being typed (`See[^1`) printed `[^1`: `[^` opens nothing but a reference, so it is hidden until its `]`, outside a code span; - a task's box before its first word (`- [x`) was an item reading "[x": it is the item's marker, held back as a bare `-` is. The header row on its own still shows as it comes, as before: a line of pipes may be prose. A reference that is complete still shows until its definition arrives at the end of the reply. The golden digest moves for streaming frames only, 43 of them, every changed prefix one of these three (34 boxes, 10 references, 1 row of dashes) and each drawing what one parse of its healed text draws. docs/streaming.md lists the three. The changeset covers this and the commit before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011qcwzcvC2yxKDfLTRyCg6U
The corpus had no code that looks like markup, so a cut that read a render prop as an open tag was never measured: `answer-10k` to `answer-40k` stayed linear while a reply about React went quadratic. `react-10k` and `react-40k` are `answer`'s parts with three shapes of such code (a usage example whose render prop has its `=>` inside the tag, a component with the same deeper in, an HTML snippet with an `<li>` left open), and `linear-code` holds their exponent under 1.25, as `linear` does `answer`'s. The stream-split sweep reads `react-10k` too. On this branch's parent the pair streams at n^2.02 (274 ms, then 4,493 ms; its last block grows to 39,369 characters); with the fix at n^0.57 (118 ms, 259 ms; 1,573). Two cores, `--quick`. results/latest.json has no rows for the pair yet, so `bench:check` reports the rule uncovered until `bun run bench` runs again on the machine the published figures come from. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011qcwzcvC2yxKDfLTRyCg6U
…g one no longer aborts `Inline::fit` reckons the nodes still to come by how many the text read so far made. A row's cells are made before any of their text is read, and the row's text counted as read only once the row was done, so the first cell of a wide header, one byte in, reckoned the rest of the document at thousands of nodes a byte. 500 columns over 20 KB reserved room for 12 million nodes; the `worst` bench's table with rows short of its columns, at 112 KB, asked for 69 GB and aborted the program (R1, R7). The cells now count as the block pass's own, each cell's inlines are reckoned from where it is in its row, and the guess is held to two nodes a byte still to read: asking too little costs one more move of the nodes. The product is saturated, so it cannot wrap where usize is 32 bits (the wasm build). That table grows 3.9 times at four times its length, where it grew 8.5; the parse bench's allocations (90, 4.4 MB) and throughput against pulldown-cmark are as they were. Checked: fmt, clippy (crate and bench), `cargo test --locked` (82), docs, the package's files. Not here: the wasm build, whose target cannot be fetched on this machine; CI builds it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011qcwzcvC2yxKDfLTRyCg6U
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.
What changes for a person using it
A reply about React streams in linear time again. A tag that only code leaves open (a render prop, whose
=>the cut read as the end of an open<Listtag; an<li>an HTML snippet leaves to the parser; a<!--in a template) made the rest of the reply one block, read and drawn again whole on every token. Measured in Chrome on two cores, with the published 0.7.1 against this branch:On that README 0.7.1 lost to markdown-to-jsx (11,190 ms); this branch is 9× faster than it. The drawn page is the same (2,524 nodes, the same text).
Five frames of a stream drew differently from the finished reply, found while checking the cut against one parse (one by a reviewer, three by the block fuzz once its lines held code that looks like tags, one by the golden digest):
</details>in an example) ended the HTML block around it, and the text after it was drawn outside the<details>;data-title) on React, on the page and in<flow-down>;$$lost the block after them;</div>) closed the tag opened after it.While a reply streams, the row of dashes under a header (
|--), a footnote reference being typed ([^1) and a task's box before its first word (- [x) are held back for a token or two instead of showing as text (docs/streaming.md).The Rust crate no longer aborts on a wide table. A row's cells are made before their text is read, and the reckoning of room for the nodes to come took them as the text's: 500 columns over 20 KB reserved 12 million nodes, and the
worstbench's short-rowed table at 112 KB asked for 69 GB, which aborts the program (R1, R7). That table now grows 3.9× at four times its length, where it grew 8.5×; the parse bench is as it was (90 allocations, 4.4 MB, the same ratio to pulldown-cmark). The product is saturated for the 32-bit wasm build.Commits
fix(stream): a fence's code is code to the cut (markupOf, from what the scan already knows), the empty item, the tabs over a blank line, the stray closing tag,data-titleon a growing fence; the fence checks written four times over are two helpers.fix(heal): the three held-back ends.bench:react-10k/react-40kand thelinear-coderule. The corpus had no code that looks like markup, which is whylinearnever saw this. Onmainthe pair streams at n^2.02, here at n^0.57.fix(crate): the room reckoning, with a test.Checked
bun run test: 921 pass.FUZZ=300000 bun test blocks-fuzz: 4 sweeps, 1.2 million documents, none differ from one parse.CODE_TAG_LINESis a sweep of its own, so the documents the golden digest holds are unchanged.No other way of drawing (tree, react, remark, tui) moved.
bun run typecheck,lint,format:check,build,check,size;site/:npm run check.tuiandremark; budgets raised by that, with the reasons inscripts/size.ts, after the fence checks were folded into two helpers to bring it down from 0.4 KB.cargo fmt --check,clippy -D warnings(crate and bench),cargo test --locked(82),cargo doc -D warnings, the package's file list.--quick --runs=5, two cores):chat-5k46/41 → 44/37 ms,answer-20k114/117 → 137/114 ms, within this machine's noise;long-100k543 → 518,code-50k208 → 151.Not checked here, for review
rust.ymlbuilds it.results/latest.jsonhas no rows forreact-10k/react-40k, sobun run --cwd bench bench:checkreportslinear-codeuncovered untilbun run benchruns on the machine the published figures come from (two minutes). I did not commit numbers from this 2-core VM over the M5's.| A | B |) shows as text until its row of dashes starts, as a line of pipes may be prose; a complete[^1]shows until its definition arrives at the end of the reply. And an HTML tag genuinely left open outside code (<details>with no</details>) still keeps the rest of the reply one block, as one parse reads it so.Generated by Claude Code