List::zeroed from the emitter, and a block’s untouched pagesOpen and answer this issue on GitHub.
performance, blocked, future · opened 2026-11-09 · updated 2026-11-19 · 4 comments
Since the switch to the block types (#490), vec[v; n] lowers to task_block::List::from_elem, which writes v into every element. Rust’s std Vec recognises an all-zero element (an internal specialization only std may use) and asks for zeroed memory instead (alloc_zeroed, calloc): fresh pages from the operating system are zero already, so nothing is written.
Measured on benches/brc/fast-unsafe.nika (vec[Slot{..}; 65536] of zeros, 3.6 MB): 101.9 -> 103.8 Ir/row (callgrind, 200k rows), the whole rise one memset, paid once per run; Table::run is identical to the instruction. callgrind overstates it: with calloc the kernel zeroes the pages on first touch, which callgrind does not count; what remains is one extra pass over the memory.
from_elem cannot test an element’s bytes for zero itself: padding bytes are uninitialised and reading them is undefined behaviour.
task_block::List::zeroed(n) (unsafe, for an element type whose all-zero bytes are a valid value): asks the Place allocator for zeroed memory. Outside a block that is alloc_zeroed (calloc), as Vec gets.List::zeroed(n) where vec[v; n] has a literal v whose every field is a numeric zero or false (recursively, no default field left out, no field of a type that may not be all zeros); otherwise from_elem as today.tests/compiler/: a zero-literal table and a non-zero one print the same as today; benches/brc/fast-unsafe.nika back to 101.9 Ir/row or below (callgrind, docs/measuring.md).A list of all-zero elements is made without writing its memory outside a block, and in a block only where the block reuses memory.
Brief queued: issue-1489
agent: builder model: opus max_turns: 200 budget_usd: 30 effort: medium —
Your work order is issue #1489, 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/1489/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-1489.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-1489, Result: blocked
Tokens: input 54, cache read 1276779, cache write 55265, output 15189 Cost: 1.04 USD, time 3 min 15 s, turns 27
Result: blocked
Files: none
Commit: none
Body: nothing built or committed; lowering checked on the current binary: let mut slots: Vec[Slot] = [] + slots.resize(65536, Slot { a: 0, b: 0 }) lowers to nikaia_std::block::list(Place::Block) + resize, and [Slot { a: 0, b: 0 }; 1000] lowers to vec[Slot { a: 0, b: 0 }; 1000] (from_elem); benches/brc/fast-unsafe.nika’s table is the resize form (fn table), not vec[v; n]
Pushed: none
Tests: none run (nothing changed)
Gate: green
Deviation: none
Found: Step 2 has the emitter write a call to an unsafe List::zeroed, but ADR-218 D4 lets emitted code hold unsafe only around foreign calls and nikaia_std::proven operations, and ADR-378 D2/D3 lets it hold unsafe only around a proven operation, when the switches are on, listed in D3’s test; nikaia_std::proven is the proven-index crate, which does not depend on task-block’s List. Probe: struct Slot { a: u64, b: i64 } / let t = [Slot { a: 0, b: 0 }; 1000] lowers today (nikaia lower p.nika) to let t = vec[Slot { a: 0, b: 0 }; 1000];, and the only unsafe in the file is unsafe { nikaia_std::proven::add::<i64>(..) }. No decision yet on whether “every field a literal zero” is a proved operation under ADR-378 (a proven:: entry, only when the switches are on), on which crate holds it (proven-index taking an allocator hook, or task-block reached through proven), or on a safe route instead (an AllZero trait sealed in task-block: primitives only, so user structs such as brc’s Slot would need an unsafe impl in emitted code)
Found: Step 3’s premise does not hold: in crates/unsafe/task-block/src/lib.rs, segment() takes a segment from the thread’s SPAREs (another task’s memory, already written) or from System.alloc(MEMORY) (malloc of 64 KiB with page alignment, which may hand back reused heap memory), and Block::whole takes System.alloc(run_layout(..)). So no page of a block is known to be zero, and with System.alloc_zeroed at page alignment Rust’s std does an aligned alloc plus write_bytes, which is the same memset. Skipping the zeroing in a block needs segments from mmap (a libc dependency task-block lacks) or some other zero source. No decision yet: until then, a zeroed cut in a block can only be the default allocate plus write_bytes
Needs: supervisor decision
Changelog: none
Issue: broke I6: the issue orders an unsafe call written by the emitter, a kind of unsafe ADR-218 D4 and ADR-378 D2/D3 do not admit, and it neither cites nor proposes a decision for it; broke I4a: step 3 says a block’s untouched memory is zero pages from the operating system, but segment()/Block::whole in task-block/src/lib.rs use System.alloc (malloc) or reused spares; broke I11: the issue names neither crates/unsafe/task-block/README.md (ADR-218 lists every unsafe there) nor the emitter files; the site to change is emit_stmt.nika’s resize fusion as well as emit_core_places.nika emit_core_list_repeat, since the bench uses [] + resize, not vec[v; n]
Owner: none
Comment: none
Friction: none
Disk freed: none (target/nikaia-project-tests 1.8G; / 7.5G free of 252G; no cache entries created)
Attribution:
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01UVxJDukWgopUzVU2M1TjK7
unsafe at all. That meant reading task-block/src/lib.rs (where segments come from, Place), the unsafe_code notes in nikaia-std/lib.rs, ADR-218 D4/D5 and ADR-378 D2/D3. It took about 15 turns, and I reached the conflict only after I had started planning the build.unsafe. The two places that emit vec[v; n] (emit_core_places.nika emit_core_list_repeat, and the resize merge in emit_stmt.nika). How segment() and whole get their memory. That the benchmark’s table is [] + resize, not vec[v; n].nikaia lower p.nika), which settled both emit sites and is worth keeping, and the disk check. None were wasted, and I did no build. The binary was older than HEAD, which did not matter for a lowering probe.unsafe, or adds an unsafe API, is checked against ADR-218 D4 and ADR-378 D2/D3 before planning.” That one line would have ended the run in about 5 turns.broke I6: no ADR covers the unsafe call the emitter is ordered to write, and the issue doesn’t say “no decision yet”.wrong I4a: step 3 says a block’s untouched memory is zero pages from the operating system, but segments come from malloc or reused spares. My report tagged this broke I4a; wrong is the correct tag.broke I11: the issue names no files: not task-block/README.md (the list of every unsafe), and not the emitter’s resize merge.knowledge: Lowering | Rust's std System.alloc_zeroed at page alignment does an aligned alloc plus memset, so only mmap gives untouched zero pages.| Fact: Lowering | Generated code may hold unsafe only around foreign calls and nikaia_std::proven operations (ADR-218 D4, ADR-378 D2/D3), so a new unsafe API for the emitter needs a decision first. |
| Fact: Lowering | [] followed by resize(n, v) is merged by emit_stmt.nika into vec[v; n] or List::from_elem_in, a second emit site beside emit_core_list_repeat. |
Generated by Claude Code
The report of the run of issue-1489 (#1489) judged this issue against docs/issues.md; the author fixes the issue by the rule it names (How a run judges its issue):
unsafe call written by the emitter, a kind of unsafe ADR-218 D4 and ADR-378 D2/D3 do not admit, and it neither cites nor proposes a decision for itsegment()/Block::whole in task-block/src/lib.rs use System.alloc (malloc) or reused sparescrates/unsafe/task-block/README.md (ADR-218 lists every unsafe there) nor the emitter files; the site to change is emit_stmt.nika’s resize fusion as well as emit_core_places.nika emit_core_list_repeat, since the bench uses [] + resize, not vec[v; n]Generated by Claude Code
Driver: not queued, this issue waits for #2179, #2180, which is still open (#1819). Set ready again when it is closed.
Generated by Claude Code