link: strip the emitted program binary (-s), 6.4 MB -> 2.1 MB #39
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/039-link-strip-the-emitted-program-binary-s-6-4-mb"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
link: strip the emitted program binary (-s), 6.4 MB -> 2.1 MB
Along the way:
Touches 41 files:
current-state.md,docs/impl/memory-model/M1-arena-substrate.md,docs/impl/runtime-testing/README.md,docs/impl/runtime/03-meta-wire.md,docs/impl/runtime/R1-executor-core.md,docs/impl/runtime/README.mdand 35 more.Split. The decision in
try_emitis a pure function now, with its own tests insrc/rust/crates/ck_lower/src/codegen/assert.rs.It said what I assumed. Reworded in
src/rust/crates/ck_rt/src/arena.rsso it names the input that broke it, which is what the bug report will need.Yes. The commit messages carried me through all 41 files, which is not always true.
@ -0,0 +33,4 @@/// `Some(result)`; otherwise `None`, so the caller falls through to its ordinary/// call handling. Keeps the assert special-casing (and its branching) out of the/// codegen root's `emit_effect`.pub(super) fn try_emit(try_emitreads, decides and writes in one function. The deciding part is the piece I would want to test on its own. Worth splitting?@ -0,0 +157,4 @@/// is always valid and `size` is forced `>= 1`, so the layout cannot fail.const LAYOUT_INVARIANT: &str = "host_fallback: a (size >= 1, align = 1) layout is always valid";let size = if n == 0 { 1 } else { n };let layout = std::alloc::Layout::from_size_align(size, 1).expect(LAYOUT_INVARIANT);The expect message on
layoutis the only thing a user sees if this fires. Does it say what they should do, or only what we assumed?@ -0,0 +185,4 @@}// SAFETY: the caller's contract (above) guarantees `ptr` is valid for `len`// immutable bytes; a bounded, read-only slice materialization.let bytes = unsafe { std::slice::from_raw_parts(ptr, len) };An unsafe block around
bytes. What invariant makes it sound, and where is that written down? A// SAFETY:line would save the next reader the audit.SAFETY comment added above
bytesinsrc/rust/crates/ck_rt/src/assert.rs, and a debug assertion for the invariant, so a violation fails a test rather than a user.Second read on
src/rust/crates/ck_lower/src/codegen/assert.rs. Nothing to add.The running actor gets a real bump arena; ck_rt_alloc's host malloc is retired for the actor path. Landed early (ahead of R8) per owner directive -- R8 extends it to multi-actor + send; this is the substrate view. Honors arenas.md: one arena per actor, hard boundary, whole-arena reclaim on actor death (one drop, no per-object free). BumpArena = chained Box<[u8]> blocks (pointers stable across growth) + cursor + high-water, in a thread-local CURRENT_ARENA (floor runs one actor per carrier), so ck_rt_alloc's C-ABI is unchanged -- codegen (S2 concat) untouched. bare fn main still falls back to host alloc (documented, later slice). Observability: two new closed MetaEvent variants ArenaHighWater{actor, bytes} + ArenaReclaimed{actor} (wire tags 8/9, host reader decodes). emit at despawn: high-water read while arena live, then reclaim (single drop), then ArenaReclaimed. No faked values. Deferred (cited): compiler-computed arena SIZING from bounded types (full M1), arena-relative handles + replay (M7/R12), state/stack split + call- slots (M2), OOM upcall (M6/R11), capability move rules + send (M4/R8). Gate M1's own DoD: arena_reclaim_run runs greeter, asserts ArenaHighWater > 0 (bytes=9) and ArenaReclaimed fires -- no leak across spawn/death. Gates: fmt clean; clippy 0/0; cargo test --workspace 905 passed; greeter -> Hi, world, helloWorld -> hello, world, both clean lifecycle.New `ckc test <dir>`: discovers every top-level `test fn` in app modules, lowers each body (reusing S1 user-fn machinery), emits one container binary whose main runs `ck_rt_run_test` per test and returns the failed count as exit code. Floor (new ck_rt/src/assert.rs, C-ABI unsafe boundary): ck_rt_run_test emits TestStarted, installs the actor arena, runs the body, emits TestPassed / TestFailed{failed}, reclaims. ck_rt_assert_check(passed, pred, hint, site) emits AssertEvaluated{kind: Soft, passed, ...} with the REAL evaluated boolean, records a FailedAssert in a thread-local, and RETURNS -- a failed assert never abandons the body (assert = non-fatal meta observation, the load-bearing lock). No new MetaEvent variant needed (the assert/test variants already existed in the closed sum + wire codec). Codegen (new codegen/assert.rs): Assert::check/equal lower; equal desugars to check(a == b, hint); Int == -> icmp eq; Assert::* recognized by its ambient built-in OpId and intercepted before provider dispatch. Harness (ck_driver/src/harness.rs): reconciles the meta stream into a per-test pass/fail report; ckc test exits non-zero on any failure. Gate (both directions): tests/corpus/soft_asserts + Docker-gated soft_assert_run -- Assert::equal(1,1) passes, Assert::equal(1,2) FAILS but the test runs to completion (TestFailed proves non-fatal). soft_asserts is front-end-clean (no trap.md) and in the runtime-coverage allow-list. Out (cited): Assert::guard (fatal), equal operand-diff payload, records/ variants/collections/String==/mocked-effects, per-test user-fn dedup (latent, documented). Files split to stay under LoC caps (codegen.rs, compile.rs) -- caps not raised. Gates: fmt clean; clippy 0/0; cargo test --workspace 911 passed; greeter/helloWorld unchanged; cka-clean new files.