Repository navigation
[0.31][Cost] Track abstraction-cost optimization and required design decisions #30
Description
Accepted decisions — 2026-09-21
D1–D6 are accepted in the tracked decision record. Implementation order: make rejection measurements observable; shorten wide immediates; coordinate exact-layout decoder sharing with private adapter frames; centralize scalar addressing and enable CFG-liveness slot reuse. Preserve the wire ABI and review each cost metric separately. No compiler changes or new optimization savings are claimed by this decision.
Full decision record — baseline: 8d6e200caa58d81429912df925a9322f691cb41d; research baseline remains 6d75a6e7. The choices below were the original open questions; this decision record now governs implementation. The issue stays open until its implementation acceptance passes.
Plan the next cost pass for 0.31, using branch 0.30 at 6d75a6e7e4ce55b940697428d895eda74a51ca86 as the starting baseline.
The three matched samples are already smaller and use fewer successful-execution cycles than their Rust references. The backend still has identifiable overhead: wide immediate expansion, repeated policy adapters, fixed entry buffers, argument copies, and conservative temporary storage. This work should reduce those costs while preserving the admitted behavior and the independently checked artifact boundary.
Baseline evidence: docs/CELLSCRIPT_COST_REGRESSION.md. The 0.30 samples are bounded evidence, not a claim of globally optimal code or universal superiority over hand-written Rust.
Work items
- [0.31][Backend] Shorten wide immediate materialization #31 — [0.31][Backend] Shorten wide immediate materialization
- [0.31][Backend] Reduce repeated policy adapters and choose a dispatch strategy #32 — [0.31][Backend] Reduce repeated policy adapters and choose a dispatch strategy
- [0.31][ABI] Right-size entry frames and evaluate policy argument copy removal #33 — [0.31][ABI] Right-size entry frames and evaluate policy argument copy removal
- [0.31][Backend] Reuse scalar stack slots and reduce temporary stack traffic #34 — [0.31][Backend] Reuse scalar stack slots and reduce temporary stack traffic
- [0.31][Cost] Extend cost budgets to rejection paths, composition, and call-chain stack use #35 — [0.31][Cost] Extend cost budgets to rejection paths, composition, and call-chain stack use
Decisions required for 0.31
The original proposals below are retained for context. The accepted D1–D6 decisions above and in the tracked record supersede them.
| Decision | Suggested starting point | Required evidence |
|---|---|---|
| Optimisation objective and budgets | Track ELF, successful/rejection cycles, witness bytes, and stack separately; require explicit byte/cycle tradeoffs | Agreed corpus and per-fixture budgets |
| Wide-constant algorithm | Deterministic sequence planning shared by sizing and emission, using existing instructions first | Full-width value checks, branch relaxation, compiled execution |
| Policy decoder sharing and dispatch | Evaluate exact-layout sharing; retain linear dispatch where its measured costs win | Dense/sparse tags, mixed layouts, per-action worst path |
| Entry buffer ownership | Right-size safe buffers first; evaluate borrowing only with explicit lifetime guarantees | Nested calls, aliasing, outgoing arguments, checker mutations |
| Scalar storage | Start with bounded liveness-based slot reuse | CFG/call coverage and meaningful frame/traffic measurements |
| ABI and artifact compatibility | Preserve wire ABI initially; version lowering/checker contracts when required | Producer/consumer inventory and compatibility tests |
Record each final decision in its owning issue or a linked tracked RFC, including alternatives, measurements, compatibility impact, and accepted limitations. Implementation PRs should identify who owns and reviews the affected backend/checker boundary.
Suggested order
- Agree metric definitions and budget policy; preserve the 0.30 baseline.
- Implement wide-immediate planning as the first bounded backend improvement.
- Decide the shared policy/entry adapter contract, then implement adapter sharing and frame/copy changes in coordinated steps.
- Add scalar-slot reuse after storage ownership is explicit.
- Rerun the full corpus and relevant gates on the final implementation commit, then set reviewed 0.31 budgets.
Measurement work continues throughout; the complete expanded corpus need not block the first local experiment.
Completion
- All six design decisions are recorded with their research evidence and explicit evidence limits.
- Every child issue is completed, or has an explicit deferral with reason and a new target; unchecked work is not described as shipped.
- The final report compares identical fixtures/build profiles against the baseline, includes regressions and rejection paths, and distinguishes instruction-byte savings from whole-ELF savings.
- Backend changes pass
./scripts/cellscript_gate.sh backend; merge-readiness is supported by./scripts/cellscript_gate.sh cion the actual final commit. - Checker independence, fail-closed behavior, and the four-file artifact bundle remain enforced.
- Document remaining cost limits and publish reviewed static budgets.
This milestone plans 0.31 work. It does not reopen the accepted 0.30 capability boundary, bump package/toolchain versions, or authorize release publication. Compressed instructions, wire-envelope redesign, and a full general-purpose register allocator are outside this initial scope; any addition needs a concrete measured case and a separate decision.
Activity
a19q3 commentedon Sep 21, 2026
Research notes, 2026-09-21. CellScript source checked at
6d75a6e7. These are proposed experiments and decisions, not implementation results.The research adds two prerequisites and one useful ordering constraint to this plan.
The immediate experiment reconstructed 231,462 inputs/checks in an independent host bit-vector model, with no mismatch and at most eight instructions observed. This is encouraging algorithm evidence, not a backend test or a full-domain bound. Its reproducible script and limitations are in the #31 research comment.
For policy/ABI work, keep three experiments separate: shared decoders, tag routing, and argument ownership. A policy with common checks currently does two tag scans; the witness path has two different copy operations. Each has different semantics and checker requirements. The supported 64-action limit also deserves measurements beyond the current eight-action corpus.
Proposed decision checkpoints
I would keep the initial witness wire ABI unchanged and judge candidates by separate byte, cycle and stack results. Prefer changes that improve one metric without worsening the others; when that is impossible, record the affected fixtures and why the tradeoff is acceptable. No universal percentage target is supported by the current evidence.
The child comments link the relevant LLVM, RISC-V and CKB sources and propose concrete experiments. No compiler code was changed during this research, and the design decisions remain open.
Research comments: #31 · #32 · #33 · #34 · #35.
a19q3 commentedon Sep 23, 2026
D1–D6 are implemented and pushed on
0.31at65df937f. The accepted decisions and implementation report describe the scope and compatibility boundary.The final clean commit's cost reports were compared against the retained pre-optimization baseline: 6,781 metric comparisons, no regressions, no changed fixture sources. The baseline retains its recorded dirty-source provenance; it is not relabeled as a clean historical commit.
Fresh acceptance recipes bind the regenerated ELF and derived Script hashes. Stale action, Lock, and missing-artifact mutations now fail preflight before the expensive node rebuild. The complete bounded replay passed all 43 actions, 17 Lock matrices and 26 stateful scenarios.
Validation is complete for this implementation checkpoint: dev, the full local CI gate, GitHub CI on the final clean commit, and the full local backend gate passed. The backend run freshly rebuilt the pinned CKB node and passed production-mode local acceptance for all 43 actions, 17 Lock matrices and 26 stateful scenarios. This is local-node acceptance, not a new public-network deployment. The initial retry encountered the local /tmp quota; relocating the compiler cache through the supported CELLSCRIPT_CELLC_TARGET_DIR setting resolved it without changing source or weakening a gate.
The final GitHub and local cost reports agree on all 88,204 compared numeric fields. Both bind clean
65df937f; the remote baseline comparison also passes all 6,781 checks.This is an implementation checkpoint, not a 0.31 release. Cargo versions remain 0.30.0. The named independent compiler/checker review, clean release replay and fresh downstream bundles remain release requirements; the 0.30 review waiver does not carry over. This issue and its children remain open for that acceptance work. No TAC was invoked.
a19q3 commentedon Sep 23, 2026
Remaining-work review, 2026-09-23, after the implementation checkpoint above.
The five optimization implementations and their final backend/CI gates are complete at
65df937f. The remaining path is acceptance and release preparation. The original “no compiler changes” / “implementation planned” text and unchecked implementation tasks should be reconciled with the implementation report and final implementation and validation record, retaining their historical dates.Recommended order:
mainas default and retains older development branches, while the accepted branch decision names0.31. The 0.31 CI workflow already covers pushes and the final successful run was a push run. Arrange the default-branch/rules change and any separately coordinated archived-branch cleanup; this review does not change or delete refs.The 0.30 independent-review waiver does not transfer. Close the cost tracker after child acceptance and its promised evidence are recorded; if release distribution continues separately, give it its own tracker and leave an explicit link rather than keeping optimization work ambiguously “unimplemented.”