Issue #1616: benches/game: mandelbrot counted against the fastest Rust entry

Open and answer this issue on GitHub.

performance, blocked · opened 2026-11-15 · updated 2026-11-16 · 5 comments

Part of #1611 (Benchmarks Game programs in benches/game/), which holds the method, the harness and the rules for findings.

What it measures. Float arithmetic per pixel with an early exit, eight pixels packed into one byte, and a binary PBM image written to standard output: float loops, bit operations on u8, and byte output.

To build

  1. The Nikaia program in benches/game/mandelbrot/, as a Nikaia programmer writes it first; a second version written for speed only if it differs. If the fastest Rust entry uses explicit SIMD and Nikaia has no form for it, that is a finding to sort by CLAUDE.md (A missing form stops the work), and the table gets a second Rust row: the fastest entry without explicit SIMD.
  2. The fastest Rust entry for mandelbrot from the Benchmarks Game, copied with its licence header and a link, as a binary of its own.
  3. Same output byte for byte at the chosen size (compare the image bytes).
  4. The rows in the table of #1611: instructions and mispredictions, overflow checks on and off, and tokens.
  5. Every row where Nikaia counts more: the cause from callgrind_annotate, filed as an issue.

Done when benches/game/game.sh prints mandelbrot’s rows next to the Rust entry with the same output, and each loss names its issue.

Comments

keywan-ghadami, 2026-11-16

Brief queued: issue-1616


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

Issue #1616

Your work order is issue #1616, 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/1616/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-16

Run: issue-1616, Result: blocked

Tokens: input 60, cache read 1804933, cache write 64939, output 10124 Cost: 1.12 USD, time 2 min 16 s, turns 30

Report

Result: blocked Files: none Commit: none Body: Stopped before the first edit. Mandelbrot’s output is a binary PBM image (the “P4\nN N\n” header, then N*N/8 packed bytes, most of them not UTF-8), and Nikaia has no way to write bytes to standard output: ADR-019 D6 keeps output to print/println and says “Binary output is the open half, not decided here”; no later ADR or Part I-III section decides it (searched docs/specification for binary output, Bytes on stdout, io::write). Writing through fs::open(“/dev/stdout”) would route around the gap, so nothing was built. The fastest Rust entry is Rust #4 (0.95 s, https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/mandelbrot-rust-4.html): F64x8 as a plain [f64; 8] array with operator impls, autovectorised, no explicit SIMD, rayon over rows, 49 iterations with a divergence check every 4 and only while the previous byte was 0; so the Nikaia “for speed” row can use simd::Fixed[f64, 8] and no second Rust row is needed. Once the decision is built, the run is: benches/game/mandelbrot/main.nika (per pixel, 50 iterations, break at |z|²>4, 8 bits packed into a u8), speed.nika (8 lanes), rust-4.rs copied with header, a Game entry in game.nika (rayon, RAYON_NUM_THREADS=1 row), outputs compared with cmp. Pushed: none Tests: none run beyond probes on the before binary (target/fast/nikaia at HEAD 8d2e6a88, copied to the scratchpad); nothing committed. Gate: green Deviation: none Found: Nikaia has no form to write bytes to standard output (no decision yet: ADR-019 D6 “Binary output is the open half, not decided here”); probe fn main() throws {\n\tlet mut v: Vec[u8] = []\n\tv.push(200 as u8)\n\tv.push(10 as u8)\n\tlet b = Bytes(v)\n\tprint(b)\n} run with nikaia run a.nika gives NK1343 internal error (rustc: nikaia_std::bytes::Bytes doesn’t implement std::fmt::Display); expected: the two bytes 0310 012 on stdout through whatever form is decided (print/print of Bytes, or an io::write); blocks benches/game mandelbrot (#1616) and later reverse-complement’s and fasta’s byte output (#1611); std has the Rust pieces already (fs.rs FilePath print writes raw bytes with std::io::stdout().lock().write_all). Found: the checker accepts print(Bytes(v)), println(Bytes(v)) and print(f"{Bytes(v)}") and rustc then refuses the lowered code: NK1343 “Internal compiler error”, note “nikaia_std::bytes::Bytes doesn’t implement std::fmt::Display” (probe fn main() throws {\n\tlet mut v: Vec[u8] = []\n\tv.push(200 as u8)\n\tprint(f"P4\n{v.len()}\n")\n\tprintln(Bytes(v))\n}, nikaia run b.nika, binary at HEAD 8d2e6a88); expected either the bytes (if the binary-output decision makes print take Bytes) or a checker refusal with an NK code naming the type, never NK1343 (its own help says the checker should not have accepted it); no decision yet, since which of the two depends on the decision above; suspected site: the print argument check in the checker’s prelude call typing (cause not traced). Needs: supervisor decision: how a program writes bytes to standard output (ADR-019 D6’s open half), e.g. print/println taking Bytes, or a std::io write of Bytes; then #1616 can be built. Changelog: none Issue: rules-gap: #1616 and #1611 name “byte output” as what mandelbrot measures but neither checked that Nikaia can write bytes to stdout (ADR-019 D6 leaves it undecided); a pre-flight probe in the issue would have filed the decision first (I-rule on probes before ready) Owner: none Comment: #1611 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. Friction: none Disk freed: none (target/nikaia-project-tests 843M, / 17G free; no cache entries created) Attribution: Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com Claude-Session: https://claude.ai/code/session_01UVxJDukWgopUzVU2M1TjK7

Debrief

  1. Most turns: finding out whether Nikaia can write bytes to stdout at all. I grepped io.rs and fs.rs, ran three print(Bytes) probes and searched the ADRs before ADR-019 D6 settled it. Two early turns went to cd $S with S unset, and one to a bare nikaia that isn’t on PATH.
  2. Looked up: ADR-019 D6 (“binary output is the open half”); that std has no byte write to stdout (fs::Path::print is the only raw stdout write, and it is internal); that Bytes(v) takes a Vec[u8] and has no push; which Rust mandelbrot entry is fastest (Rust #4, no explicit SIMD).
  3. Checks run: the print(Bytes) probes (needed), the ADR grep (needed), and fetching the Rust entries (useful for the next run). Reading game.nika and spectral-norm’s main.nika in full was wasted once the run was blocked.
  4. One change: the issue lists the I/O forms its program needs (“byte output”). A probe of each on develop before it is marked ready would have caught this as a decision first, without a builder run.
  5. What the issue lacked:
    • rules-gap: it names “byte output” but no probe that Nikaia can do it; no rule asks for a probe of each capability an issue’s program needs.
    • rules-gap: #1611 lists fasta and reverse-complement too, and both need the same undecided form; nothing records that dependency.
  6. Traps for the next builder:
    • Fact: Core Nikaia cannot write bytes to stdout (ADR-019 D6 leaves it undecided), and print(Bytes) passes the checker but fails as NK1343; a program with binary output is blocked until it is decided.
    • Fact: Core nikaia is not on PATH here; call target/fast/nikaia run scripts/syntax.nika and the other scripts by that path.
    • Fact: Core cd into the scratchpad resets the shell to the repo; write absolute scratchpad paths in every command.

Generated by Claude Code

keywan-ghadami, 2026-11-16

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


Generated by Claude Code

keywan-ghadami, 2026-11-16

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

Unblocked: print(b) of Bytes now writes the bytes unchanged (#1859), so mandelbrot can write its PBM image.


Generated by Claude Code

keywan-ghadami, 2026-11-16

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

waits for the decision on bytes to standard output (#1854); add Needs #1854 so the driver holds it until that is built.


Generated by Claude Code

Back to Open Issues