Open and answer this issue on GitHub.
performance, blocked · opened 2026-11-07 · updated 2026-11-20 · 6 comments
Decided (owner, 2026-11-14): build it. This is the correct way to get fast warm lower-std runs. #1306 (option B, drop tools/ from the key) is closed as not correct: a changed compiler can lower std differently, and a cold fixpoint does not show that every std file’s output is unchanged. The measurements below say how much this gains. They are no longer a condition for building it.
Order: build after the move of crates/nikaia-std/src/tools/ to compiler/ (an issue for it follows), so the new cache is keyed on the new paths. #1160 is on develop (7427fd7a, 0faad64e), so it no longer conflicts.
NIKAIA_COMPILER (crates/nikaia/build.rs, compiler_fingerprint) hashes all of crates/nikaia-std/src/tools: 265 files and about 4,900 functions, .nika and lowered .rs alike. After any tools edit and a rebuild, every lower-std cache entry misses (about 128 s cold), and so does target/nikaia-project-tests. The gate’s fixpoint run (scripts/gate.nika gate_fixpoint) always hits that case.
crates/nikaia/src, nikaia-logic), the rustc version and std.contracts stay one coarse block each.(function, hash) that ran. For the ledger, the same per fact once #1277 makes it incremental.Why it is sound. Lowering is deterministic. The path through the code depends only on the inputs and on the code of the functions that run. A changed function that did not run can only start running if a function that does run branches differently, and that function’s hash would have changed. This needs three things, and the build has to show each one holds:
Limit. An edit to a core function (expression emit, type checking) is in every file’s trace and still misses everything. That is correct, but it is not faster.
blocked.crates/nikaia/src/sysroot.rs, build.rs), with NIKAIA_COMPILER narrowed to the coarse blocks.docs/measuring.md: the share of functions each file’s lowering runs, the hit rate over the last N tools commits, and the cost of the bitset in a cold run.NIKAIA_LOWER_TIMES=1 shows it.The causes of the time itself (ledger 54 s, a fixed emit cost of about 1 s per file): #1277.
Brief queued: issue-1278
agent: builder model: opus max_turns: 200 budget_usd: 30 effort: medium —
Your work order is issue #1278, 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/1278/comments -F body=@file,
ending with the Claude Code footer), rule I13.
develop in the main checkout; other agents’ uncommitted files are not yours: never touch or stage them.target/fast/nikaia run scripts/commit.nika -- REPORT (it adds exactly the report’s Files:); the driver pushes.cargo build --profile fast -p nikaia, lower-std and its fixpoint when a tools/*.nika changed, cargo fmt, cargo clippy --all-targets -- -D warnings, nikaia run scripts/pre-push.nika, the tests the issue names and the ones your change touches.CHANGELOG.md, badges and NK codes are the supervisor’s. New tests in Nikaia only: a Rust test file an older issue names is built as a tests/compiler/tests/ program, no Deviation: and no Issue: point (I9, #1671).Body:. Found: is only for what lies outside the area, cannot be fixed this run or needs a decision; the driver files it as an issue.std or the toolchain lacks stops the work, unless an ADR or Part I-III refuses it (name it): Result: blocked, Found: the gap with a probe, Needs: supervisor decision.NIKAIA_CACHE_LIMIT=2G; at the end delete your own clone’s target/ and target/release/nikaia-scratch.suspected, or does not mark (docs/issues.md I7), is a hypothesis: run the check that settles it (nikaia run scripts/where.nika -- NAME, the probe with a trace, callgrind for a cost) before you build on it (owner, 2026-11-16). Shown false: say so in Issue: as wrong I7: <what the check showed> (the driver comments it on the issue) and follow the real cause.Result: partial with what you ruled out, the probe, and the suspected file and function./home/user/Nikaia/docs/briefs/performance/issue-1278.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.
Result:, Gate: (green or red <check>), Deviation:, Found: and the other fields with nothing to say hold the bare word: done, none. Anything after it reads as content.Result: done only when the issue’s Done when holds; partial with the items left otherwise.Deviation: only for an item of the issue built otherwise than written, or not built. Found: only for a defect outside your area, or one this run cannot fix: one defect per Found: line, with its probe and the output it gives, only the shapes that fail today, and the suspected file and function or cause unknown (#1695); a by-design behaviour is none (#1677). A correct program your own change refuses (a fail-closed check’s false refusal) is no Deviation: but one Found: line per shape, with its probe (#1680). Everything else goes into Body:; how you verified goes into Tests:.Issue: by docs/issues.md, How a run judges its issue: complete, or broke I<n>: ..., rules-gap: ..., wrong I<n>: ..., joined with ;; a point your own commit built gets (built) after its kind (rules-gap (built): ...), and the driver does not file it. complete is the bare word: prose after it (complete; the earlier runs ...) is filed as an improvement issue (#1931); history or a note for your own issue goes into Body: or Comment: #N <text>.done <sha>, report <path> (or BLOCKED: ... / PUSH REJECTED ...).Generated by Claude Code
Run: issue-1278, Result: blocked
Tokens: input 30, cache read 591711, cache write 48098, output 13302 Cost: 0.81 USD, time 2 min 44 s, turns 15
Result: blocked
Pushed: none
Tests: none run; nothing built or committed (I stopped before the first edit, on reading the code)
Gate: green
Deviation: none
Found: The trace has no way to see memos that hand-written host Rust keeps of lowered results, so “no state outside the trace” (the issue’s soundness condition) does not hold on develop e6d25eb1. traced: (1) crates/nikaia/src/parser/mod.rs:372 bounds_beside: std::sync::OnceLock<BoundsBeside> on a shared Parsed. Whichever parallel per-file lowering walks it first fills it through lowered bounds_frame::bounds_beside, so those bits land in that thread’s bitset, and every other file reuses the value without them. (2) crates/nikaia/src/text_tiers.rs:148 static METHODS: OnceLock<MethodIndex> = ...get_or_init(|| nikaia_std::compiler::ty::method_index(library)), process-wide, filled once by lowered code. (3) crates/nikaia/src/comptime_run.rs:365 thread_local! REMEMBERED (constants computed by lowered code, reused by later files on the same worker thread), and KNOWN / DEFAULTS / AHEAD (lines 601-660). The result: a change to a function that only such a fill ran gives a cache hit with stale output. To be sound, each memo would have to record the trace bits at fill time and replay them on reuse, which is hand-written Rust in the host, or the memos would have to go during lower-std. The issue forbids that Rust (“No hand-written Rust for this beyond what the lowering writes … If that is not possible, stop and report it as blocked”). no decision yet
Needs: supervisor decision: how the host’s memos of lowered results (Parsed::bounds_beside, text_tiers METHODS, comptime_run REMEMBERED/KNOWN/DEFAULTS/AHEAD) join the per-file trace. Options: hand-written Rust record/replay at each memo site, dropping them during lower-std, or moving those host parts to Nikaia first.
Changelog: none
Issue: broke I7: the soundness section names “no globals” as a condition the build must show, but does not check it, and the host already holds several process-wide and cross-thread memos of lowered results; rules-gap: “No hand-written Rust beyond what the lowering writes” clashes with To build’s “hit check in lower-std (crates/nikaia/src/sysroot.rs, build.rs)”, which is Rust, and with the cache identity, which compiler_identity() also serves for target/nikaia-project-tests (narrowing NIKAIA_COMPILER would make those caches unsound unless lower-std gets its own identity)
Comment: #1278 Blocked before building: lowered compiler code fills host memos that hand-written Rust keeps (Parsed::bounds_beside OnceLock shared across the parallel per-file lowerings, text_tiers METHODS static OnceLock, comptime_run REMEMBERED/KNOWN thread_locals). A per-thread trace misses the functions those fills ran, so the hit check would be unsound. The emitter side looks feasible in Nikaia: emit_function.nika writes every fn header, sysroot_package.nika writes the index with LOWERED_DIGEST, and hash::sha256_hex exists. A design decision is needed for the memos, and also for lower-std’s own coarse identity, separate from compiler_identity(), which the project-test cache also uses.
Friction: none
Disk freed: none; target/nikaia-project-tests 1.8G, / 7.5G free, no new cache entries
Attribution:
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01UVxJDukWgopUzVU2M1TjK7
build.rs to compiler_identity, then to sysroot.rs lower_package and on to emit_function.nika, so I could see where a trace could go. The run itself was short: about 12 tool calls and no builds.compiler_fingerprint in build.rs, compiler_identity in lib.rs, and LOWERED_DIGEST, written by sysroot_package.nika;sysroot_cache.nika building the key (sysroot_names, sysroot_named_key);emit_function.nika writing every function header;hash::sha256_hex exists;tools/ to compiler/ move had already landed.The brief could have named all of these.
ls for the move, greps of the fingerprint, outlines from where.nika, and a grep for OnceLock/thread_local in the host and the lowered code. The grep that turned up the caches decided the run. Nothing was wasted. I ran no probe and no build, because the block came from reading code. So the Found: rests on reading code, not on a run, which the rules usually ask for.broke I7: “No state outside the trace” is stated but never checked, and the host already keeps several shared caches of results computed by lowered code. A grep settles it.rules-gap: the issue asks for no hand-written Rust, yet its To build names sysroot.rs and build.rs, which are Rust.rules-gap: compiler_identity() also keys the project-tests cache, and the issue does not say whether lower-std gets its own identity.knowledge: Measuring | the hit rate over the last N tools commits means building N compilers (about 10 minutes each), so it does not fit one run.wrong I7: the order “build after the move” names no issue, and the move had already happened.Fact: Core | Host Rust holds memos of lowered-code results (Parsed::bounds_beside OnceLock, text_tiers METHODS, comptime_run REMEMBERED/KNOWN thread_locals), so any per-file trace or cache keyed on "code that ran" must account for them.Fact: Measuring | compiler_identity() keys both the lower-std cache and target/nikaia-project-tests, so narrowing NIKAIA_COMPILER affects both caches.Generated by Claude Code
From the report of the run of issue-1278 (#1278):
Blocked before building: lowered compiler code fills host memos that hand-written Rust keeps (Parsed::bounds_beside OnceLock shared across the parallel per-file lowerings, text_tiers METHODS static OnceLock, comptime_run REMEMBERED/KNOWN thread_locals). A per-thread trace misses the functions those fills ran, so the hit check would be unsound. The emitter side looks feasible in Nikaia: emit_function.nika writes every fn header, sysroot_package.nika writes the index with LOWERED_DIGEST, and hash::sha256_hex exists. A design decision is needed for the memos, and also for lower-std’s own coarse identity, separate from compiler_identity(), which the project-test cache also uses.
Generated by Claude Code
The report of the run of issue-1278 (#1278) 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
Driver: not queued, this issue waits for #2176, which is still open (#1819). Set ready again when it is closed.
Generated by Claude Code
Open question moved here from the closed improve issue #2177 (Found: #2176): how do the host memos join the per-file trace (Parsed::bounds_beside, text_tiers METHODS, comptime_run REMEMBERED/KNOWN/DEFAULTS/AHEAD)? Options: hand-written record/replay, dropping the memos during lower-std, or moving those host parts to Nikaia. Also: lower-std needs its own cache identity.
Generated by Claude Code