Reusing one heap buffer for stable tree reads

This experiment tests aligned, read-once stable B+tree nodes on the pinned PocketIC build. It is a raw wasm64 prototype, not an implementation or performance promise for Hylix. Current engine guidance remains in engines; see the page-control study for the charging model and source review.

Ten independent million-key trees

Ten physically disjoint trees contain one million keys each. Each tree has 7,876 populated 4 KiB nodes and height 3: 78,760 nodes / 322,600,960 live node bytes in total. Each tree's reserved range starts on a 64 KiB boundary and spans 493 whole 64 KiB blocks, with no block shared between trees. Keys and values are fixed u64 fields. Construction commits before measurement. Node checksums, independent value/path oracles and committed-data samples verify real nonzero stable data.

One update looks up one key per tree, sequentially, without an upper-node cache. All 30 node fetches reuse the same 4 KiB scratch at heap byte 8,192. Stack, request, reply and scratch fit within one 64 KiB heap region. Heap capacity remains 64 KiB.

Measurement Complete call instructions Per lookup
Selected 10-lookup call 321,710 32,171
Same call minus its measured 160,000 heap-page charge 161,710 16,171
Mean of 32 fresh calls, ten varied-key lookups each 321,693.125 32,169.3125
Mean after removing each call's measured heap-page charge 161,693.125 16,169.3125

The adjusted values are amortized complete-call remainders, including protocol, search, telemetry reply and other work. They are not pure CPU costs or a universal no-op subtraction. Every measured call paid exactly 80k heap access plus 80k heap dirty instructions. The 32 complete-call totals ranged 321,683–321,710.

The selected profiled call reconciles exactly:

Charge Instructions
Heap access and dirty tracking 160,000
Stable read API/copy: 30 × (4,096 + 20) 123,480
Stable page access/dirty tracking 0
Other APIs, including diagnostic reply 29,224
Static Wasm instructions 9,006
Dynamic Wasm instructions / unexplained 0 /0

All 30 reads took the direct first-read helper. Profiling on/off produced the same 321,710 total. Artifact SHA256: 2254c318b4b9ea5439d998ed67bb69c2c692b2d627901b97f952ca5f84499a9d.

The limit of the result

The helper requires the complete requested logical 4 KiB range to be untouched in that physical execution. It copies real data; it does not make arbitrary repeated stable access free. A separate read of a node header followed by its body can lose eligibility. Native fallback charges its metered 64 KiB source region once per execution; it does not add 80k for every later read of that region.

Same no-cache prototype, one update Total instructions Stable page fees Helper/native reads
100 distant lookups, ten rounds over all trees 2,492,590 800,000 210 /90
100 repeated per-tree keys 4,092,590 2,400,000 30 /270

Each separate call starts fresh tracking. A small per-execution ancestor cache can help repeated paths, but must earn its copying, lookup and heap-page costs. These observations motivate aligned nodes, single fetches and reusable workspace, not blanket buffering or a promise that every stable workload beats heap.

Scope and audit

PocketIC 16.1.0 binary SHA256: 2e1dae35a83d8169533630c06fb0a7cb4086f71fa10fa60a5fd4137ea5f3672f. Setup is untraced; one earlier warm call precedes the separate-call series. The tree prototype has no Store ownership, mutations, migration or upgrade machinery. Its diagnostic replies expose paths and cost instructions.

The forest audit checked 9 raw traces, 40 completed physical executions, 4 bounded profiles and 760 independent lookup paths, with no dropped/truncated records. An initial host assertion compared string and numeric page coordinates after a valid capture; its failure is retained. The corrected host runner reused the unchanged guest artifact. See the adjacent evidence packet and detailed notes for sources, receipts and controls.

Reproduce the offline audit

Run python3 evidence/verify.py from this directory. The evidence packet contains exact sources, small Wasms, compact raw traces, ledgers, failed attempts and verification tools. The verifier checks 1,154 payload hashes and reruns the selected path/population/ledger audits without a compiler, PocketIC server, network or playground checkout.

Full tables: forest cases, 32 fresh calls, and single-tree controls.