Native page tracing and allocation experiments
Status: the combined ten-item simplification batch is merged and selected, with a 19.22% Heavy16 instruction reduction and separately reported SDK tradeoffs. The public Wire replacement is also merged; its first matched Heavy16 run adds a 1.03% instruction reduction. See the batch report and the Wire report. The dynamic shared-page allocator and packed PageLog admission are now merged. The same-Wasm turn-budget comparison records 500M, 1.5B and no Reactor cutoff with ordinary IC time slicing. Following the heartbeat comparison, the selected benchmark default is timer-backed Reactor at 500M. Earlier candidates below are experiment history. Heavy16 exercises workflow state, scheduling, message batches, callbacks and Rechain commits with small/scalar reducer state. It does not qualify large business-map layouts.
First measured RRT baseline
The previously qualified ordinary 811d7084… Wasm completed the matched
16-canister workload on the local tracing server ee3ef3cd…. This first run
finished before the request to limit detailed tracing; its compressed raw traces
occupy about 2.8 MiB. Subsequent detailed captures use a bounded busy window.
There is no Wasm page-profiler instrumentation in these artifacts.
| Successful replicated executions | Instructions | Heap page instructions | Heap page share |
|---|---|---|---|
| Complete workload and publication tail | 528,371,423,672 | 131,531,120,000 | 24.89% |
Workflow self-turn (reactor_turn) |
384,946,133,265 | 35,708,720,000 | 9.28% |
Admission (start) |
90,751,614,886 | 70,089,200,000 | 77.23% |
Receive batch (reactor_receive) |
26,806,232,215 | 13,640,400,000 | 50.89% |
The workflow turn dominates total instructions, but most of its cost is outside heap page fees. Locality is especially relevant to admission and callbacks; it cannot explain the entire RRT/HRRT performance gap. The remaining instructions include ordinary Wasm and IC API work. This trace does not by itself attribute that remainder to Store, algorithms, codecs or ownership handling.
| Absolute heap region | Heap page instructions |
|---|---|
| Stack and statics, below 2 MiB | 13,988,880,000 |
| Runtime and protected bootstrap, 2 MiB to 1,026 MiB | 38,919,120,000 |
| Retained Store, at/above 1,026 MiB | 78,623,120,000 |
The boundaries come from the measured artifact's canonical memory receipt, not from an assumed current source layout. These are address regions, not semantic ownership: for example the runtime range includes the protected bootstrap. Stable accesses are not included in these heap counters.
Raw exports and the harness/build receipts are under
runs/rrt-baseline-on/; rrt-baseline-summary.json
contains the derived per-function, region and per-canister totals. Run
analyze_trace.py on one phase's per-canister .json.gz files,
not both primary and completed exports, which overlap. Its tests check fresh
per-execution charging, region boundaries, composite-query callback exclusion,
and invalid/duplicate inputs. The IC review documents the actual
calibration and the limits of the custom server's provenance.
First candidates
- Runtime: shared small-object segments with compact allocator metadata, retaining ordinary allocation lifetimes across calls and awaits. An initial design pinned metadata banks among payloads and prevented large contiguous allocations after a burst. The frozen candidate reserves metadata from free arena tails instead; the original large-allocation regression test now passes. Actual Wasm lifecycle and workload results still decide selection.
- Store: resource-owned private value slabs start small, then refill at 4 KiB. This avoids reserving 4 KiB for a tiny pool while preserving ownership and direct collection access. Populated pools may reserve one additional small slab, so a native memory saving alone is insufficient to select it.
The first two candidates have not earned promotion:
| Case | Primary + maintenance rounds | Finished replicated instructions | Cycles, including maintenance | Decision |
|---|---|---|---|---|
Exact feature-off 296f6309 control |
84 + 2 | 528,369,814,312 | 1,244,164,617,519 | Control |
Runtime segments f1244b00 |
80 + 2 | 524,073,531,143 | 1,235,660,312,382 | Reject as a general SDK change |
Smaller first retained slabs 67a893de |
86 + 2 | Not measured for the complete run | 1,239,924,054,929 | Hold: worse throughput and latency |
Runtime segments reduce the Heavy16 instruction total by 0.81%, but increase its heap-page component from 131,531,120,000 to 134,396,240,000 instructions (+2.18%). The gain is therefore outside page fees, with different scheduling and batching; it does not validate the simulated locality benefit. More decisively, the populated SDK screen regresses retained, stable and heap instruction totals by 33.10%, 45.61% and 27.65%. All behavior and state checks pass, and the unchanged upstream control is exact. Successful lifecycle tests cannot compensate for this performance regression.
The short native SDK traces isolate the
regression for three calls on the same populated snapshots. Retained preview
adds accessed and dirty regions 33, 34 and 255: 480,000 extra page instructions,
while other instructions fall by 644. Stable transfer and preview add regions
33, 34, 35 and 255: 640,000 extra page instructions, while other instructions
fall by 856 and 668. These are measured runtime addresses; retained state pages
are unchanged. General Arena is already bypassed on a small-slot hit, so
removing that backend's arithmetic alone cannot eliminate the observed cost.
Its duplicate backing extent/header and rounding are still candidates for
replacement together with dense payload placement and hot metadata.
The retained-slab candidate saves 35.75 MiB of logical Wasm allocation across 16 canisters, but increases primary rounds from 84 to 86 and p95 latency from 43.8 to 45 seconds. Its bounded trace does not establish a complete instruction saving. Both candidates preserve the same completed work and have zero reported traps and unfinished transport/workflow tails. Revised allocation placement must pass the cheap populated-app screen before another Heavy16 qualification.
Unified replacement history
The next runtime candidate replaces the backing allocator instead of adding a
small-object frontend to it. One compact external row describes an extent's
physical neighbors, free-list membership and small-slot state. Codec allocations,
small slabs and large allocations use this same engine; the old Arena, its
payload headers and the frontend's duplicate backing ownership are removed.
The first descriptor bank sits beside the codec area. Small classes start with compact segments, release empty overflow segments and reuse prefix descriptors before distant overflow descriptors. Native testing caught the opposite reuse order making a small post-burst allocation touch cold metadata; the candidate now explicitly prefers the prefix. Overflow metadata grows from free terminal extents, preserving contiguous payload reuse instead of pinning interior holes. Live allocations retain ordinary Rust lifetimes across calls and awaits.
The first unified checkpoint, 67ea4204, still fails the populated-app screen:
retained instructions rise 7.70% and stable instructions 9.17%. Three native
call traces isolate one additional accessed and dirty runtime region, page 33,
costing 160,000 instructions per call; persistent regions and overflow metadata
page 255 do not change. Single-call trace samples also show 18,466–20,350 extra
non-page instructions. The follow-up targets empty per-class starter capacity,
which otherwise remains reserved after a population burst. Correct metadata
placement alone did not establish compact payload placement.
That first checkpoint was not selected. The subsequent combined-ten batch is selected below after native, lifecycle and matched Heavy16 qualification. Native address tests establish the intended placement, not an IC instruction saving. The installed custom PocketIC binary changed after the first experiments; the replacement campaign pins the new binary by hash, calibrates it, and reruns the unchanged control Wasms on that same binary.
Complete native captures are explicit opt-in; default detailed tracing remains three rounds. The initial complete export occupies about 18 MB as serialized JSON, or 1.4 MiB compressed when retaining only the final phase. Totals describe finished replicated executions, excluding setup, queries and later management inspection. The custom tracer does not emit aborted DTS attempts. Recorded Heavy16 entries are below the configured instruction-slice limit, but this is not an independent proof that the scheduler performed no aborted work.
Keep behavior, upgrade and reclamation checks. Compare complete ordinary workload completion, rounds, latency, cycles and memory, plus clearly labeled instruction/page measurements. A fixed round window may contain different work after an optimization: retain its work counters and never extrapolate its page share to the full workload. Selected DTS executions can finish after tracing is stopped, so export the bounded execution-start cohort after ordinary completion.
Selected combined simplification batch
The ten-change batch reduces matched Heavy16 finished replicated instructions from 528.37B to 426.82B (−19.22%), primary completion from 84 to 69 rounds and p95 latency from 43.8 to 33.0 seconds. Work and closure checks match, with zero traps. Native and actual IC lifetime/upgrade checks pass. The user selected this Heavy16 gain despite ordinary populated SDK instruction regressions of +14.78% heap, +1.80% retained and +2.34% stable. Those are follow-up optimization targets, not hidden improvements. Public Wire and dynamic shared Wasm-page allocation are subsequent work and are not included in these results.
Viewer
The current experimental viewer uses http://127.0.0.1:8090/. Benchmarks can
connect to its caller-owned server with RRT_PIC_SERVER_URL; session shutdown
deletes only the created instance and leaves the server/viewer alive. Trace data
remains in that server's RAM until explicitly cleared or the server exits.
The URL is a local working-session convenience, not a deployment endpoint.