Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 39 additions & 38 deletions docs/ALLOCATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ returns. Tokens: each target's own `tokenize` count. Nodes: rule nodes of the re

| target | grammar | input | mode | tokens | nodes | allocations | per token | per node | bytes | B per token | B per node | result allocs | result bytes | overhead bytes |
|:--|:--|:--|:--|--:|--:|--:|--:|--:|--:|--:|--:|--:|--:|--:|
| ts | typescript | acorn.js | parse | 42,251 | 28,638 | 139,665 | 3.31 | 4.88 | 4,618,136 | 109.3 | 161.3 | 79,491 | 2,313,619 | 2,304,517 |
| ts | typescript | acorn.js | parseWith | 42,251 | 28,638 | 139,665 | 3.31 | 4.88 | 4,618,136 | 109.3 | 161.3 | 79,491 | 2,313,619 | 2,304,517 |
| ts | typescript | lib.es5.d.ts | parse | 13,659 | 7,182 | 43,680 | 3.20 | 6.08 | 1,436,340 | 105.2 | 200.0 | 20,313 | 591,395 | 844,945 |
| ts | typescript | lib.es5.d.ts | parseWith | 13,659 | 7,182 | 43,680 | 3.20 | 6.08 | 1,436,340 | 105.2 | 200.0 | 20,313 | 591,395 | 844,945 |
| ts | typescript | _tsserver.js | parse | 4,932 | 3,139 | 15,943 | 3.23 | 5.08 | 537,368 | 109.0 | 171.2 | 8,673 | 252,250 | 285,118 |
| ts | typescript | _tsserver.js | parseWith | 4,932 | 3,139 | 15,943 | 3.23 | 5.08 | 537,368 | 109.0 | 171.2 | 8,673 | 252,250 | 285,118 |
| ts | typescript | _tsserver.js ×4 | parse | 19,728 | 12,553 | 63,693 | 3.23 | 5.07 | 2,103,920 | 106.6 | 167.6 | 34,686 | 1,008,865 | 1,095,055 |
| ts | typescript | _tsserver.js ×4 | parseWith | 19,728 | 12,553 | 63,693 | 3.23 | 5.07 | 2,103,920 | 106.6 | 167.6 | 34,686 | 1,008,865 | 1,095,055 |
| ts | javascript | acorn.js | parse | 42,051 | 32,239 | 146,763 | 3.49 | 4.55 | 4,819,100 | 114.6 | 149.5 | 86,693 | 2,515,039 | 2,304,061 |
| ts | javascript | acorn.js | parseWith | 42,051 | 32,239 | 146,763 | 3.49 | 4.55 | 4,819,100 | 114.6 | 149.5 | 86,693 | 2,515,039 | 2,304,061 |
| ts | javascript | _tsserver.js | parse | 4,928 | 3,411 | 16,587 | 3.37 | 4.86 | 555,420 | 112.7 | 162.8 | 9,217 | 267,394 | 288,026 |
| ts | javascript | _tsserver.js | parseWith | 4,928 | 3,411 | 16,587 | 3.37 | 4.86 | 555,420 | 112.7 | 162.8 | 9,217 | 267,394 | 288,026 |
| ts | javascript | _tsserver.js ×4 | parse | 19,712 | 13,641 | 66,269 | 3.36 | 4.86 | 2,176,128 | 110.4 | 159.5 | 36,862 | 1,069,439 | 1,106,689 |
| ts | javascript | _tsserver.js ×4 | parseWith | 19,712 | 13,641 | 66,269 | 3.36 | 4.86 | 2,176,128 | 110.4 | 159.5 | 36,862 | 1,069,439 | 1,106,689 |
| ts | typescript | acorn.js | parse | 42,251 | 28,638 | 159,870 | 3.78 | 5.58 | 5,263,936 | 124.6 | 183.8 | 99,327 | 2,948,317 | 2,315,619 |
| ts | typescript | acorn.js | parseWith | 42,251 | 28,638 | 159,870 | 3.78 | 5.58 | 5,263,936 | 124.6 | 183.8 | 99,327 | 2,948,317 | 2,315,619 |
| ts | typescript | lib.es5.d.ts | parse | 13,659 | 7,182 | 52,393 | 3.84 | 7.30 | 1,712,924 | 125.4 | 238.5 | 28,023 | 836,284 | 876,640 |
| ts | typescript | lib.es5.d.ts | parseWith | 13,659 | 7,182 | 52,393 | 3.84 | 7.30 | 1,712,924 | 125.4 | 238.5 | 28,023 | 836,284 | 876,640 |
| ts | typescript | _tsserver.js | parse | 4,932 | 3,139 | 18,563 | 3.76 | 5.91 | 621,168 | 125.9 | 197.9 | 11,206 | 333,261 | 287,907 |
| ts | typescript | _tsserver.js | parseWith | 4,932 | 3,139 | 18,563 | 3.76 | 5.91 | 621,168 | 125.9 | 197.9 | 11,206 | 333,261 | 287,907 |
| ts | typescript | _tsserver.js ×4 | parse | 19,728 | 12,553 | 74,173 | 3.76 | 5.91 | 2,439,120 | 123.6 | 194.3 | 44,818 | 1,332,916 | 1,106,204 |
| ts | typescript | _tsserver.js ×4 | parseWith | 19,728 | 12,553 | 74,173 | 3.76 | 5.91 | 2,439,120 | 123.6 | 194.3 | 44,818 | 1,332,916 | 1,106,204 |
| ts | javascript | acorn.js | parse | 42,051 | 32,239 | 166,694 | 3.96 | 5.17 | 5,457,020 | 129.8 | 169.3 | 106,529 | 3,149,490 | 2,307,530 |
| ts | javascript | acorn.js | parseWith | 42,051 | 32,239 | 166,694 | 3.96 | 5.17 | 5,457,020 | 129.8 | 169.3 | 106,529 | 3,149,490 | 2,307,530 |
| ts | javascript | _tsserver.js | parse | 4,928 | 3,411 | 19,197 | 3.90 | 5.63 | 638,752 | 129.6 | 187.3 | 11,750 | 348,191 | 290,561 |
| ts | javascript | _tsserver.js | parseWith | 4,928 | 3,411 | 19,197 | 3.90 | 5.63 | 638,752 | 129.6 | 187.3 | 11,750 | 348,191 | 290,561 |
| ts | javascript | _tsserver.js ×4 | parse | 19,712 | 13,641 | 76,709 | 3.89 | 5.62 | 2,509,456 | 127.3 | 184.0 | 46,994 | 1,392,635 | 1,116,821 |
| ts | javascript | _tsserver.js ×4 | parseWith | 19,712 | 13,641 | 76,709 | 3.89 | 5.62 | 2,509,456 | 127.3 | 184.0 | 46,994 | 1,392,635 | 1,116,821 |
| js | typescript | acorn.js | fresh | 42,251 | 28,813 | 5,161 | 0.12 | 0.18 | 14,643,756 | 346.6 | 508.2 | - | - | - |
| js | typescript | acorn.js | reuse | 42,251 | 28,813 | 4,992 | 0.12 | 0.17 | 234,424 | 5.5 | 8.1 | - | - | - |
| js | typescript | lib.es5.d.ts | fresh | 13,659 | 7,692 | 7,008 | 0.51 | 0.91 | 2,790,368 | 204.3 | 362.8 | - | - | - |
Expand All @@ -54,38 +54,38 @@ returns. Tokens: each target's own `tokenize` count. Nodes: rule nodes of the re
| js | javascript | _tsserver.js | reuse | 4,928 | 3,535 | 318 | 0.06 | 0.09 | 15,176 | 3.1 | 4.3 | - | - | - |
| js | javascript | _tsserver.js ×4 | fresh | 19,712 | 14,137 | 1,386 | 0.07 | 0.10 | 6,416,748 | 325.5 | 453.9 | - | - | - |
| js | javascript | _tsserver.js ×4 | reuse | 19,712 | 14,137 | 1,245 | 0.06 | 0.09 | 59,744 | 3.0 | 4.2 | - | - | - |
| go | typescript | acorn.js | fresh | 42,251 | 28,638 | 83 | 0.00 | 0.00 | 9,249,920 | 218.9 | 323.0 | 3 | 2,072,576 | 7,177,344 |
| go | typescript | acorn.js | fresh | 42,251 | 28,638 | 85 | 0.00 | 0.00 | 9,671,168 | 228.9 | 337.7 | 3 | 2,154,496 | 7,516,672 |
| go | typescript | acorn.js | reuse | 42,251 | 28,638 | 0 | 0.00 | 0.00 | 0 | 0.0 | 0.0 | 0 | 0 | 0 |
| go | typescript | acorn.js | slim-reuse | 42,251 | 11,491 | 0 | 0.00 | 0.00 | 0 | 0.0 | 0.0 | 0 | 0 | 0 |
| go | typescript | lib.es5.d.ts | fresh | 13,659 | 7,233 | 73 | 0.01 | 0.01 | 2,117,280 | 155.0 | 292.7 | 3 | 548,864 | 1,568,416 |
| go | typescript | lib.es5.d.ts | fresh | 13,659 | 7,233 | 75 | 0.01 | 0.01 | 2,289,312 | 167.6 | 316.5 | 3 | 589,824 | 1,699,488 |
| go | typescript | lib.es5.d.ts | reuse | 13,659 | 7,233 | 0 | 0.00 | 0.00 | 0 | 0.0 | 0.0 | 0 | 0 | 0 |
| go | typescript | lib.es5.d.ts | slim-reuse | 13,659 | 3,112 | 0 | 0.00 | 0.00 | 0 | 0.0 | 0.0 | 0 | 0 | 0 |
| go | typescript | _tsserver.js | fresh | 4,932 | 3,185 | 60 | 0.01 | 0.02 | 718,496 | 145.7 | 225.6 | 3 | 225,280 | 493,216 |
| go | typescript | _tsserver.js | fresh | 4,932 | 3,185 | 61 | 0.01 | 0.02 | 759,456 | 154.0 | 238.4 | 3 | 237,568 | 521,888 |
| go | typescript | _tsserver.js | reuse | 4,932 | 3,185 | 0 | 0.00 | 0.00 | 0 | 0.0 | 0.0 | 0 | 0 | 0 |
| go | typescript | _tsserver.js | slim-reuse | 4,932 | 1,372 | 0 | 0.00 | 0.00 | 0 | 0.0 | 0.0 | 0 | 0 | 0 |
| go | typescript | _tsserver.js ×4 | fresh | 19,728 | 12,737 | 78 | 0.00 | 0.01 | 3,710,624 | 188.1 | 291.3 | 3 | 901,120 | 2,809,504 |
| go | typescript | _tsserver.js ×4 | fresh | 19,728 | 12,737 | 79 | 0.00 | 0.01 | 3,841,696 | 194.7 | 301.6 | 3 | 933,888 | 2,907,808 |
| go | typescript | _tsserver.js ×4 | reuse | 19,728 | 12,737 | 0 | 0.00 | 0.00 | 0 | 0.0 | 0.0 | 0 | 0 | 0 |
| go | typescript | _tsserver.js ×4 | slim-reuse | 19,728 | 5,485 | 0 | 0.00 | 0.00 | 0 | 0.0 | 0.0 | 0 | 0 | 0 |
| go | javascript | acorn.js | fresh | 42,051 | 32,239 | 83 | 0.00 | 0.00 | 9,249,920 | 220.0 | 286.9 | 3 | 2,072,576 | 7,177,344 |
| go | javascript | acorn.js | fresh | 42,051 | 32,239 | 85 | 0.00 | 0.00 | 9,671,168 | 230.0 | 300.0 | 3 | 2,154,496 | 7,516,672 |
| go | javascript | acorn.js | reuse | 42,051 | 32,239 | 0 | 0.00 | 0.00 | 0 | 0.0 | 0.0 | 0 | 0 | 0 |
| go | javascript | acorn.js | slim-reuse | 42,051 | 11,491 | 0 | 0.00 | 0.00 | 0 | 0.0 | 0.0 | 0 | 0 | 0 |
| go | javascript | _tsserver.js | fresh | 4,928 | 3,411 | 60 | 0.01 | 0.02 | 718,496 | 145.8 | 210.6 | 3 | 225,280 | 493,216 |
| go | javascript | _tsserver.js | fresh | 4,928 | 3,411 | 61 | 0.01 | 0.02 | 759,456 | 154.1 | 222.6 | 3 | 237,568 | 521,888 |
| go | javascript | _tsserver.js | reuse | 4,928 | 3,411 | 0 | 0.00 | 0.00 | 0 | 0.0 | 0.0 | 0 | 0 | 0 |
| go | javascript | _tsserver.js | slim-reuse | 4,928 | 1,367 | 0 | 0.00 | 0.00 | 0 | 0.0 | 0.0 | 0 | 0 | 0 |
| go | javascript | _tsserver.js ×4 | fresh | 19,712 | 13,641 | 79 | 0.00 | 0.01 | 4,251,296 | 215.7 | 311.7 | 3 | 1,015,808 | 3,235,488 |
| go | javascript | _tsserver.js ×4 | fresh | 19,712 | 13,641 | 81 | 0.00 | 0.01 | 4,554,400 | 231.0 | 333.9 | 3 | 1,089,536 | 3,464,864 |
| go | javascript | _tsserver.js ×4 | reuse | 19,712 | 13,641 | 0 | 0.00 | 0.00 | 0 | 0.0 | 0.0 | 0 | 0 | 0 |
| go | javascript | _tsserver.js ×4 | slim-reuse | 19,712 | 5,465 | 0 | 0.00 | 0.00 | 0 | 0.0 | 0.0 | 0 | 0 | 0 |

## Where: ts target, parse, typescript grammar, acorn.js (top 15 of 16 sites by bytes)

| kind | site (literals folded) | in functions | allocations | per token | modeled bytes | share | in result |
|:--|:--|--:|--:|--:|--:|--:|--:|
| object | `{ off, end, nl, kid, lid }` | 1 | 42,251 | 1.00 | 1,352,032 | 29.3% | 0 |
| .slice() → array | `_hs.slice(b, _n)` | 1 | 28,916 | 0.68 | 898,372 | 19.5% | 28,638 |
| object | `{ rule, children, offset: off, end }` | 1 | 28,915 | 0.68 | 809,620 | 17.5% | 28,638 |
| object | `{ tokenType, offset: off, end }` | 1 | 23,031 | 0.55 | 644,868 | 14.0% | 22,215 |
| array growth | `toks.push(mk_tok(off, end, pendingNl, kid, lid))` | 1 | 18 | 0.00 | 607,924 | 13.2% | 0 |
| .slice() → string | `src.slice(pos, e)` | 1 | 16,248 | 0.38 | 300,424 | 6.5% | 0 |
| object | `{ off, end, nl, kid, lid }` | 1 | 42,251 | 1.00 | 1,352,032 | 25.7% | 0 |
| object | `{ tokenType, offset: off, end }` | 1 | 43,236 | 1.02 | 1,210,608 | 23.0% | 42,051 |
| .slice() → array | `_hs.slice(b, _n)` | 1 | 28,916 | 0.68 | 978,432 | 18.6% | 28,638 |
| object | `{ rule, children, offset: off, end }` | 1 | 28,915 | 0.68 | 809,620 | 15.4% | 28,638 |
| array growth | `toks.push(mk_tok(off, end, pendingNl, kid, lid))` | 1 | 18 | 0.00 | 607,924 | 11.5% | 0 |
| .slice() → string | `src.slice(pos, e)` | 1 | 16,248 | 0.38 | 300,424 | 5.7% | 0 |
| .slice() → string | `_src.slice(t.off, u.end)` | 1 | 203 | 0.00 | 3,248 | 0.1% | 0 |
| .slice() → string | `_src.slice(_sp[b * _SW + N], _sp[b * _SW + N])` | 1 | 72 | 0.00 | 1,240 | 0.0% | 0 |
| array growth | `localE.push({ tokStart: _sp[s + N]!, tokEnd: pos, ext: Math.max(pos...` | 1 | 1 | 0.00 | 76 | 0.0% | 0 |
Expand All @@ -100,12 +100,12 @@ returns. Tokens: each target's own `tokenize` count. Nodes: rule nodes of the re

| kind | site (literals folded) | in functions | allocations | per token | modeled bytes | share | in result |
|:--|:--|--:|--:|--:|--:|--:|--:|
| object | `{ off, end, nl, kid, lid }` | 1 | 42,251 | 1.00 | 1,352,032 | 29.3% | 0 |
| .slice() → array | `_hs.slice(b, _n)` | 1 | 28,916 | 0.68 | 898,372 | 19.5% | 28,638 |
| object | `{ rule, children, offset: off, end }` | 1 | 28,915 | 0.68 | 809,620 | 17.5% | 28,638 |
| object | `{ tokenType, offset: off, end }` | 1 | 23,031 | 0.55 | 644,868 | 14.0% | 22,215 |
| array growth | `toks.push(mk_tok(off, end, pendingNl, kid, lid))` | 1 | 18 | 0.00 | 607,924 | 13.2% | 0 |
| .slice() → string | `src.slice(pos, e)` | 1 | 16,248 | 0.38 | 300,424 | 6.5% | 0 |
| object | `{ off, end, nl, kid, lid }` | 1 | 42,251 | 1.00 | 1,352,032 | 25.7% | 0 |
| object | `{ tokenType, offset: off, end }` | 1 | 43,236 | 1.02 | 1,210,608 | 23.0% | 42,051 |
| .slice() → array | `_hs.slice(b, _n)` | 1 | 28,916 | 0.68 | 978,432 | 18.6% | 28,638 |
| object | `{ rule, children, offset: off, end }` | 1 | 28,915 | 0.68 | 809,620 | 15.4% | 28,638 |
| array growth | `toks.push(mk_tok(off, end, pendingNl, kid, lid))` | 1 | 18 | 0.00 | 607,924 | 11.5% | 0 |
| .slice() → string | `src.slice(pos, e)` | 1 | 16,248 | 0.38 | 300,424 | 5.7% | 0 |
| .slice() → string | `_src.slice(t.off, u.end)` | 1 | 203 | 0.00 | 3,248 | 0.1% | 0 |
| .slice() → string | `_src.slice(_sp[b * _SW + N], _sp[b * _SW + N])` | 1 | 72 | 0.00 | 1,240 | 0.0% | 0 |
| array growth | `localE.push({ tokStart: _sp[s + N]!, tokEnd: pos, ext: Math.max(pos...` | 1 | 1 | 0.00 | 76 | 0.0% | 0 |
Expand Down Expand Up @@ -156,14 +156,15 @@ returns. Tokens: each target's own `tokenize` count. Nodes: rule nodes of the re
| array | `[source]` | 1 | 1 | 0.00 | 28 | 0.0% | - |
| .slice() → array | `lexEmptyPops.slice()` | 1 | 1 | 0.00 | 16 | 0.0% | - |

## Where: go target, fresh, typescript grammar, acorn.js (top 5 of 5 sites by bytes)
## Where: go target, fresh, typescript grammar, acorn.js (top 6 of 6 sites by bytes)

| site (innermost function in the parser package) | allocations | bytes | share |
|:--|--:|--:|--:|
| `(*engine).finish` | 47 | 5,829,088 | 63.0% |
| `lexFrom.func2` | 26 | 3,413,248 | 36.9% |
| `(*engine).pushLeaf` | 6 | 7,424 | 0.1% |
| `(*engine).matchTok` | 3 | 112 | 0.0% |
| `(*engine).finish` | 48 | 6,244,960 | 64.6% |
| `lexFrom.func2` | 26 | 3,413,248 | 35.3% |
| `(*engine).matchLit` | 7 | 7,344 | 0.1% |
| `(*engine).pushLeaf` | 2 | 5,440 | 0.1% |
| `(*engine).matchTok` | 1 | 128 | 0.0% |
| `(*engine).parseProgram` | 1 | 48 | 0.0% |

## Where: go target, reuse, typescript grammar, acorn.js (top 0 of 0 sites by bytes)
Expand Down
3 changes: 2 additions & 1 deletion docs/CORRECTNESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ lowering member each printer implements (`src/target-{ts,go,rust}.ts`: the TS `p
native and builder forms, the Rust `prattRule`; the recovery interpreter `src/ir/recovery-family.ts`
reads the same facts from its table, and `test/ir-engine.ts` mirrors them), and the list rows in
`test/portable-cases.ts` that exercise it. **V** means the exercising rows are in those lists,
which compare every target with the interpreter, verdict and CST (gate
which compare every target with the interpreter, verdict and CST byte for byte (until
`land/lossless-cst` only the tree of rule nodes; gate
`emit-parity/portable-targets/lists`), and each row's verdict was checked against tsc (and acorn for
JavaScript). **R** means the row was argued from the code: the mechanism has no portable
counterpart, so there is nothing to compare. **W** means the argument has a witness that fails if
Expand Down
36 changes: 36 additions & 0 deletions docs/MEASUREMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,36 @@ Reuse mode is the like-for-like mode for memory: one `CstBuilder` kept across pa
(`parse_with`) against one oxc `Allocator` `reset()` before each parse; fresh mode is a new
builder / allocator per parse.

### The default tree keeps every token (2026-11-29, `land/lossless-cst`)

Since this landing the default CST of the Rust, Go and TS targets holds every token as a leaf,
punctuation included, as the interpreter's always did. From #56 until this landing it dropped the
punctuation leaves, so every row below this section was measured on a tree without them: a CST
that was not lossless. Keeping them costs the Rust parse 2% to 5% more instructions on the real
inputs (`dense-semi.ts`, which is almost all `;`, 24%), the Go direct engine about 4%; the TS target
executes about 1% fewer blocks but makes 14% to 20% more allocations (one object per leaf; Go fresh
parses allocate 4% to 8% more bytes, `docs/ALLOCATIONS.md`). Instructions per parse,
`measure-profile` full scope, run 46290960497 (A = master 118bee29, M = the landing), monogram ÷ oxc:

| input | reuse, A | reuse, M | fresh, A | fresh, M |
|:--|--:|--:|--:|--:|
| `checker.ts` | 0.896 | 0.915 | 0.900 | 0.919 |
| `typescript.js` | 0.893 | 0.914 | 0.894 | 0.914 |
| `parser.ts` | 0.891 | 0.914 | 0.907 | 0.938 |
| `typescript.d.ts` | 0.997 | 1.034 | 1.014 | 1.053 |
| 2 MB synthetic file | 0.921 | 0.957 | 0.923 | 0.960 |
| non-ASCII-heavy file | 0.879 | 0.895 | 0.913 | 0.923 |
| `gen-textmate.ts` | 0.924 | 0.947 | 0.942 | 0.967 |
| `typescript.ts` | 0.725 | 0.746 | 0.788 | 0.826 |
| dense `;` | 0.957 | 1.191 | 0.959 | 1.194 |
| dense `a+a+…` | 0.809 | 0.787 | 0.811 | 0.788 |
| `jsx-corpus.tsx` | 1.346 | 1.409 | 1.391 | 1.446 |
| `jsx-corpus.jsx` | 1.224 | 1.287 | 1.348 | 1.433 |

On `checker.ts` monogram now runs 106.8M instructions per parse in reuse mode (was 104.6M), oxc
116.7M. `typescript.d.ts` crosses above oxc: 3.4% more in reuse mode (was 0.3% less). Time was not
re-measured.

### monogram `bf18adc` (2026-11-23)

Time: `measure-bench` run 45244727475 (both modes on AMD EPYC 9V74). Instructions:
Expand Down Expand Up @@ -386,6 +416,12 @@ that excess is T2 - C, the slot overhead beyond the CST builder it replaces. The
constructs at accept sites) all remove T2. No step can remove T1. The typed build's floor is
P + T1 = 18.5M fresh, below the lower bound.

Since `land/lossless-cst` the CST build keeps the punctuation leaves (measure-profile run 46290960497):
16,610,344 instructions fresh and 16,122,636 reuse on checker.cov.ts (was 16,466,918 and 15,865,035),
the typed build unchanged at 23,575,738 and 22,219,465, so the typed build is +41.9% / +37.8% against
it (was +43.2% / +40.1%). A converter then reads every punctuation token from the CST and needs no
re-read of the text; the parts above were not split again.

## Recorded result: element dialects (TSX and JSX)

`measure-profile` run 45129600578 (AMD EPYC 7763), M = master `d326d65`. Per token: Rust and Go
Expand Down
Loading
Loading