Issue #1548: yaml: close the gap to saphyr-parser found by benches/yaml (events 2.8x on large, 5.4x on deep)

Open and answer this issue on GitHub.

blocked, yaml · opened 2026-11-10 · updated 2026-11-21 · 21 comments

Filed by the driver from the Found: of the run of issue-1517 (#1517); rewritten by the supervisor (2026-11-10, updated 2026-11-19; goal raised 2026-11-20 by the owner: faster than saphyr-parser, the six causes below worked off).

Part of #928. Needs #2409 Needs #2410 Needs #2411 Needs #2417 Needs #2418 Needs #2419 Needs #2282

Found

benches/yaml (#1517) counts yaml::events with checks off at 2.82x the instructions of saphyr-parser on the 10 MB input, 5.41x on deep, 2.78x on scalars and 3.37x on the suite cases. The callgrind profile names five causes (repro: nikaia run benches/yaml/bench.nika -- 1, then callgrind_annotate on target/yaml-bench/bin/events.off inputs/large.yaml):

  1. Events are copied once per nesting level. The walk (walk/events in packages/yaml/src) returns a Vec[Event] per node and the parent extends it. Grow and extend take 42 % of yaml::events on deep.
  2. The grammar threads ds: Vec[Dir] through every node rule and clones it per call. List<Dir>::clone_in takes 5 % of large, where the list is empty.
  3. Rule Props tries Tag(ds) in two alternatives on every node. parse_Tag and parse_Props take 10 % of large.
  4. malloc, free and memcpy take 23 % of large. There is a String per scalar, and the events are built from the Node tree rather than streamed.
  5. Plain scalars are read per character (parse_PlainChar, list::chars): 9 % of large.

After the second run (comment of 2026-11-10): large 2.20x, deep 2.53x, scalars 2.73x, suite 3.04x.

To build

Each cause is its own commit, measured with callgrind before and after (docs/measuring.md):

The six causes left (owner, 2026-11-20)

Each is its own issue, measured with callgrind before and after:

  1. Text cuts without a second UTF-8 check: ADR-374 D3/D4 text cuts (#2410), and bytes(p) binding names like text(p) (#2409).
  2. Events and nodes refer to their scalars in the input instead of copying them (#2417).
  3. The indentation is counted once, not twice (#2411).
  4. winnow-grammar picks an alternative by its first byte (#2419).
  5. Comments, indentation and scalar runs are read with the vectorised search (#2418).
  6. The @stream entry costs about what the in-memory parse costs (#2282).

Done when


Generated by Claude Code

Comments

keywan-ghadami, 2026-11-10

Brief queued: issue-1548


agent: builder model: opus max_turns: 200 budget_usd: 30 effort: medium —

Issue #1548

Your work order is issue #1548, inlined below with its comments. There is no brief written around it: plan your own steps from its To build list, build them in order, commit after each finished step, and end when its Done when holds (or at the limits of builder.md, reporting what is left). The facts in your prompt are Core of docs/builder-facts.md; more on a topic: nikaia run scripts/syntax.nika -- KEYWORD, a probe: nikaia run scripts/probe.nika -- SNIPPET.

Measure the issue against docs/issues.md while you work: what it lacked, what was wrong in it. That answer goes into the report’s Issue: field. A finding, a changed plan or a finished item also goes into the issue as a comment (gh api repos/Nikaia-Foundation/Nikaia/issues/1548/comments -F body=@file, ending with the Claude Code footer), rule I13.

Rules (CLAUDE.md; shared checkout)

Report (at most 15 lines, to exactly /home/user/Nikaia/docs/briefs/yaml/issue-1548.md.report.md)

Fields: Result, Files, Commit, Body (optional), Fixes, Pushed, Tests, Gate, Deviation, Found, Needs, Changelog, Issue, Owner (a question for the owner), Disk freed, and last Attribution: with your commit trailer lines below it.


Generated by Claude Code

keywan-ghadami, 2026-11-10

Run: issue-1548, ESCALATE claude exited with code 1

Tokens: input 412, cache read 13939627, cache write 302585, output 86062 Cost: 14.55 USD, time 2 min 2 s, turns 209

Report

(none)

Debrief

  1. Most turns and time: compiler defects that blocked the yaml change, not the yaml change itself.
    • The walk into one out list hit NK2302 in views.nika, then rustc E0621, which the compiler only showed as NK1127 through the default_limits() helper program.
    • The Props rewrite (cause 3) then hit a missing binding of rule values in text_tiers.nika (walk_grammar).
    • Two 600 s timeouts on the lower-std/build cycle and an interrupted session cost more.
    • My first views fix broke view_stored_in_a_branch_refused (#1085), and I only saw it on the rerun.
  2. Looked up that the brief could have handed me:
    • ADR-283 D27 (mut-parameter places) and how emit_how writes lifetimes.
    • ADR-grammar-1 D2: the grammar macro clones rule values, so ds is copied on every call (cause 2 is a lowering defect).
    • That text tiers (ADR-282) treat a grammar rule as a function with no parameters.
    • Where NK1106 comes from (check_core_places.nika → text_tiers.nika).
  3. Checks run:
    • Useful: the callgrind measurements with m.sh, the compiler tests filtered on view, lent and place (they caught the #1085 regression), the yaml package tests (they caught the shifted line numbers in bounds.stdout), clippy and pre-push.
    • Wasted: the step-1 test run lost to the interruption. Also the Props patch, which I had marked “tested on a copy” but which never compiled against the real package.
  4. One change that would have saved the most: builder.md should say that NK1127 on a computed default is usually a rustc failure in the package, and give the recipe to see it (replace the default with a literal in a copy).
  5. What the issue lacked:
    • It names the five causes without saying which are package changes and which need compiler fixes: cause 2 is the emit_grammar clone defect, cause 1 needs ADR-283 D27 places to work for pushed struct literals. rules-gap
    • No probe or baseline figure per input. It gave the target ratio but not the starting callgrind counts. broke I7
  6. Traps the next builder will meet:
    • Fact: Core | NK1127 "can't be computed while the program is built" on a compile-time default often hides a rustc error in the package itself; replace the default with a literal in a copy to see it.
    • Fact: grammar | A rule's value is cloned at every call (winnow-grammar codegen rule.rs:50), and text_tiers did not bind rule values until #1548, so a field read off a struct rule value was refused with NK1106.
    • Fact: Core | packages/yaml/tests/bounds.stdout holds source line numbers; any edit to main.nika needs a bless and a check that only the numbers moved.

Two fixes are committed locally: views/emit (b283d1a0, deep 5.66 → 2.70 together with the walk) and the yaml walk (a3d45c18, large 2.84 → 2.52). Nothing is pushed. The text_tiers fix for rule values was in its build cycle when the run ended. It is not verified, not committed, and its new test has not been run on the old compiler. The Props change (cause 3) sits uncommitted in the yaml source. Causes 2, 4 and 5 and the README update are still open. No final report was written.


Generated by Claude Code

keywan-ghadami, 2026-11-10

Run: issue-1548, Result: partial (left: cause 2 rule values cloned per call, cause 4 events from the parse with #1518, cause 5 run scan of plain scalars, the 1.5x target)

Tokens: input 166, cache read 5973314, cache write 128639, output 31846 Cost: 6.01 USD, time 31 min 18 s, turns 83

Report

Result: partial (left: cause 2 rule values cloned per call, cause 4 events from the parse with #1518, cause 5 run scan of plain scalars, the 1.5x target) Files: b283d1a0 views emit; a3d45c18 packages/yaml walk; ea344e1c text_tiers.nika + lowered + tests/compiler a_field_read_off_a_rule_value_keeps_the_tier_of_the_field; ff882752 packages/yaml Props; 4b8f758f benches/yaml/README.md Commit: 4b8f758f benches/yaml: the table and the causes after the walk and properties fixes (5 commits, all local) Body: issue comment: events/saphyr-parser now large 2.20 (was ~2.8), deep 2.53 (was 5.4), scalars 2.73, suite 3.04; load large 1.76; from_str 1.50; outputs byte-identical. Fixed: per-level event copying (walk pushes onto one list), Props read twice (read once, KeyTail/PropTail/FlowPropTail share it); text tiers bind a rule’s struct value like a fn param (found on the way, own test). Open: 2 needs a decision (below), 4 needs #1518, 5 blocked by a winnow-grammar defect (below). Part: #1548 Pushed: local 4b8f758f Tests: tests/compiler –filter grammar 69/69 both settings; new test fails on old binary (NK1106), passes now; yaml package 33/33 incl yaml_test_suite (bounds.stdout reblessed, line numbers only); lower-std fixpoint clean; clippy nikaia-std clean; cargo fmt; pre-push green Gate: green Deviation: causes 2, 4, 5 not built (decision, size, external macro defect); the 1.5x target not met Found: (a) winnow-grammar 2eb219c: a label in a repeated group is out of scope for a guard in the same group: rule Run(flow: bool) = (x:any if(ok(x, flow)))+ -> { } gives NK1127 hiding rustc “cannot find value x” (probe scratchpad issue-1548/p2); (b) a rule value ref Vec[D] is refused at the call Two(ds) / Two([]) with NK1102 (probe p1), and rule values are passed by value and cloned per call (List

::clone_in 4 % of large): lent by default like views-3 fn params, or an explicit `ref`? (check_grammar grammar_value, emit_pattern_call) Needs: supervisor decision (Found b); a fix or rev bump in winnow-grammar (Found a) Changelog: yaml: events 2.2-2.7x saphyr-parser (deep 5.4 -> 2.5) — the event walk appends to one list and a node's properties are read once; text tiers: a field read off a grammar rule's struct value keeps its tier Issue: rules-gap: causes mix package work and compiler/macro work without splitting them (I-split); no per-input baseline (I7) Owner: none Disk freed: removed target/nikaia-project-tests/yaml-facade/debug (2883 MB, made in this run); cache now 319M, / 6.0G free Attribution: Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UVxJDveRM5qKZKyCqq6Y24

Debrief

  1. What cost the most: NK1127 on the package’s computed default default_limits() hid the real rustc errors. Twice I had to copy the package and swap in a literal Limits before I could see the error behind it: the text-tier hole and the winnow-grammar guard scope. Rebuilding the README table by script was next; my first attempt mixed up the 3-pipe rows of different tables.
  2. What I had to look up:
    • ADR-grammar-1 D2 (rule values are taken “as a function does”) and the views-3 rule that function parameters are lent.
    • check_grammar.nika grammar_value, emit_pattern.nika emit_pattern_call, and winnow-grammar codegen/rule.rs:50 (#name.clone()).
    • The winnow-grammar checkout path, and the fact that rev 2eb219c is the newest.
  3. Checks run:
    • Useful: callgrind at a tenth of the inputs (m.sh) before and after each commit; tests/compiler --filter grammar; the yaml package with its yaml-test-suite; the lower-std fixpoint; clippy on nikaia-std; pre-push; one full bench at the end.
    • Wasted: the cause-5 experiment, built and then reverted, and some early guesses at what lay behind NK1127.
  4. One change that would have saved the most: a Core fact saying that NK1127 in a package with a computed default can hide a rustc error, and how to see that error (copy the package, replace the default with a literal).
  5. What the issue lacked:
    • rules-gap: it did not split package work from compiler or macro work. Cause 2 needs a language decision on rule values, and cause 5 needs a fix in the external winnow-grammar macro.
    • broke I7: it gave no baseline per input at the current commit, only the README’s old figures, so I re-measured first.
    • rules-gap: it did not say that cause 4 depends on #1518 and is too large for one run.
  6. Traps the next builder will meet:
    • Fact: Core NK1127 on a computed default (for example default_limits()) hides the rustc error behind it; replace the default with a literal in a copy of the package to see it.
    • Fact: lowering Grammar rule values are passed by value and cloned per call (winnow-grammar rule.rs #name.clone()), and ref on a rule parameter is refused with NK1102.
    • Fact: lowering In winnow-grammar 2eb219c, a label bound inside a repeated group ( x:any if(..x..) )+ is not in scope for the guard in that group.
    • Fact: Core packages/yaml/tests/bounds.stdout holds line numbers of main.nika; bless it after any edit and check that only the numbers moved.

Generated by Claude Code

keywan-ghadami, 2026-11-10

Progress (second run). Events compared with saphyr-parser, counted by callgrind:

input before now
large 2.8x 2.20x
deep 5.4x 2.53x
scalars – 2.73x
suite – 3.04x

load on large is 1.76x and from_str is 1.50x. The fixes were:

What remains:

This issue stays open until those land and the figures are re-measured.


Generated by Claude Code

keywan-ghadami, 2026-11-10

Blocked on #1318 (owner, 2026-11-10). No further optimization of the package until #1318 (warn on a .clone() that copies nothing new) is built. Then the first step here tests the compiler: can it already point to where the package must be optimized?

First step once #1318 is done

  1. Run nikaia check on packages/yaml and list every needless-clone warning, with its file and line.
  2. Set the warnings against the callgrind profile of the large and deep inputs. Sort them into:
    • hot spots the compiler named;
    • hot spots it missed;
    • warnings on cold code.
  3. Write the result here and on the research page. A hot spot the compiler missed but could have seen is a finding against the checker.
  4. Only then fix the warnings and re-measure.

#1560 is not part of this hold. The clone it removes is written by the grammar lowering and appears nowhere in the source, so #1318 could not warn about it.


Generated by Claude Code

keywan-ghadami, 2026-11-18

Update on the step this issue waited for: the needless-clone warning (#1318) is built and closed.

Remaining path, in order of expected gain:

  1. Events straight from the parse, with no intermediate list (#1518).
  2. A run match for plain characters in the scanner (#1561).
  3. text() without a from_utf8 check on slices that are already known to be valid.

The yaml lane is paused today for integration speed (#2154) and continues afterwards with these.


Generated by Claude Code

keywan-ghadami, 2026-11-19

Unblocked, back to ready (supervisor, 2026-11-19). Everything this issue waited on has landed:

Next run, in order

  1. Re-measure events, load and from_str against saphyr-parser with callgrind (benches/yaml, docs/measuring.md) at the current develop: large, deep, scalars and suite. Write the baseline table here before changing anything (I7).
  2. Point the bench’s events case at the streaming events(), if it does not use it already, and re-measure.
  3. Cause 5: a run match for plain-scalar characters in the scanner, using the guard in a repeated group.
  4. text() without the from_utf8 check on slices that are already known valid. If this needs a compiler or lowering change, fix it in the compiler with its own test (ADR-grammar-1). If it needs a language decision, report it as Found.
  5. Update the benches/yaml/README.md table and the causes.

Done when events are at most 1.5x saphyr-parser on large, deep, scalars and suite, or the run shows, with the profile, which remaining gap needs a decision or a compiler change, filed as its own issue.


Generated by Claude Code

keywan-ghadami, 2026-11-19

Driver: #1548 is not queued, its form misses what a builder needs (nikaia run scripts/issue-check.nika -- 1548, docs/issues.md, #2003):

Label swapped from ready to decision: add what is missing (a Needs #M line for an issue it waits for, or Part of #M), then set ready again.


Generated by Claude Code

keywan-ghadami, 2026-11-19

Brief queued: issue-1548-rerun


agent: builder model: opus max_turns: 200 budget_usd: 30 effort: medium —

Issue #1548

Your work order is issue #1548, inlined below with its comments. There is no brief written around it: plan your own steps from its To build list, build them in order, commit after each finished step, and end when its Done when holds (or at the limits of builder.md, reporting what is left). The facts in your prompt are Core of docs/builder-facts.md; more on a topic: nikaia run scripts/syntax.nika -- KEYWORD, a probe: nikaia run scripts/probe.nika -- SNIPPET.

Measure the issue against docs/issues.md while you work: what it lacked, what was wrong in it. That answer goes into the report’s Issue: field. A finding, a changed plan or a finished item also goes into the issue as a comment (gh api repos/Nikaia-Foundation/Nikaia/issues/1548/comments -F body=@file, ending with the Claude Code footer), rule I13.

Rules (CLAUDE.md; shared checkout)

Report (at most 15 lines, to exactly /home/user/Nikaia/docs/briefs/yaml/issue-1548-rerun.md.report.md)

Fields: Result, Files, Commit, Body (optional), Fixes, Pushed, Tests, Gate, Deviation, Found, Needs, Changelog, Issue, Owner (a question for the owner), Comment (#N <text>, what to say on another issue; the driver posts it, one line each), Friction, Disk freed, and last Attribution: with your commit trailer lines below it.


Generated by Claude Code

keywan-ghadami, 2026-11-19

Run: issue-1548-rerun, Result: partial (items left: the two @stream Founds below and #1518; the text() from_utf8 check, 3%, not started)

Tokens: input 244, cache read 8223140, cache write 180711, output 51318 Cost: 4.33 USD, time 1 min 57 s, turns 122

Report

Result: partial (items left: the two @stream Founds below and #1518; the text() from_utf8 check, 3%, not started) Files: benches/yaml/README.md Commit: yaml bench: the table at the plain-run change, the @stream causes Body: fe829f75 makes the facade build again against the owned Event (#1443) and borrows a scalar from its span. c06fa0aa makes PlainMore take a run of plain characters as one guarded repetition (#1561); output is byte-identical; scalars 282.8M -> 278.3M; it also re-blesses bounds.stdout (stale since #1443) and facade.stdout. This commit re-measures the table and names the causes left. The streaming entry is not used in the bench: it costs 120x (Found). Part: #1548 Tests: packages/yaml nikaia test: 35 of 35 after re-blessing bounds (stale line numbers since 8df05167e, red before) and facade (one label); events.off output byte-identical on deep and scalars (cmp); pre-push green Gate: green Deviation: item 4 (bench events case on yaml::Yaml::events) built and measured but not committed: 40,360M on deep against 340.8M, so the large row would take hours under callgrind Found: yaml’s @stream entry makes every parse of the grammar slower: package packages/yaml at c06fa0aa, bench program benches/yaml/events/events.nika (yaml::documents(input) then for e in yaml::events(docs)), built with RUSTFLAGS='-C overflow-checks=off' nikaia build, over target/yaml-bench/inputs/deep.yaml counts 340.8M instructions; the same package with @stream entry rule events(...) and its rules Opened/FirstEvents/NextEvents/Ended/AtEnd removed counts 186.2M, output byte-identical; it should not depend on whether the grammar has a @stream entry, since documents does not stream; traced: winnow-grammar-macros codegen/edge.rs Codegen::edge wraps every parser in rt::edge_reach when the grammar has any stream rule (its ADR 27 §3), and emit_core_leaves.nika lowers one copy per input (emit_bytes_grammar), so the stream entry and stream share it; edge_reach is 26.4% self of deep; fix by a separate lowered copy for @stream entries or per-entry tracking in winnow-grammar, no decision yet Found: for e in yaml::Yaml::events(input) { ... } (the events bench with the walk moved into fn lines(input: Bytes) -> String throws) prints the same events as yaml::events(yaml::documents(input)) but counts 40,360M instructions on target/yaml-bench/inputs/deep.yaml against 340.3M, and 5,464M against 278.3M on scalars.yaml; it should cost about what the in-memory parse costs (ADR-grammar-2 D7 streams so as not to hold the whole input); traced: winnow_grammar rt/stream.rs Stream::record_chunk (39.6G of 40.4G inclusive) parses the rule’s prefix again in the diagnosing pass, and the yaml rule’s prefix Opened Bom? Blanks DocEnd* FirstEvents(limits.depth) holds the whole first document (malloc/free 60%, ParseError::push_rule 11.7%); suspected that a grammar whose first document is a fold item as well avoids it (check: that rule shape, callgrind on deep) Found: an alternation in a repeated group whose alternatives give different values fails rustc: fn ok(x: scalar, flow: bool) -> bool sync { return x != ':' && x != ' ' && !(flow && x == ',') } grammar G { rule WS = "" -> { } entry rule top -> String = s:text(Run(false)) -> { s } rule Safe(flow: bool) = x:any if(ok(x, flow)) -> { } rule Run(flow: bool) = (x:any if(ok(x, flow)) | ":" peek(Safe(flow)))+ -> { } } fn main() throws { println(G::top("ab:c") catch { return }) } with nikaia run main.nika gives NK1343 “expected … to return Result<char, ErrMode<__WgEr>>, but it returns Result<&str, ErrMode<_>>”; (any | ":")+ and (any | ":") fail the same; ("a" | "b:")+ and (x:any if(ok(x, flow)))+ work; it should print ab:c (a group’s alternatives are matched for their text only); suspected: winnow-grammar macro codegen of ModelPattern::Group alts (rev e1dd687), check: the macro’s expansion of Run Needs: #1518 (allocation: the Node tree and a String per scalar before the events, 16% of large) Changelog: yaml: plain scalars matched as a run of characters, not a rule call per character (#1548) Issue: #1548 judged against docs/issues.md: the driver’s missing-Needs flag is moot (the supervisor’s 2026-11-19 comment drops #1518 as a dependency); wrong I7: the causes it lists are outdated, the main regression since 0.0.1424 (deep 177.8M -> 340.8M) is the @stream entry’s edge tracking (#1443), which the issue does not name Comment: #1548 baseline at 42b3b8a21+fe829f75, millions of instructions, checks off, events vs saphyr-parser: large 7996.1 (2.63x), deep 340.8 (4.21x), scalars 282.8 (1.82x), suite 18.8 (3.56x); load vs saphyr: large 7752.2 (1.91x), deep 339.5 (2.84x), scalars 282.4 (1.92x), suite 17.6 (2.97x); from_str large 7384.8 (1.80x serde_yaml); after c06fa0aa: events large 7873.6 (2.59x), deep 340.3 (4.20x), scalars 278.3 (1.79x), suite 18.5 (3.52x); load large 7629.8 (1.88x); from_str 7262.3 (1.77x); large events.off profile: edge_reach 9% self, malloc/free 16%, from_utf8 of text() 3% Friction: the bench’s facade did not build since the owned Event of #1443 (de.rs E0107/E0581/E0308), and packages/yaml/tests/bounds.stdout was stale since the same commit: a bench or package test that a change does not run goes red unseen Disk freed: none; target/nikaia-project-tests 997M (new: yaml-facade/debug 997 MB), / 7.4G free; target/yaml-bench 739M Attribution: Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com Claude-Session: https://claude.ai/code/session_01UVxJDveRM5qKZKyCqq6Y24 Reviewed: 086f1feb68cf9082c1b0c9fe0e99961623dc5b6d2498c383276dd5b69a1e112b Pushed: local af298bc0dd1bb671434853c856f717413afa0728

Debrief

  1. Most turns/time: the bench. A full bench.nika run is about 30 min, and the first one failed on the facade build (the owned Event from #1443). After that, finding the real regression took several callgrind rounds plus a package copy with the @stream entry cut out to prove it. Waiting in one call was clumsy: a foreground until loop hit the 600 s cap.
  2. Looked up: where the lowering emits grammar copies (emit_core_leaves.nika, emit_bytes_grammar), winnow-grammar’s codegen/edge.rs and rt/stream.rs (record_chunk, Reading), the exp build command (RUSTFLAGS='-C overflow-checks=off' nikaia build), and how Yaml::events reports errors (events_stream.nika).
  3. Checks run: the baseline bench, the after bench, callgrind on deep/scalars/large, package nikaia test (3×), pre-push (2×), the commit dry runs. Wasted: one package test run in the scratch copy (bounds and facade fail there only because scripts/slot.nika and repo paths are missing), and a second nikaia test just to read the diffs, when > file the first time would have done.
  4. Change that would have saved most: a small script, e.g. scripts/bench-one.nika PKG INPUT, that builds the events program against a given package and prints callgrind totals plus a cmp against the reference output. Its absence cost the most turns: I rebuilt measure.sh by hand, and without it every before/after needs a 30-min full bench.
  5. What the issue lacked:
    • wrong I7: its causes predate #1443. The main regression is the @stream edge tracking (deep 177.8M → 340.8M), which it does not name.
    • broke I5: no current figures; item 0 had to make them. That costs one bench run, and the bench was red (the facade didn’t build).
    • rules-gap: no rule asks a feature commit like #1443’s to re-run the benches of the package it touches, and the bench went red unseen.
    • knowledge: Lowering | a grammar with any @stream rule wraps every parser of that grammar in rt::edge_reach, so a non-stream entry of the same grammar pays for the tracking too.
  6. Traps for the next builder:
    • Fact: Lowering | an alternation in a repeated group whose alternatives give different values ((x:any if(g(x)) ”:”)+) fails rustc with NK1343; keep such an alternative as its own rule alternative.
    • Fact: Core | running a package's nikaia test rewrites its nikaia.proofs, nikaia.derived and nikaia.lock; commit them with a source change, else restore them by name.
    • Fact: Lowering | a @stream entry re-parses its rule's prefix in the diagnosing pass (record_chunk), so a prefix that holds a whole document costs 20-120x the in-memory parse.

Generated by Claude Code

keywan-ghadami, 2026-11-19

From the report of the run of issue-1548-rerun (#1548):

baseline at 42b3b8a21+fe829f75, millions of instructions, checks off, events vs saphyr-parser: large 7996.1 (2.63x), deep 340.8 (4.21x), scalars 282.8 (1.82x), suite 18.8 (3.56x); load vs saphyr: large 7752.2 (1.91x), deep 339.5 (2.84x), scalars 282.4 (1.92x), suite 17.6 (2.97x); from_str large 7384.8 (1.80x serde_yaml); after c06fa0aa: events large 7873.6 (2.59x), deep 340.3 (4.20x), scalars 278.3 (1.79x), suite 18.5 (3.52x); load large 7629.8 (1.88x); from_str 7262.3 (1.77x); large events.off profile: edge_reach 9% self, malloc/free 16%, from_utf8 of text() 3%


Generated by Claude Code

keywan-ghadami, 2026-11-19

The report of the run of issue-1548-rerun (#1548) judged this issue against docs/issues.md; the author fixes the issue by the rule it names (How a run judges its issue):


Generated by Claude Code

keywan-ghadami, 2026-11-19

Driver: not queued, this issue waits for #1518, which is still open (#1819). Set ready again when it is closed.


Generated by Claude Code

keywan-ghadami, 2026-11-20

Unblocked: the edge-tracking cost (#2281) is gone with winnow-grammar 0612989. Next: step 0, re-measure against saphyr-parser at current develop, then causes 4 and 5.


Generated by Claude Code

keywan-ghadami, 2026-11-20

Brief queued: issue-1548


agent: builder model: opus max_turns: 200 budget_usd: 30 effort: medium —

Issue #1548

Your work order is issue #1548, inlined below with its comments. There is no brief written around it: plan your own steps from its To build list, build them in order, commit after each finished step, and end when its Done when holds (or at the limits of builder.md, reporting what is left). The facts in your prompt are Core of docs/builder-facts.md; more on a topic: nikaia run scripts/syntax.nika -- KEYWORD, a probe: nikaia run scripts/probe.nika -- SNIPPET.

Measure the issue against docs/issues.md while you work: what it lacked, what was wrong in it. That answer goes into the report’s Issue: field. A finding, a changed plan or a finished item also goes into the issue as a comment (gh api repos/Nikaia-Foundation/Nikaia/issues/1548/comments -F body=@file, ending with the Claude Code footer), rule I13.

Rules (CLAUDE.md; shared checkout)

Report (at most 15 lines, to exactly /home/user/Nikaia/docs/briefs/yaml/issue-1548.md.report.md)

Fields: Result, Files, Commit, Body (optional), Fixes, Pushed, Tests, Gate, Deviation, Found, Needs, Changelog, Issue, Owner (a question for the owner), Comment (#N <text>, what to say on another issue; the driver posts it, one line each), Friction, Disk freed, and last Attribution: with your commit trailer lines below it.


Generated by Claude Code

keywan-ghadami, 2026-11-20

Run: issue-1548, Result: partial

Tokens: input 210, cache read 10222542, cache write 151202, output 55755 Cost: 4.43 USD, time 1 min 53 s, turns 105

Report

Result: partial Files: benches/yaml/README.md Commit: yaml bench: the table after the edge-tracking fix and the Blanks scan, the causes left on deep Body: Step 0 baseline at 46045b3a (events.off vs saphyr-parser, millions, checks off): large 5887.1 (1.94x), deep 185.7 (2.29x), scalars 220.2 (1.42x), suite 15.1 (2.84x); load large 1.33x, deep 1.53x, scalars 1.46x; from_str 1.28x serde_yaml. The edge-tracking fix (#2281) did most of it. b346065e: Blanks scans a line’s spaces once (it scanned them three times, Blank then LastBlank’s two alternatives), fold hands back raw text with nothing to fold: deep 185.7 -> 164.1, large 5887 -> 5754. 6a21c8f5: the bench’s events program appends to its output as events_saphyr.rs does, not a String per event via f-strings: large 5754 -> 4495, deep 164.1 -> 140.6. Now: events large 1.48x, deep 1.74x, scalars 1.35x, suite 2.53x; load 1.28/1.34/1.46x; from_str 1.25x. Outputs byte-identical at every step on small, deep, scalars, large; the bench checks every program against the first. Tried and dropped: parsing valid UTF-8 input as text (NK1187, here over text waits for #743); a FlowItem alternative without the key’s text (deep 129.0, 1.59x) parses FlowAny twice on a failure and goes exponential (limits_depth_and_size timed out), so not committed. README names the causes left. Part: #1548 Tests: nikaia test in packages/yaml 35/35 at b346065e (yaml_test_suite pass list included; bounds.stdout re-blessed, line numbers only); bench.nika full run green (same output checks); no compiler change, so no fails-before run Gate: green Deviation: To-build item 4 not built: the streaming yaml::Yaml::events still counts 40,279M on deep against 140.6M through documents+events (Stream::attempt re-parses the prefix, 99 %), so the bench keeps documents and events Deviation: To-build item 4’s text() without from_utf8 not built: the cut by text positions it needs (ADR-374 D3/D4/D8) is not built, see the Found line Found: a grammar’s bytes(p) binds no name inside p, unlike text(p), so a rule cannot keep a node and check its bytes unchecked; probe grammar G { rule WS = "" -> { } entry rule top -> i64 = b:bytes(v:Num) -> { v } rule Num -> i64 = d:digit -> { 7 } } fn main() throws { let x = G::top(Bytes([49])) catch { 0 } println(f"{x}") } gives error[NK1117]: \v` isn’t declared anywhere.; the same with text(v:Num) prints 7; Part II 10's grammar table binds names only inside text(..) and a labelled span(..); yaml's FlowItem/Key take text only to check a key stays on one line, 8 % of benches/yaml deep (deep 1.74x -> 1.59x without it); suspected emitter __nikaia_covered path in crates/nikaia-std/src/compiler/emit_pattern.nika; no decision yet Found: ADR-374 D3/D4 text cuts are not built: fn main() throws { let mut s = String() s.push_str(“ab\ncd”) let m = s.find(“\n”) ?? return println(s.before(m.start)) println(s.after(m.end)) } gives error[NK1171]: String has no method called after (and before; s.start(), s.end(), between, forward(bytes:) the same), it should print ab and cd (ADR-374 D3); packages/yaml fold and block cut slices with bs[a..<b].text() and pay from_utf8 (about 5 % of benches/yaml large with the grammar's captures), which a cut at positions skips (D8); cause: not built, std text methods Found: packages/yaml counts each line's indentation twice: Blanks (in Eol Blanks) scans the spaces of the next content line and fails, then Block counts them again with m:count(“ “) (up to its three alternatives): parse_Blanks_inner self 9.2M of 140.6M on benches/yaml deep (6.6 %); handing the count from Blanks to Block touches every rule that reads Eol Blanks v:Block`; traced (callgrind self cost, packages/yaml/src/main.nika rules Blanks and Block) Needs: none Changelog: none Issue: wrong I7: the causes list was outdated, the largest gap since 0.0.1424 was the @stream edge tracking (#2281, fixed) and the bench program’s String per event (a fifth of large), neither named; broke I4: #1518 is named as a wait in a comment while the body says its edit model is not part of the issue Comment: #1548 Re-measured at 6a21c8f5 (events.off vs saphyr-parser, checks off): large 1.48x, deep 1.74x, scalars 1.35x, suite 2.53x; load 1.28x/1.34x/1.46x/2.27x; from_str 1.25x serde_yaml. Baseline at 46045b3a before this run: 1.94x/2.29x/1.42x/2.84x. Deep stays above 1.5x: flow-entry text checks (8 %), indentation counted twice (7 %), the engine’s alternatives (15 %); the streaming entry still costs 40,279M on deep. Table and causes in benches/yaml/README.md. Owner: none Friction: none Disk freed: 11M of scratch builds; target/nikaia-project-tests 993M (new entry yaml-facade/debug 993M); / 15G free Reviewed: a8ff0b9759cdae6422837f11b29b4c5e22ccb6fd1e748c3ed3eea77a61dd8233 Pushed: local 67e097b92a543ec8607a47dd2c007cac26667a5e Attribution: Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com Claude-Session: https://claude.ai/code/session_01UVxJDwSpspVvrTQMgwWNUS

Debrief

  1. Most time: waiting on callgrind and the full bench (two runs of about 40 minutes each), plus two dead ends: the text-path parse refused with NK1187, and the extra FlowItem alternative. The extra alternative passed the bench but went exponential in limits_depth_and_size, which cost one package-test run.
  2. Looked up:
    • ADR-374 D3/D4/D8 for text cuts, and the finding that none of it is built (NK1171).
    • That here over text isn’t built (NK1187, #743).
    • The grammar builtins table in Part II 10: bytes(p) binds no names inside it.
    • Where the generated grammar Rust lives (target/.../gen/yaml/yaml.rs), and that grammar::covered_bytes runs from_utf8.
  3. Checks run: a per-step cmp.sh (identical output on four inputs plus counts on deep, scalars and large), the yaml package tests, pre-push, and two full benches. Wasted: the count after the failed bytes(..) build, which reran a stale binary, and the facade/limits rerun that hit the 600 s tool timeout.
  4. One change: make builder.md say that a grammar alternative which re-parses a failing sub-rule turns exponential with nesting depth, so it must be checked against limits_depth_and_size before anything is counted.
  5. What the issue lacked:
    • wrong I7: the causes predate #2281, and the issue doesn’t name the bench program’s String per event (a fifth of large).
    • broke I4: #1518 is named as a wait in a comment while the body excludes it.
    • knowledge: Measuring | the yaml events program must append to its output as events_saphyr.rs does, or f-strings dominate the row.
    • knowledge: Core | ADR-374 cuts (start/before/after/between/forward) are not built yet, so text slices still pay from_utf8.
  6. Traps:
    • Fact: Probes | A grammar's bytes(p) binds no names inside p (only text(..) and a labelled span(..) do), so bytes(v:Rule) leaves v undeclared (NK1117).
    • Fact: Measuring | bench.nika counts tokens from the source at the end of its run, so editing a bench program while it runs puts the new token count into the old table.
    • Fact: Core | A grammar over text that uses here is refused (NK1187) until #743; a Bytes grammar's text(..) captures each pay from_utf8.

Generated by Claude Code

keywan-ghadami, 2026-11-20

From the report of the run of issue-1548 (#1548):

Re-measured at 6a21c8f5 (events.off vs saphyr-parser, checks off): large 1.48x, deep 1.74x, scalars 1.35x, suite 2.53x; load 1.28x/1.34x/1.46x/2.27x; from_str 1.25x serde_yaml. Baseline at 46045b3a before this run: 1.94x/2.29x/1.42x/2.84x. Deep stays above 1.5x: flow-entry text checks (8 %), indentation counted twice (7 %), the engine’s alternatives (15 %); the streaming entry still costs 40,279M on deep. Table and causes in benches/yaml/README.md.


Generated by Claude Code

keywan-ghadami, 2026-11-20

The report of the run of issue-1548 (#1548) judged this issue against docs/issues.md; the author fixes the issue by the rule it names (How a run judges its issue):


Generated by Claude Code

keywan-ghadami, 2026-11-20

Driver: not queued, this issue waits for #2409, #2410, #2411, #2417, #2418, #2419, #2282, which is still open (#1819). Set ready again when it is closed.


Generated by Claude Code

keywan-ghadami, 2026-11-20

From the report of the run of issue-2420 (#2420):

The @stream walk over a String/Bytes now runs winnow-grammar’s slice entry (#2420): deep.yaml 277.0M -> 217.7M against 121.4M in memory. The rest is the walk’s thread and its zero-capacity channel for each item


Generated by Claude Code

keywan-ghadami, 2026-11-21

From the report of the run of issue-2425 (#2425):

D32 (#2425) step 1 is in for String sources: a yaml walk whose events take whole String parameters into a mut out list is lent now; one taking a field of a lent node (n.raw) waits for the D5 part-store defect filed from #2425’s run.


Generated by Claude Code

Back to Open Issues