Open and answer this issue on GitHub.
lowering, performance, blocked, tooling · opened 2026-11-18 · updated 2026-11-21 · 5 comments
Found while: supervising the yaml lane (YAML package, #928), 2026-11-18. Related: #2078 (the merge re-lowers with the old binary and fails), #1102 (rebase conflicts in lowered files), #1278 (lower-std cache key), #1581 (a cold lowering of the tools package takes 3–5 minutes).
On 2026-11-18 the yaml driver merged origin/develop before pushing its tested commits, twice. Both merges conflicted only in crates/nikaia-std/src/compiler/lowered.rs (3915 lines, the index every lane’s lowered change touches). Each one cost about 30 minutes of wall time before the push:
lower-std refused the merged sources, because develop had changed code parameters to &mut impl FnMut (ADR-views-3 D17). That is the failure #2078 covers. The supervisor had to bootstrap by hand: build develop’s compiler, then lower-std --sysroot /home/user/Nikaia/crates, then build again.MERGE cb513c37 re-lowered crates/nikaia-std/src/compiler/lowered.rs), the driver’s own re-lowering in target/ledger-tree ran about 30 minutes, with the short checks after it, before PUSHED cb513c37.With several lanes pushing to develop, almost every merge conflicts in lowered.rs. That makes each lane’s integration slow, and the owner paused the yaml lane for the day to bring the integration speed back up.
compiler/lowered/*.rs, 273 files, plus the index lowered.rs) are checked in. Every lane that changes any lowered .nika file rewrites lines in the one shared index, so concurrent lanes conflict there even when their .nika changes do not touch each other.lower-std (plus a build on each side) in the ledger tree. That run lowers far more than the files whose .nika source changed in the merge, and its cache is cold or keyed too coarsely (#1278).A merge of origin/develop whose only conflicts are in lowered files settles in the driver in a few minutes (measured: the time between the MERGE <sha8> line and short checks, logged by the driver), without hand work. The supervisor notes in docs/tokenspeed.md or the driver log how long the next three such merges took.
drive_merge_regenerate how long each step takes (build, lower-std, build again), and record one real lowered-only merge as the baseline in this issue.lowered.rs: see what each lane changes in it (module lines, digests, a list of entries?), and change the lowering so that the index changes only when a module is added or removed. One option is to move the per-file part, such as a digest, into each lowered/<file>.rs. Another is a merge=ours driver in .gitattributes for the index and the lowered files, so that git never stops on them and the driver always regenerates. Decide which of the two in the build and give the reason in the comment..nika files whose source differs between the merge base and the merged tree, plus their dependants, instead of a full lower-std. If lower-std has no such mode, add one, written in Nikaia. This builds on the cache key of #1278.scripts/drive.nika and docs/supervisor.md (the merge step) with the new cost.Generated by Claude Code
Brief queued: issue-2154
agent: builder model: opus max_turns: 200 budget_usd: 30 effort: medium —
Your work order is issue #2154, 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/2154/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-2154.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-2154, Result: partial
Tokens: input 112, cache read 3997739, cache write 120341, output 35467 Cost: 2.66 USD, time 16 min 21 s, turns 56
Result: partial
Files: scripts/drive.nika docs/supervisor.md tests/compiler/tests/drive_relower.nika tests/compiler/tests/drive_relower.stdout tests/compiler/tests/drive_merge_shared_checkout.nika tests/compiler/tests/drive_merge_shared_checkout.stdout
Commit: drive: time each merge-regeneration step, settle on a round that changed only LOWERED_DIGEST, reuse the settled binary for the ledgers
Body: drive_merge_regenerate prints a MERGE timing line (each build, lower-std, badges, ledgers, total). drive_lowered_print leaves out the pub const LOWERED_DIGEST: line, so a round that changed only the index digest counts as settled: that saves one build and one cold lower-std per merge, since the digest feeds compiler_identity and makes the cache cold. The ledgers step reuses the binary the settle built (drive_ledgers_refresh_on) and no longer runs another cargo build. #2078’s order is unchanged. Tests: drive_relower gets the cases “index digest only” (settles in 2 rounds; HEAD’s drive.nika escalates “lower-std did not settle after 5 rounds”) and “merge build” (3 cargo runs, the ledgers step adds none). The timing figures are written as Ns in the test output.
Part: #2154
Tests: all 30 tests/compiler tests that use scripts/drive.nika pass; pre-push green; target/fast/nikaia check scripts/drive.nika clean; the “index digest only” case failed on HEAD’s drive.nika (escalated after 5 rounds)
Gate: green
Deviation: item 2 (cut the conflicts in lowered.rs) not built: the driver settles a lowered-only conflict by taking their side and regenerating, the same as a clean merge, so the conflict adds no time. The time goes into the regeneration rounds. Per-file digests would need Rust changes in compiler_identity/commit.nika and would help only hand merges. A merge=union attribute would duplicate the LOWERED_DIGEST line and break the first build.
Deviation: item 3 (re-lower only what changed) built as fewer rounds and builds, not per-file reuse: compiler_identity (NIKAIA_COMPILER + LOWERED_DIGEST) changes with every merge, so reusing per-file lowering across identities is unsound without a decision on what the identity covers
Found: none
Needs: supervisor decision: whether lower-std may reuse per-file lowered output across compiler identities (needed for item 3 as written); the Done-when figure must be read from real merges’ MERGE timing lines
Changelog: Driver merges: a MERGE timing line per merge; a round that changed only LOWERED_DIGEST counts as settled, which saves a build and a cold lower-std; the ledgers reuse the settled binary
Issue: meets I1-I13 except item 2, which presumes the conflict costs time; in the driver, the regeneration rounds do
Comment: #2154 Measure with the new MERGE timing line on the next real merges before building per-file re-lowering; the digest-insensitive settle and the ledger binary reuse should take about one build and one cold lower-std off each merge
Friction: none
Disk freed: 0 (target/nikaia-project-tests 2.0G, / 19G free)
Attribution:
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01UVxJDukWgopUzVU2M1TjK7
Reviewed: d018d9416d0c037ce1ef78a232cf68ab0d4e957057c7c3d99e0a71712f280b95
Pushed: local 3a93041a95e5c3484096516dd91572c32ae30a57
date +%N stub that gave a different result each run, a sh(work, …) call after work had already been moved, and blessing before the test was finished.compiler_identity hashes (NIKAIA_COMPILER plus LOWERED_DIGEST, in crates/nikaia/src/lib.rs), how LoweredBefore::open makes the cache cold, and that drive_ledgers_refresh → drive_tree_exe always runs cargo build again. The brief could have handed me all three.nikaia check scripts/drive.nika, the drive_relower and drive_merge_shared_checkout tests, all 30 tests that use the driver (twice), pre-push, a fails-before run on HEAD’s drive.nika, and the commit dry run. Wasted: the first background run of the 30 tests, which ran before my last edits, and one rebuild of a binary that was stale against HEAD. The “merge build” case gave 3 cargo runs with my change; I did not rerun it on HEAD to show the one-run saving. Also, my report came to 20 lines, over the brief’s limit of 15.Ns before blessing.wrong I7: the cause “a lowered-only conflict costs ~30 min” is not marked as suspected. In the driver, a conflict takes their side and regenerates exactly like a clean merge, so the time goes into the regeneration rounds, not the conflict.broke I5: there is no reference figure or per-step timing to measure against, so Done-when (“settles in a few minutes”) cannot be checked locally.rules-gap: it does not say whether per-file re-lowering may reuse output across compiler identities. That needs a decision, and I named it under Needs:.knowledge: Lowering | LOWERED_DIGEST feeds compiler_identity, so every new digest makes lower-std's cache cold.Fact: Core | Calling a function such as sh(dir, …) takes ownership of a String argument, so pass dir.clone() when dir is used again later.Fact: Lowering | A lowered set that differs only in its LOWERED_DIGEST line lowers to the same files, so a settle check may ignore that line.Generated by Claude Code
From the report of the run of issue-2154 (#2154):
Measure with the new MERGE timing line on the next real merges before building per-file re-lowering; the digest-insensitive settle and the ledger binary reuse should take about one build and one cold lower-std off each merge
Generated by Claude Code
Built in 3a93041a (driver): each merge prints a MERGE timing line; a round that changed only LOWERED_DIGEST counts as settled (saves one build and one cold lower-std per merge); the ledgers reuse the settled binary.
Not built:
MERGE timing lines of real merges.Supervisor: accepted as partial; the issue stays open for the Done-when figure.
Generated by Claude Code
Supervisor, 2026-11-21: the MERGE timing lines of the last eight real merges in the performance driver (target/drive-performance.log):
| build | lower-std | ledgers | total |
|---|---|---|---|
| 48 s | 187 s | 117 s | 357 s |
| 153 s | 308 s | 100 s | 567 s |
| 234 s | 412 s | 117 s | 771 s |
| 79 s | 326 s | 102 s | 513 s |
| 18 s + old lower-std 345 s + 49 s | 327 s | 103 s | 848 s |
| 246 s | 323 s | 112 s | 685 s |
| 185 s | 303 s | 101 s | 593 s |
| 44 s | 363 s | 111 s | 524 s |
A merge now takes 6 to 14 minutes, against the earlier 30. Done when asks for “a few minutes”, which is not met yet. The full lower-std, at about 5 minutes, is now the largest part. Cutting it is item 3, re-lowering only what the merge changed. Item 3 needs:
This issue is set to blocked until those two land. The ledgers step, at about 110 s, is the next candidate.
Generated by Claude Code