Issue #1620: benches/game: the json package counted against serde_json

Open and answer this issue on GitHub.

libraries, performance, blocked · opened 2026-11-15 · updated 2026-11-19 · 8 comments

Part of #1611 (cross-language benchmarks in benches/game/), which holds the method, the harness and the rules for findings. This is the everyday library next to the Benchmarks Game programs, done the way benches/yaml counts the yaml package against saphyr and libyaml.

What it measures. Reading and writing JSON, which almost every server does: the json package (packages/json) against serde_json, the Rust library people use.

To build

  1. Three inputs, written into the README with their sizes: small (one request body, about 1 KB), large (about 10 MB of mixed objects and arrays, for example the twitter.json and canada.json files of the nativejson-benchmark, with their licence), and deep (nesting up to the package’s limit).
  2. Two levels, each a binary of its own per side:
    • the tree: parse into the package’s value type against serde_json::Value, and write it back;
    • into a type of the program (a struct with fields): the package’s way against serde_json with #[derive(Deserialize)].
  3. Same output byte for byte (the written-back text, or a printed digest of the values).
  4. The rows in the table of #1611: instructions and mispredictions, overflow checks on and off, and tokens of the program that uses each library.
  5. Every row where Nikaia counts more: the cause from callgrind_annotate, filed as an issue.

Done when benches/game/game.sh (or a json.sh beside it that the table includes) prints the json rows next to serde_json with the same output, and each loss names its issue.

Comments

keywan-ghadami, 2026-11-16

Brief queued: issue-1620


agent: builder model: opus max_turns: 200 budget_usd: 30 issues: 1620, 1611 effort: medium —

Issue #1620

Your work order is issue #1620, 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/1620/comments -F body=@file, ending with the Claude Code footer), rule I13.

Rules (CLAUDE.md; shared checkout)

Report (at most 15 lines, to exactly {REPORT})

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.

Supervisor’s note (2026-11-16)


Generated by Claude Code

keywan-ghadami, 2026-11-18

Run: issue-1620, Result: partial

Tokens: input 0, cache read 0, cache write 0, output 0 Cost: 0.00 USD, time 0 min 0 s, turns 0

Report

Result: partial Files: benches/game/Cargo.toml benches/game/Cargo.lock benches/game/game.nika benches/game/json/README.md benches/game/json/input.nika benches/game/json/tree.nika benches/game/json/rust-tree.rs Commit: benches/game: the json package counted against serde_json on the tree, 1.4x to 2.0x, three generated inputs Body: json/tree.nika (json::parse, json::to_string of standard input) against json/rust-tree.rs (serde_json::Value with preserve_order, arbitrary_precision, unbounded_depth, so both keep member order and number text and read 512 levels; serde_json 1.0.149 added to Cargo.toml/Cargo.lock). Inputs generated by json/input.nika (no data file, no licence to carry): small 1,046 bytes, large 10,000,080 (twitter-like records, every tenth line canada-like coordinates), deep 819,202 (400 chains 511 levels deep, the package’s limit). game.nika gets problems json-small/-large/-deep (-- json runs all three) with three new things: Game fields bin (a Rust binary serving several problems) and package (an official package taken in by path) with defaults, units: 0 meaning bytes of standard input, and an input that names a Nikaia program to generate it. Per byte, checks off: small serde_json 488.5, Nikaia 676.0 (1.38x); large 136.6 vs 246.3 (1.80x); deep 382.4 vs 766.2 (2.00x); x86-64-v3 the same; tokens Rust 148, Nikaia 55. All print the same bytes (md5 b4abe7cc, 4bfb653c, fcbb0495). benches/game/json/README.md holds inputs, sizes, table and causes. Level 2 (into a struct) not built: see Needs. Part: #1620 Tests: nikaia run benches/game/game.nika – json prints the table, all programs the same output at both settings (3 min); game.nika checks; nikaia fmt –check of the three .nika clean; rustfmt –check rust-tree.rs clean; pre-push green with the files staged; no compiler, std or Rust of the compiler changed, so no build, lower-std or clippy Gate: green Deviation: #1620 item 1 names twitter.json and canada.json of the nativejson-benchmark “for example”; the inputs are generated by benches/game/json/input.nika in their shape instead, so no 10 MB data file or third-party licence goes into the repository Deviation: #1620 item 2’s second level (a struct of the program, the package’s way against #[derive(Deserialize)]) is not built: the package’s way is json::read[T] (ADR-344 D3, ADR-grammar-2 D10), which does not exist in packages/json yet; its build is #604 Found: json package builds the path text of every value while reading, 30 % of its instructions on the large input and 42 % on deep (benches/game/json, nikaia run benches/game/game.nika -- json, callgrind_annotate of target/game-bench/bin/json-large.x86-64.off: task_block::text::format 730 M of 2,463 M inclusive, called 933,000 times from json::value): value in packages/json/src/main.nika makes f"{path}[{at}]" for each array element and f"{path}.{key}" for each member, text only an Error ever shows; expected: the path built only when reading fails (for example a stack of segments joined in fail), which alone takes json-large from 1.80x serde_json to about 1.27x Found: json package copies text a character at a time, 24 % of its instructions on the large input (callgrind_annotate of target/game-bench/bin/json-large.x86-64.off after nikaia run benches/game/game.nika -- json): parse in packages/json/src/main.nika collects the whole input into a Vec[scalar] (text.chars().collect(), nikaia_std::list::chars 149 M of 2,463 M), and number and string build each value by text.push(r.cs[i]) one scalar at a time (Text::push 434 M inclusive from json::value and json::string, 6.8 M calls); expected: the reader walks the input’s bytes and takes a number or an escape-free string as one slice of the input, as serde_json does Found: Text::push of one character is an out-of-line call of about 30 instructions on its own (54 with its growth) in a program that pushes characters into a String: in json-large (above) <task_block::text::Text>::push is 277 M self over 9.3 M calls, called from json::value, json::string and json::write_string, though it is #[inline] in crates/unsafe/task-block/src/text.rs and its ASCII path is one push_or_end; Rust’s String::push of an ASCII char inlines to a capacity check and a store; cause unknown, suspected Text::push / Grow::push_or_end (crates/unsafe/task-block/src/list.rs) not inlined into the package’s crate Needs: #604 Changelog: benches/game: the json package against serde_json, reading standard input into the tree and writing it back. nikaia run benches/game/game.nika -- json counts three generated inputs (1 KB, 10 MB, 512 levels deep): 1.4x, 1.8x and 2.0x serde_json’s instructions at about a third of its tokens, most of the gap the path text the package builds for every value and its copying a character at a time Issue: broke I4: item 2’s second level names “the package’s way” without saying it is json::read[T] (ADR-344 D3), which is not built and waits for #604, so the issue cannot be done when filed; wrong I3: Done when names benches/game/game.sh, the harness is game.nika; rules-gap: item 3 asks for byte-identical written-back text but not which serde_json features make the two sides mean the same (preserve_order, arbitrary_precision, unbounded_depth: without them serde_json sorts keys, rewrites numbers and stops at 128 levels) Owner: none Comment: #1611 json (#1620): the tree level is in game.nika as json-small/-large/-deep, inputs generated by benches/game/json/input.nika; per byte, checks off, serde_json (preserve_order, arbitrary_precision) against the json package: small 488.5 vs 676.0 (1.38x), large 10 MB 136.6 vs 246.3 (1.80x), deep 512 levels 382.4 vs 766.2 (2.00x), tokens 148 vs 55; causes: the path text built for every value (30 %), text copied a character at a time (24 %). The level into a struct waits for json::read[T] (#604). Friction: a callgrind run by hand of a Nikaia program reading standard input hangs for ever (killed after 10 min) unless NIKAIA_RUNTIME_CONFIG points at io-method = “blocking”, which game.nika sets but nothing tells whoever profiles its binaries afterwards; valgrind --tool=callgrind target/game-bench/bin/json-large.x86-64.off < target/game-bench/out/json-large.input never ends, with NIKAIA_RUNTIME_CONFIG=target/game-bench/io-blocking.toml it takes a minute Disk freed: none (target/nikaia-project-tests 856M, / 16G free; cache entry over 100 MB touched: rlib/df8bcfe6 451M; target/game-bench 460M, the harness’s, kept) Attribution: Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com Claude-Session: https://claude.ai/code/session_01UVxJDukWgopUzVU2M1TjK7 Pushed: local 4e368a320373aa26d44721556dc2128b78118b76 Supervisor: 2026-11-18: accepted as partial: the tree level is measured; the level into a struct waits for json::read[T] (#604), which stays its own issue.


Generated by Claude Code

keywan-ghadami, 2026-11-18

The report of the run of issue-1620 (#1620) 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

Brief queued: issue-1620-run2


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

Issue #1620

Your work order is issue #1620, 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/1620/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/performance/issue-1620-run2.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-1620-run2, Result: blocked

Tokens: input 14, cache read 192204, cache write 21837, output 2246 Cost: 0.28 USD, time 0 min 42 s, turns 7

Report

Result: blocked Files: none Commit: none Body: run 1 (commit “benches/game: the json package counted against serde_json on the tree, 1.4x to 2.0x, three generated inputs”, Part of #1620) built items 1, 3, 4 and 5 for the tree level; what is left is item 2’s second level (a struct of the program, the package’s way against #[derive(Deserialize)]), and the package’s way is json::read[T] (ADR-344 D3), whose build is #604; #604 is not in the prompt and git log -400 --grep='Fixes #604' finds no fix, and packages/json/src has no fn read, so it is open and the run ends here before any edit Pushed: none Tests: none run: nothing changed (dependency check only: git log -400 –grep=’#604’ empty, grep ‘fn read’ packages/json/src/*.nika empty) Gate: green Deviation: none Found: none Needs: #604 Changelog: none Issue: broke I4: item 2’s second level depends on json::read[T] (ADR-344 D3), built by #604, but the issue names no Needs #604, so the driver ran it again while #604 is open; wrong I3: Done when names benches/game/game.sh, the harness is benches/game/game.nika Owner: none Comment: #1620 run 2 ended blocked at once: the only item left, the level into a struct of the program, needs json::read[T] (ADR-344 D3), still unbuilt (#604); the tree level is done by run 1. Add Needs #604 to the issue body so the driver waits for it. Friction: none Disk freed: none (target/nikaia-project-tests 1.7G, / 15G free; no new cache entries, nothing built this run) Attribution: Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com Claude-Session: https://claude.ai/code/session_01UVxJDukWgopUzVU2M1TjK7

Debrief

  1. Most turns: few were spent. The run needed about 6 tool calls: reading the brief, run 1’s commit and report, and the check on #604.
  2. Looked up: run 1’s report, to learn what was left and that it waited for #604. I also ran git log --grep to see whether #604 was closed. The brief could have said “run 1 left only level 2, which needs #604; #604 is open (or closed).”
  3. Checks run: git log -400 --grep='Fixes #604' and grep 'fn read' packages/json/src. Both were needed and none was wasted. I built and tested nothing, which was right.
  4. Biggest saving: the driver should not start a run while the earlier run’s Needs: #N is still open. Run 1 said Needs: #604, and this run still started.
  5. What the issue lacked:
    • broke I4: no Needs #604 for item 2’s level into a struct, which needs json::read[T] (ADR-344 D3), so the driver queued the issue again.
    • wrong I3: Done when names benches/game/game.sh; the harness is benches/game/game.nika.
    • broke I4: item 5 wants “each loss names its issue”, but the issue does not list the issues filed from run 1’s three Found: lines, so a later run cannot fill in the README.
  6. Traps:
    • Fact: Core Before planning a re-run, read the earlier run’s .report.md in docs/briefs/<lane>/: its Needs: and the supervisor’s note on it often show at once that the run is blocked.
    • Fact: Core A dependency missing from the prompt counts as open when git log -400 --grep='Fixes #N' is empty; also grep for the code it would add (here fn read in packages/json/src) to confirm.

Generated by Claude Code

keywan-ghadami, 2026-11-19

From the report of the run of issue-1620-run2 (#1620):

run 2 ended blocked at once: the only item left, the level into a struct of the program, needs json::read[T] (ADR-344 D3), still unbuilt (#604); the tree level is done by run 1. Add Needs #604 to the issue body so the driver waits for it.


Generated by Claude Code

keywan-ghadami, 2026-11-19

The report of the run of issue-1620-run2 (#1620) 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 #604, which is still open (#1819). Set ready again when it is closed.


Generated by Claude Code

Back to Open Issues