Issue #1611: Benchmarks Game programs counted against the fastest Rust entries: one table in benches/game/

Open and answer this issue on GitHub.

performance, blocked · opened 2026-11-15 · updated 2026-11-18 · 17 comments

Goal. Show that Nikaia is fast in general, not only on the one task we picked. Today the only cross-language evidence is benches/brc (the One Billion Row Challenge), where Nikaia wins, and benches/yaml, where it loses by a factor of 1.5 to 3. Every other bench measures what a language feature costs inside Nikaia (refcount, lockfloor, overlap, taskblock, …). A reader who wants to know whether the language is fast sees one example chosen by us.

Part of #540 (the benchmark table). This issue settles #540’s choice for the cross-language part: established programs, counted by docs/measuring.md (callgrind instructions and mispredictions, never seconds; tokens of both sides), against tuned Rust. The Python/Go columns and the build-time column of #540 stay open there.

What. A directory benches/game/ with programs from the Computer Language Benchmarks Game, each counted against the fastest Rust entry published there (not a Rust program we write ourselves, so nobody can say the other side was handicapped). The Benchmarks Game programs are under the revised BSD licence; the Rust sources are copied with their header and a link to the entry.

One sub-issue per program:

Plus one everyday library: the json package against serde_json.

Left out for now, each with its reason: regex-redux (needs a regex package; filed separately when one exists), pidigits (needs arbitrary-precision integers).

To build (this issue: the frame)

  1. benches/game/game.sh, on the pattern of benches/brc/brc.sh: it builds each Nikaia program and each Rust program as a binary of its own, release on both sides with the same settings (opt-level 3, LTO on both or neither, same codegen units), checks that the outputs are the same byte for byte, counts with callgrind, and prints the table.
  2. Per program, four rows: Nikaia as a Nikaia programmer writes it first; Nikaia written for speed (if it differs); each with overflow checks on, and a second row with them off (docs/measuring.md); and the fastest Rust entry. A column with the tokens of each program (scripts/tokens.nika).
  3. The input size per program is chosen so that one callgrind run stays under about a minute, and is written in the table head. The Benchmarks Game Rust entries that use threads are counted as they are (callgrind serialises threads; total instructions); a second row with one thread where the entry allows it.
  4. benches/game/README.md: the method and the current table only. Rows where Nikaia loses stay in the table.
  5. A link to the table from the website’s performance page and from README.md (by docs/writing-guide.md).

Findings. Where Nikaia counts more instructions than Rust, the cause is found with callgrind_annotate and filed as an issue (performance, ready) with the attribution. It is not worked around in the benchmark program (CLAUDE.md, Fix, do not work around). A missing form of the language or of std stops the program’s sub-issue as Result: blocked (CLAUDE.md, A missing form stops the work).

Done when benches/game/game.sh prints a table with every sub-issue’s program, the outputs of both sides are the same byte for byte, and every row where Nikaia counts more has an issue that names the cause.

Comments

keywan-ghadami, 2026-11-16

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

n-body now has a “Nikaia for speed” row (simd::Fixed[f64, 4], benches/game/n-body/speed.nika): 249.5 instructions a step at x86-64-v3 against Rust #9’s 196.4 (1.27x), 510.5 at x86-64; plain program unchanged at 326.4 (1.66x).


Generated by Claude Code

keywan-ghadami, 2026-11-16

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

spectral-norm (#1613) is in game.nika: per matrix entry at n=1000, checks off, Rust #6 10.0 instructions; Nikaia plain 14.3 at x86-64-v3 (1.42x), 19.0 at x86-64; Nikaia for speed (simd::Fixed[f64, 2]) 8.0 at v3 (0.80x), 9.5 at x86-64. Same output 1.274224148 for all.


Generated by Claude Code

keywan-ghadami, 2026-11-16

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

fannkuch-redux (#1614) is in game.nika: per permutation at n=10, checks off, Rust #6 81.5 instructions; Nikaia plain 515.9 (6.33x), for speed 216.1 (2.65x), same at x86-64-v3. The same algorithms in plain Rust count 499 and 266, so Nikaia’s code costs what Rust’s does; the gap is Rust #6’s run-time pshufb (no form in std::simd, ADR-377 §4). The run also made a list’s clone a memcpy (612 -> 516 for the plain program).


Generated by Claude Code

keywan-ghadami, 2026-11-16

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

binary-trees (#1615) is in game.nika: per tree node at depth 16, checks off, Rust #5 (bumpalo arena) 43.3 instructions; Nikaia plain (recursive enum, one Box per node) 248.8 (5.75x), same at x86-64-v3; the same boxed tree in plain Rust counts 197.1, so the gap is the per-node malloc/free against the arena (#490 step 5) plus about 50 instructions a node of the Counting allocator.


Generated by Claude Code

keywan-ghadami, 2026-11-16

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

mandelbrot (#1616) is blocked: binary PBM output needs bytes on standard output, which ADR-019 D6 leaves undecided; reverse-complement and fasta will meet the same gap. Fastest Rust entry is Rust #4, no explicit SIMD.


Generated by Claude Code

keywan-ghadami, 2026-11-16

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

fasta (#1617) is in game.nika: per letter at n=2500000, checks off, Rust entry 7 on one thread 25.7 instructions (its two spin-locked threads never finish under callgrind); Nikaia plain 94.0 (3.66x), 1.16x the same algorithm in plain Rust; for speed 24.8 (0.96x) at x86-64 and v3. The output, md5 daf1153f, is the input for k-nucleotide and reverse-complement at that size.


Generated by Claude Code

keywan-ghadami, 2026-11-16

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

k-nucleotide (#1618) is in game.nika: per letter of section THREE on fasta 250000’s output, checks off, Rust entry 7 313.8 instructions; Nikaia plain 2537.2 (8.08x), for speed (two-bit codes, u64 keys) 989.1 (3.15x), 958.4 at x86-64-v3. Both Nikaia rows read standard input untrusted and so hash with SipHash-1-3; trusted, speed counts 1.13x Rust. Programs that read standard input run under callgrind with io-method = “blocking” (valgrind 3.22 deadlocks on the io_uring wait).


Generated by Claude Code

keywan-ghadami, 2026-11-16

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

reverse-complement (#1619) is in game.nika: per letter on fasta 2500000’s output, checks off, Rust entry 1 1.9 instructions (SSSE3 pshufb table, one thread the same); Nikaia plain 45.0 (23.2x), 1.15x the same algorithm in plain Rust; for speed (in place, Array[u8, 256] table) 10.6 (5.5x), 10.1 at x86-64-v3. Same output md5 ce5a95c7. The run also made io::read and Path::parts hand back a program’s Vec (they were NK1343 into a Vec parameter).


Generated by Claude Code

keywan-ghadami, 2026-11-16

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

docs/measuring.md now asks each loss against a game entry to quote a control: the Nikaia program’s own algorithm in plain Rust, counted beside it (#1847), which tells the other entry’s algorithm from Nikaia’s own cost.


Generated by Claude Code

keywan-ghadami, 2026-11-16

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

benches/game/README.md, asked by the children (#1615, #1618: “The README says which allocator”), is made by this issue’s open frame item, so each child meets it missing; file the README as its own issue and name it Needs #N in the children still open (docs/issues.md I4, #1853), or say each child adds its own section.


Generated by Claude Code

keywan-ghadami, 2026-11-18

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

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).


Generated by Claude Code

keywan-ghadami, 2026-11-18

Brief queued: issue-1611


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

Issue #1611

Your work order is issue #1611, 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/1611/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-1611.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-18

Run: issue-1611, Result: partial: mandelbrot is not in the table (its sub-issue #1616 is open), and no issue number is known here for the causes of the n-body, spectral-norm, fannkuch-redux, fasta, k-nucleotide, reverse-complement and json losses

Tokens: input 84, cache read 2394106, cache write 70989, output 19321 Cost: 1.48 USD, time 1 min 50 s, turns 42

Report

Result: partial: mandelbrot is not in the table (its sub-issue #1616 is open), and no issue number is known here for the causes of the n-body, spectral-norm, fannkuch-redux, fasta, k-nucleotide, reverse-complement and json losses Files: benches/game/README.md README.md website/research/performance/index.md Commit: benches/game/README.md: the method and the table of every Benchmarks Game problem against its fastest Rust entry, linked from README.md and the performance page Body: Frame items 1-3 were built by the children (game.nika, not game.sh, by CLAUDE.md’s helper-tools rule). This run adds item 4, benches/game/README.md, with the programs, the method, the table of a full nikaia run benches/game/game.nika today (7 problems and json, every output the same byte for byte) and the known cause of each loss, rows where Nikaia loses kept. It also adds item 5, a link from README.md (Very fast) and from website/research/performance. Two earlier commits made game.nika run again: json/input.nika used chars(), now an error, and k-nucleotide/main.nika’s sort key was a view, now NK1104. Figures moved since the children: fasta plain 3.66x -> 3.08x, speed 0.96x -> 0.78x; k-nucleotide plain 8.08x -> 6.37x; reverse-complement plain 23.2x -> 20.9x; json 1.33/1.65/1.93x. Part: #1611 Tests: nikaia run benches/game/game.nika (all problems, exit 0, outputs the same byte for byte); json/input.nika fails on HEAD’s version with the chars() error and runs after the fix; nikaia check of every main/speed.nika; pre-push green with the docs staged (page-examples green) Gate: green Deviation: item 1 is benches/game/game.nika, not game.sh (CLAUDE.md, helper tools are Nikaia); item 2’s token column holds Nikaia and Rust only, as game.nika prints it Found: none Needs: #1616 Changelog: benches/game/README.md: the Benchmarks Game table. Seven programs of the Computer Language Benchmarks Game and the json package, each counted with callgrind against the fastest Rust entry published there, with the method and the known cause of every loss; linked from README.md and the performance page. Issue: broke I4: Done when asks for every sub-issue’s program, but mandelbrot (#1616) is a separate open sub-issue and this frame names no Needs #1616; broke I7: Done when asks every losing row to have an issue naming its cause, but those issues were filed by the driver from the children’s Found lines and their numbers reach no builder, so the frame cannot check it Comment: #1611 benches/game/README.md now holds the method and today’s full table (Nikaia 0.0.1431). Left: mandelbrot (#1616), and links from the README’s causes to the performance issues filed from the children’s Found lines (n-body has no attributed cause yet; spectral-norm signed /2 and scalar divide; fannkuch-redux and reverse-complement run-time pshufb, ADR-377 section 4; k-nucleotide keyed hash; json path text and per-character copy). Their numbers are not visible to a builder. Owner: none Friction: game.nika prints its table only at the end, so the first full run (9 minutes) lost every row when k-nucleotide failed to build; one problem’s failure could leave the rows counted so far Disk freed: target/game-bench 530M removed; target/nikaia-project-tests 856M, 13G free, no new entry over 100 MB Attribution: Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com Claude-Session: https://claude.ai/code/session_01UVxJDukWgopUzVU2M1TjK7 Reviewed: 0e1eecdbace272ca86733e1dfed2ddc6a2fab91f1883d446fb8cff308665e7a3 Pushed: local 5ee574af16e94531dbaceb0938771d58d3b5e5c5

Debrief

  1. Most time: the first full run of game.nika, about 9 minutes. k-nucleotide failed to build late in the run, and because the table prints only at the end, every row counted before it was lost.
  2. Looked up: the per-row causes and figures, gathered from eight child commit messages. Also the issue numbers for those causes, which I never found. I also had to find that chars() and the NK1104 lambda-key refusal had changed since the children ran.
  3. Checks run:
    • Two full game.nika runs; the first was wasted.
    • nikaia check on every main/speed.nika; it would have caught the k-nucleotide break before the first run.
    • A fails-before run of input.nika; pre-push, three times.
    • The build turned out to be a no-op.
  4. One change: builder.md could say: “Before a long bench harness run, nikaia check every program it builds; language refusals land daily.”
  5. What the issue lacked:
    • broke I4 Done when asks for every sub-issue’s program, but it names no Needs #1616 for mandelbrot, which is open.
    • broke I7 Done when asks every losing row to have a cause issue, but it gives no list of the cause issues the children filed, so a builder cannot check it.
    • wrong I1 item 1 asks for game.sh, but the harness is game.nika, by CLAUDE.md’s rule that helper tools are Nikaia.
    • rules-gap a frame issue whose children finished could carry their figures in one place; they are spread over comments and commit bodies.
  6. Facts for the next builder:
    • Fact: Measuring | benches/game/game.nika prints its table only after every problem has run, so check all bench programs with nikaia check first, or one build failure discards the whole run.
    • Fact: Measuring | Bench programs under benches/ are not in any test, so a language change such as chars() becoming an error or the NK1104 lambda-key refusal breaks them silently; expect fixes before measuring.

Generated by Claude Code

keywan-ghadami, 2026-11-18

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

benches/game/README.md now holds the method and today’s full table (Nikaia 0.0.1431). Left: mandelbrot (#1616), and links from the README’s causes to the performance issues filed from the children’s Found lines (n-body has no attributed cause yet; spectral-norm signed /2 and scalar divide; fannkuch-redux and reverse-complement run-time pshufb, ADR-377 section 4; k-nucleotide keyed hash; json path text and per-character copy). Their numbers are not visible to a builder.


Generated by Claude Code

keywan-ghadami, 2026-11-18

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

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


Generated by Claude Code

keywan-ghadami, 2026-11-18

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


Generated by Claude Code

Back to Open Issues