Current-source Store and collection profiling, round two

This is an isolated diagnostic source closure from d8635bfe951e98561d0b25703155a030d6e7054d, the implementation used by the accepted 005041 ordinary benchmark. It copies only source inputs, not build caches. Production source and the earlier accepted/rejected profile checkpoints remain untouched.

The campaign measures 100,000-record RTree point and paged full scans, NodeStore insertion and removal, and stable Deque distributed reads. Independent ordinary benchmark case factories supply requests and expected outputs. Each recorded operation runs in three modes: the ordinary endpoint on the control artifact; the diagnostic endpoint on that same artifact with collector buffers prepared; and the diagnostic endpoint on the enabled artifact. Three snapshot-restored repetitions assess deterministic replay. An immutable root scope here still executes through an IC update endpoint, matching the ordinary API benchmark.

Full RTree scans and 32-entry NodeStore removals collect phase totals only. Bounded one-page RTree and one-entry NodeStore removal cases collect ordered backend events separately. The two paths answer different questions: the bounded trace is not the full scan's access trace. Both disabled and enabled artifacts retain and prewarm identical fixed collector buffers; disabling event capture does not remove their footprint. The event buffer remains bounded at 4,096 events. Overflow, unmatched spans or dropped events reject a recording.

A phase's inclusive cost contains its nested phases; its exclusive cost subtracts each immediate child exactly once. The operation subtree has a separate ledger. The sum of its exclusive phase costs must exactly equal the single Operation span's inclusive cost. Whole-body accounting likewise reconciles with EndpointBody. These are gross instrumented intervals: span bookkeeping, counter calls and tracing change code generation, runtime allocations, layout and memory access costs. The paired ordinary/control/profile costs expose perturbation, but do not justify subtracting a uniform profiler cost from individual phases.

The phase collector is copied from the corrected, independently reviewed current-profile-v2 implementation. In particular, finish copies fixed counter arrays out of global state and ends its borrow before allocating result vectors; instrumented allocator calls cannot reborrow a live State reference. Backend trace snapshots currently allocate while sharing the distinct trace collector, which is safe only because the allocator hooks touch phase State and the raw runtime arena, never the trace collector. New hooks receive an independent safety review before execution.

Backend events record logical offsets, actual retained arena or stable addresses, scratch addresses, lengths, caller phase, ordering and inclusive elapsed instructions. Retained lending encloses the decoder callback. A requested lend range is an upper bound on actual touched bytes. Stable and retained addresses are separate spaces; growth records capacity change and is not treated as a memory read. Observed backend chronology cannot reconstruct earlier SDK, stack, Candid or runtime heap touches, and therefore does not prove the IC's first-access eligibility on its own.

baseline-manifest.json identifies the committed source closure. tools/freeze.py hashes final compiled inputs; the measurement owner archives them together with compiler/final-Wasm hashes, execution receipts and PocketIC cleanup. tools/build.sh uses the repository's pinned compiler and existing bench/target, writing final artifacts only to its explicit research evidence directory. The measurement owner alone runs builds and PocketIC.