Expand description
Bench-only debug counters for Arc-clone / COW-copy events (issue #821
Workstream B seed, docs/runtime-bench.md).
The value model’s performance claims (docs/value-model-spec.md §5/§6)
rest on two mechanisms: sharing a collection is an O(1) Arc::clone, and
mutating a shared collection pays exactly one O(n) copy (via
Arc::make_mut inside Value::array_make_mut/map_make_mut/
record_make_mut) before becoming unique again. Wall-clock benchmarks
can only infer whether these mechanisms actually fired; these counters
measure it directly.
This entire module exists only when the bench-counters feature is
enabled — it is not part of the default feature set, so cargo build -p brink-runtime (no extra flags) never compiles it in: there is no
bench_counters module, no atomics, no call-site branches — a
compile-time cut, not a runtime toggle. The call sites in
collection_ops.rs/record_ops.rs/vm.rs that report into this module
do so through tiny note_* wrapper functions that are themselves
#[cfg]-gated to a no-op empty body when the feature is off, so the
wrapper call inlines away to nothing (verified by the gate: cargo build -p brink-runtime/cargo clippy with no bench-counters feature builds
clean with the module physically absent).
Structs§
- Bench
Counters - A point-in-time read of the counters. Cheap
Copyvalue so benches can snapshot before/after a measured section and diff.
Functions§
- record_
arc_ clone - Record one Arc-clone (cheap share) event.
- record_
cow_ copy - Record one COW copy event.
- reset
- Zero both counters. Benches call this before the measured section so setup work (compiling, linking, building initial fixtures) doesn’t pollute the count.
- snapshot
- Read the current counter values without resetting them.