Ashroot structural overhead bench
This local PocketIC bench compares each Ashroot behavior with two independent,
safe direct implementations over Nyxus, Hylix and Minima. reference uses split
private owners; flat keeps the same collections in one private owner. The
report selects the direct layout with fewer finished replicated instructions
at each point; upgrade compilation/management debits stay separate, with their
observed totals shown alongside execution. That is a
best known reference among the measured layouts, not a proof of a globally
optimal implementation.
The cost model defines the required structural work. An insert into a primary tree with four ordinary indexes needs one primary mutation and four set mutations, plus the validation, key projections, constraints and ownership work required by its contract. A measured gap can include those costs and layout differences; it must not all be called generic dispatch overhead.
Running
Use the pinned compiler from tools/env.sh, an exclusive Cargo target, a fresh
artifact directory and a fresh result directory. The canonical builder writes
matrix.json with all three roles, three engines and both upgrade versions.
It records newstack and SDK source identities, the exact source closure,
prepared Wasm/Wire artifacts, Code-section bytes and deterministic local
gzip level-6 size.
Pass --debug-artifacts to retain the canonical optimized DWARF/body-map bundle
needed by the SDK symbolizer. Profile exact installed bytes; a separate build's
debug information is usable only when its installed-byte identity matches.
Build upgrade pairs with the same Cargo target and environment. Debug remap
origins are included in the compiler contract; composing V1/V2 from different
target directories can correctly fail catalog admission. The default builder
keeps both versions in one target. Separate invocations must preserve that context.
source tools/env.sh
python3 benches/ashroot-overhead/build.py \
--target-dir /tmp/ashroot-overhead-target \
--output benches/ashroot-overhead/tmp/build-001
python3 benches/ashroot-overhead/coverage.py
node benches/ashroot-overhead/oracle.mjs
node benches/ashroot-overhead/run.mjs \
--artifacts=benches/ashroot-overhead/tmp/build-001/matrix.json \
--output=tests/tmp/ashroot-overhead-run-001 \
--pocket-ic=/absolute/path/to/pinned/pocket-ic \
--variant=baseline
python3 benches/ashroot-overhead/analyze.py \
tests/tmp/ashroot-overhead-run-001/result.json \
--output tests/tmp/ashroot-overhead-report-001
The cached CARGO_HOME must be selected as required by the existing SDK build
workflow. wasm-objdump from WABT is required. The builder accepts --engines,
--roles and --versions comma lists for diagnostics. The runner accepts
--engines=nyxus, --roles=ashroot,reference,flat and --select=REGEX to
diagnose a subset. Subset runs are INCOMPLETE; combine disjoint result files
in the analyzer to complete a variant. Repeated samples require separate
variant labels. Missing or failed supported cells make reporting fail. Static
coverage.py success only means SPEC_VALID, never measured performance.
Use --profile=true --select=REGEX for a bounded ordinary-call instruction
profile. Select a separate variant/output and compare the same artifact, inputs
and full state with profiling off. Upgrade profiling is rejected because its
multiple executions do not fit that one-execution capture. Profile ledgers,
blocks, origin dictionaries and physical stacks have separate completeness
limits; inspect them before attributing cost. pocket-ic explain --compact
describes the pinned binary's charge catalog, while the captured execution
provides actual hotspots. The run records artifact source identities separately
from the host repository used for its helper scripts.
When only Ashroot changes, reuse-controls.py --variant final --output FRESH --against-artifacts NEW_MATRIX BASELINE_RUN... composes the existing reference/flat samples into the new profile
with their original immutable artifact and trace receipts. It records source-run
hashes and never edits old evidence or calls reused samples fresh measurements.
Repeat --against-artifacts for disjoint engine/version matrices. Every reused
engine/version must have a candidate Ashroot image, and every candidate pair must
be checked. Reuse requires identical captured SDK inputs, benchmark Rust sources,
common model/protocol/runner inputs, shared Ashroot key/record/error/planner
definitions, SDK identity and compiler/build settings. Receipts include both
matrix and manifest hashes and the shared-source digest. Controller-only Ashroot
implementation changes are allowed; this check does not claim that rebuilding
the direct images against changed Ashroot would produce identical machine code.
Analyze those partial files together with the new Ashroot runs; normal raw-trace,
logical-work and complete-coverage checks still apply.
Each case gets a fresh canister with the same rows and insertion order in every role. Setup and complete before/after state checks sit outside the measured update. The runner owns its local server and deletes its canisters after each case. It does not deploy externally. Failures and completed sample receipts remain in the fresh output directory.
For native conformance and algorithm counters before the IC run:
node benches/ashroot-overhead/native-corpus.mjs \
--output=benches/ashroot-overhead/tmp/native-corpus-001.ndjson
python3 benches/ashroot-overhead/counts.py \
--corpus benches/ashroot-overhead/tmp/native-corpus-001.ndjson \
--target-dir /tmp/ashroot-native-target \
--output benches/ashroot-overhead/tmp/native-counts-001
The native corpus checks ordinary outcomes and complete primary/index snapshots; the IC corpus checks replica rollback and upgrades. Native counters observe ID comparisons (including index PK ties), key/value codecs, validations, projections, factories and body bytes. They do not instrument every allocator/provider action; an uninstrumented owner-retirement counter is N/A. Semantic tests check ownership and release IC traces supply page costs. Native instrumentation uses opt0 and never enters the optimized release Wasm. It does not measure IC instructions.
Coverage and interpretation
cases.json is the maintained finite corpus. coverage.py checks all 35
public Database, TableRead and IndexView methods against actual source,
and checks all fixture opcodes. Aliases have distinct Rust calls and cases.
The ledger also tracks iterator limits, bounds, filters, early stop, hints,
callback errors, batch prefixes, duplicate/missing/unique/FK refusals,
relationships, atomic trap rollback, helpers, owning values and migrations.
Compile-only generation/typing helpers are listed separately: they are not
assigned an invented runtime cost. A finite corpus is not exhaustive proof.
The independent JavaScript oracle computes each outcome and every row and
ordered index entry, including unaffected collections. It does not merely
compare the implementations with each other. inspect calls the public
primary/index pagination paths in one query. If its bounded snapshot truncates,
the runner falls back to full cursor pagination. Owning bodies, omitted from
row snapshots, are verified with unmeasured full-digest updates. Those updates
and all oracle queries are outside the measured trace window.
Prepared components 100–108 use separate collections in every compiled image
role, including the image containing Ashroot. Their category remains
component; invoking one is not invoking an Ashroot integrity API. They measure primary-only, individual
set, composed five-write, validation/projection, temporary unique map/set,
sorted build and Minima grouped-read work. Their oracle checks their exact
partial state, not fictitious full-table coherence. Populated component
inserts match the API populations; empty-tree cases stay separate. Do not sum
isolated component instruction samples to predict a composed call.
The report compares a zero-index API insert with prepared primary100 and a four-index API insert with composed102 inside the same compiled image, engine and population. It checks both before/after rows, ordered index entries and candidate match exactly. Components report entry changes while API results report row insertions, so gaps also include that result bookkeeping. These composition gaps omit some integrity work and remain separate from the primary API-versus-complete-reference comparison. There is no prepared primary-plus-one-Set control, so the report marks that composition unavailable rather than summing100+101. Differences between component samples in different image roles describe compiled-image effects, not Ashroot dispatch.
Every measured point includes a logical cost contract linked to the research model. Successful writes count primary row installations and exact ordered entry additions/removals, including replacement with identical values and per-step batch prefixes whose final changes might cancel. Counts describe logical requirements; bulk builders/clearers need not perform one physical tree call per row. Read cases record logical metadata/point decisions or observed candidates. Trap work, failing guards, decoding, allocation and ownership/provider transport retain conditional explanations rather than an invented universal operation count. Final state alone cannot price discarded work or a migration that safely reuses an owner.
The original corpus at source 4c49aaf1cc5514f4b70795616f1573dd93f0c92e
has SHA-256
52f8117508c2a4c2c98e9cd7d2cff99e6f48b11b3e25b31082927aa661baced5.
The current corpus records that identity under previous_corpus; its only
case-selection change enables prepared components in every image role. Its
SHA-256 is
0cc2fc174be1c0650756bd61a393f9bc59573b59d697e9fe863f316aacc8d267.
It has 231 cases, 2388 supported matrix cells and 33 explicit N/A cells. Fresh native
model expansion and fresh runs are required; old result identities stay intact.
Sorted builders use available safe public APIs: Nyxus uses an end cursor; Minima stages rows/slot IDs, allocates slots in bulk and builds its sorted directory; Hylix inserts because its public balanced builder requires an owning source map. That Hylix component is an available-public-API control, not a theoretical optimum. Minima grouped reads include address resolution, sorting and restoring input order. They can prefetch beyond the accepted output limit and are not claimed to replace lazy lookup semantics.
Upgrade cases use one synchronous KEEP upgrade, including mapper failure,
invalid final FK and a late trap. There is no multi-message migration. Mode
20 changes index definitions, 21 recodes fields, 22 consumes values on
Nyxus/Hylix (Minima uses recoding), 23 drops a table, 24 validates foreign keys,
25 adds an empty table, and 26 seeds a new table. The direct reference can
reuse a normal owner prefix where that preserves the final contract; Ashroot
can explicitly rebuild indexes. Reports must retain that algorithm distinction.
Measurements and accounting review
Three intervals are kept distinct. apiInstructions is a counter interval
inside the memory scope around API dispatch and result observation.
frameInstructions also includes root publication. Whole-call instructions
come from the finished replicated execution trace, including Wire transport,
reply, cleanup and page charges. Common planner input preparation occurs
before the API counter and remains inside the frame/full call. Performance
counters are interval observations, not substitutes for the finished trace.
Whole-call instructions already include includedPageInstructions; never
add the page field again.
That raw page_access_instructions field describes heap access/write
charges. instructionsExcludingHeapPages removes only that finished trace's
heap debit; stable-page fees and other execution/system charges remain. It is
not a CPU count. Exact stable-page fees are unavailable in the unprofiled trace;
the complete instruction-profile ledger exposes them separately. Stable coverage
can include direct-read touches that avoid native fees, so multiplying its ranges
by a region price would invent a cost. Whole-call page costs cannot be subtracted
from the shorter API/frame interval counters. Earlier frozen reports retain their
original field names and bytes.
Upgrade management charges such as compilation are
recorded separately as non-Wasm instruction debits and included once in
totalExecutionInstructions. For a complete single prepayment/refund pair,
the analyzer reconciles upgrade Wasm plus management instructions with the
actual charged instruction budget. Cold and warm compilation can differ;
retain the observed charge rather than replacing it with a source estimate.
Cycle debit is the balance difference across the measured call, not an
absolute balance that includes installation/setup. Raw runtime ledgers retain
execution, storage, byte and other charges. The report also keeps accessed and
dirty pages, completed logical work, actual call/execution counts, discarded
attempts, before/after canister resources and exact request/response bytes.
accessedPages/dirtyPages describe heap ranges;
stableAccessedPages/stableDirtyPages describe the separate stable address
space. All four count the trace's 64 KiB regions, as specified by
wasm_page_size=65536, rather than the IC's internal 4 KiB OS-page counters.
Their scalar totals sum coverage per execution. pageCoverage also retains
range unions per module hash and memory class; repeated executions and
heap/stable addresses are never silently combined into one union.
Trapped calls retain their charged, discarded execution. Memory reports are
capacity/accounting values, not live bytes, peak memory or host RSS. Local host
wall time is diagnostic, not a mainnet latency claim. Local gzip/Code sizes
are distinct from installed-module accounting returned by PocketIC.
The runner uses the owned PocketIC helper from benches/minima-graph, pinned
to binary SHA-256
6a9a75ad9b4551d2b0f4a0d954ffb8bd5bbd0ebc44ac00290679b06ad0b2f8e6
(PocketIC 16.1.0). It checks full trace availability, no truncation, exact
binary identity and no oracle/query work in the update window. Reports
recompute totals from raw gzip traces and verify trace, state, manifest and
artifact hashes. Source and host-input freshness are checked before and after
the run. Source changes require fresh artifacts, not reinterpretation of old
absolute-path receipts.
The IC source review used the separate read-only checkout /srv/shared/ic
at 49a94778d9aff90139cadc4f9c14b98b2aae42a4, which was dirty. Its status
text hash was
253b561633be94691a8692451a9f2016df69d24fdf913aee86f905acc9163ad1.
This source is research evidence; it is not asserted to be the source of the
measured binary. The reviewed paths and content hashes are:
| IC source path | SHA-256 |
|---|---|
rs/embedders/src/wasmtime_embedder/system_api.rs |
8cfc7686c1aee18c052fc8eff10ed34a08644fd7ce2a243e2c43aed0f0cbe698 |
rs/embedders/src/wasmtime_embedder.rs |
c7f36948a821a1af229314b85ca37416c5742221fc9b8f5ecb73e33b242b1903 |
rs/embedders/src/wasm_executor.rs |
5aa832f7bbd668f57a3fee702f5a22497818055eb6c58b0ec726b9e2572b803f |
rs/interfaces/src/execution_environment.rs |
9953cf31a9719ad9c527c70f87a185a918cad8adca95b655fbfecba236538514 |
rs/execution_environment/src/execution/install_code.rs |
b8ee4cc06cf84ef1cfbe63e33f897e0060541a78f2d000bb1c941d6cd9e97c13 |
rs/execution_environment/src/execution/upgrade.rs |
cd2c70caeb97d391c9b11f08b94dd8269ec33de5a260959656364922752b1fb3 |
rs/cycles_account_manager/src/cycles_account_manager.rs |
f5ff8a27fb89a5089ea057e1347b747fa0af6172fb987b2ee0418b8298e549a6 |
rs/pocket_ic_server/profiling/server/instruction_charge_rules.rs |
ac7595f075611869a89a1108d5660898fbaffa1d94524e8bbff3cfed1d5225fe |
The review distinguishes the message counter from accumulated round work, checks separate compilation-budget charging, storage charges by duration and page-accounting inclusion. Actual server runtime configuration and complete binary traces remain authoritative for measured limits and costs.
analyze.py produces maintained JSON, CSV and Markdown with per-case source
and baseline identities, observed direct alternatives, coverage status and
unrun cells. JSON retains before/after capacity and accounting values for every
point; CSV exposes total accounted, heap, stable and installed-binary bytes.
These are IC status values, not live or peak allocations. Native counted-I/O output may be attached with repeated
--native-counts=FILE; that instrumentation stays outside Release Wasm.
Attachments are checked against their successful opt0 receipt, corpus hash,
engine/role identities and counter widths. Those receipts record start source
status; they do not independently prove compiler/binary identity or source
freshness throughout a native build. The frozen source workflow and canonical
IC build receipts remain separate evidence.