Retained HashMap/Vec locality experiment, 2026-10-18

Candidate is isolated in experiment/retained-sequences-20261018, based on 5d7e001 (compressed native Map, fused Store admission, native revisionless writes, compiled platform/physical-layout contracts). No main merge.

The primary comparison is independent public calls over 100,000 entries, including 32 far-key calls and same-key controls. Each restored measurement or 32-call sequence receives one untimed no-op update, with its receipt separate from the measured body and whole-call cycle debit. All controls use the same protocol. No-op warmup does not retain IC first-access tracking between calls.

The candidate groups native HashMap hash/key/value spans into small tiles inside unchanged allocations: u64/u64 uses 16 slots per 384-byte tile, instead of placing its three columns 64 KiB apart. Segment sizes, directory counts, hash function, probing, ownership and public APIs remain the same. One selected-segment proof is reused for a probe's hash/key/value; HashMap and Vec iterators cache their current immutable segment. Vec replacement resolves its slot once.

This is a field-proximity hypothesis, not physical fault telemetry. Actual retained base and allocator offsets can make even a tile cross a 64 KiB tracked region. The benchmark includes same-algorithm ordinary byte-buffer controls and std collections; std HashMap uses a different deterministic integer hasher, so only the same-core control isolates storage from hash/algorithm differences.

Matched tiled-layout result

Baseline is the qualifier's frozen 5d7e001 nine-cohort suite. Candidate SDK commit is 2cef81c; frozen build source is c9e90a1. Each cohort has one 100,000-entry population, three snapshot-restored repetitions per isolated case, and three repetitions of each 32-call sequence. All isolated body counts repeat exactly across the three trials. The six std/exact/native HashMap/Vec controls use identical population order, keys, protocol, compiler and platform profile.

Native operation Baseline body Tiled body Body change Baseline whole-call cycles Tiled whole-call cycles
Hash far key, independent call mean 335,787 175,667 −47.7% 9,290,047 8,969,806
Hash insert one 657,220 337,192 −48.7% 9,919,440 9,279,384
Hash replace one 417,223 257,225 −38.3% 9,439,446 9,119,450
Hash miss 175,714 175,620 −0.1% 8,955,108 8,954,920
Hash 32 far keys in one call 3,990,685 2,066,839 −48.2% 17,092,156 13,244,464
Hash insert 128 10,174,717 8,659,700 −14.9% 31,022,952 27,992,918
Hash full scan 15,830,970 14,320,593 −9.5% 40,248,146 37,227,392
Vec full scan 7,115,142 5,615,307 −21.1% 22,823,664 19,823,994
Vec far key, independent call mean 175,491 175,491 0% 8,976,629 8,976,629

For the primary far-key independent-call case, tiled native HashMap is 1.086× the same-core heap body (161,736) and 1.090× the std HashMap body (161,196). Whole-call cycle debit is 1.003× both controls. This does not make the algorithms equivalent: the std control uses a different hash and remains faster for warmed and large-batch work. Native Hash warm-loop hot instructions fell from 6,277,559 to 4,834,032; std used 2,457,914. Vec random access did not improve in this patch. The large cold-hit reduction is consistent with closer fields, without being an instrumented count of faults or charged regions.

Population is a small negative: native Hash total body rose 743,410,495 → 745,717,449 (+0.31%), while its largest 1,024-entry growth step fell 35,547,112 → 35,323,749 (−0.63%). Exact-core heap Hash population rose 0.43%, with its maximum step down 1.00%. This patch does not improve every workload. The clear/delete/churn diagnostic found another material tradeoff: clear body rose 6,348,082 → 12,540,348 (+97.5%) and whole-call debit rose 60.6%. Capacity remains reserved in both layouts. Single deletion improved 48.5%; batches of 128 deletions or delete/reinsert pairs improved about 11%. Clearing the tiled hash columns spans more address regions and short fills; the measurement does not isolate dirty-region cost from loop overhead.

All committed memory counters are exactly unchanged in all six cohorts. Native Hash uses 24,444,928 main bytes and 4,223,488 allocated Store block bytes; native Vec uses 20,250,624 main bytes and 2,126,592 Store bytes. These totals include the benchmark actor and its empty sibling attachments. The std heap's committed linear-memory total is not its collection's allocated-byte footprint.

All operation tables and machine-readable means/ranges include every isolated case and every independent-call trace. The compressed baseline and candidate preserve raw samples, all warmup receipts, source fingerprints, artifact hashes and lifecycle qualification. Receipt verification confirms equal before/build/run source manifests, exactly one no-op update per restored case or sequence, and continuous measured cycle balances without intervening warmups. The only compiled input differences are Hash/Vec implementations, their host regression tests and a native-only format-rejection client; canister source and std controls are unchanged. All their measurements are identical.

Qualification passed 24 native integration tests, three borrow-escape compile failures and actual PocketIC16 KEEP conversion, rollback including growth, query discard, native ABI rejection, attachment/alias/retirement and subsequent writes. The separate actual Hash FORMAT1→2 check loaded 100,001 old-format entries including the latest committed key, rejected KEEP as SchemaMismatch, verified the old Wasm hash, all contents and Store counters, then successfully inserted and deleted under the old executable. The IC reviewer independently checked source geometry/provenance and the final matched source guards, warmup protocol and primary metrics.

Followup screening

Wasm inspection found primitive StableHash still returned its infallible u64 result through an out-of-line Result ABI and stack traffic. A separate one-line inline hint preserved the exact hash mapping and contracts but increased warm Hash hot instructions by 12.2%. It was rejected and reverted. The negative result records all measured cases and the resulting generic hash call that lost the original scalar specialization. The selected SDK remains 2cef81c; no inline hint is included. It remains provisional for parent review, with the full-clear regression explicitly accepted only if the workload warrants the much cheaper independent lookups and ordinary mutations.