Ordinary checked-block read code generation

Status: accepted in the qualified 014045 combination after 88 focused native tests and the standalone screen. See the combined qualification and final comparison. This directory preserves the isolated experiment against d8635bfe951e98561d0b25703155a030d6e7054d / 005041.

The current stable fused-read path preserves the stable first-read copy shortcut. Retained bounded reads already take the ordinary checked-block path, but the last round left larger RTree paged scans slower on both placements. This experiment changes only two compiler attributes: mark live_arena and decode_block as #[inline(always)]. It does not change any executable Rust statement, public API, persisted layout, backing call, or cache policy.

Evidence and hypothesis

The final baseline RTree retained Wasm is 1,010,878 bytes, SHA-256 cc1143c34ce6534f6994ec41ac6e002fe6d5f626989412b4b972db0f8330c656. Its raw_block calls both helpers out of line; the fused-read callback also calls decode_block out of line. raw_block has a 96-byte stack frame, live_arena 32 bytes, and decode_block 64 bytes. Extracts and original wasm2wat --enable-memory64 line locations are recorded beside this note. These are static code-generation observations, not measured instruction shares.

The old pre-fusion implementation kept live admission and header decoding in one function. Inlining the two shared helpers may restore optimization across that boundary while keeping one source of truth for the fused and ordinary paths. It may also enlarge Wasm or perturb other generated code; only matched PocketIC results can establish a win. RTree nodes have equal minimum and maximum payload bounds, so read-ahead beyond the actual payload is not an explanation for their prior scan regression.

Semantic equivalence

The patch contains exactly two attribute additions. Arena decoding, independent live-start authority, block alignment/order, header flags/length/incarnation, list placement, resource identity/ownership, and callback payload bounds are unchanged and execute in the same source order. No authority or admission cache is added or extended. Scratch ownership and nested callback behavior are unchanged. Stable fusion still executes its one header-plus-payload backing read. Retained reads still use their exact checked payload window. Third-party collections continue using the same public interface as built-in collections.

Qualification plan

The measurement owner alone applies the patch and builds. Focused native checks:

source ver1/tools/env.sh
cargo test --manifest-path ver1/Cargo.toml -p cdk-rsx-store --lib --test bounded_preflight --test storage_access --test storage_invariants --test private_pool --test read_window

Inspect the newly built RTree Wasm to confirm the helper calls actually disappear and record artifact size/hash. The first screen covers RTree and NodeStore at 10,000/100,000 plus Map/Deque at 100,000 (470 cases, one candidate trial against 005041's three-trial medians), as selected by the coordinator. This is an exploratory screen, not repeated qualification. Preserve stable sparse lookup controls, ordinary scans, insertion/removal, and byte/capacity snapshots. No performance acceptance is implied by the source-equivalence proof.

Independent source/lifetime review passed the exact patch hash on 2026-10-17; this establishes unchanged source semantics, not runtime performance.

Candidate code generation

The newly built retained RTree artifact is 1,010,690 bytes, 188 bytes smaller than the baseline; its SHA-256 is 5d710ee7929e2635cb0de45c2684c78d354545d98aa3dcfdff958b93e4fac888. The stable artifact is 1,010,714 bytes, SHA-256 5fe84f8781df41466c2edf180077239f65fcd43dfe940ec5c6f474e53728eda6. Neither artifact has a remaining definition or call for live_arena or decode_block. raw_block now contains the inlined logic. These observations confirm the intended compiler transformation; they do not prove an instruction benefit. The retained baseline and both candidate extracts are preserved with exact hashes. inspect.py reproduces the candidate metadata and extracts from a final Wasm.

Exploratory result

The matched screen report records 396 of 470 body and inner cases improved, 74 unchanged (Deque), and none regressed. All 228 population-memory comparison rows are unchanged. This API screen used one candidate trial, so repetition is not established. The separate 100,000-entry Map point matrix used three trials per case (312 samples) and also has no body or inner regressions. Position-median insert/hit/miss operations save 174 instructions retained and 304 stable.

RTree paged scans improve, but the gain is modest and does not by itself erase the previous round's material scan regression. The source/codegen boundary was one source of extra CPU work, not a complete explanation of the remaining performance gap. The coordinator shortlisted the exact patch for final merged qualification; no other inlining or decoding changes are included here.