Skip to content

perf(state): measure contextual verification phases - #782

Open
evan-forbes wants to merge 44 commits into
mainfrom
perf/contextual-phase-metrics
Open

perf(state): measure contextual verification phases#782
evan-forbes wants to merge 44 commits into
mainfrom
perf/contextual-phase-metrics

Conversation

@evan-forbes

@evan-forbes evan-forbes commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • measure the full contextual interval, initial checks, parent-chain work, new
    chain construction, and state-writer snapshot cloning;
  • separate the cumulative UTXO snapshot from transparent spend checks;
  • measure shielded anchors, contextual block construction, and the parallel
    state update;
  • separate the parallel chain clone from Chain::push;
  • measure header-transition preparation and commit on success and error paths;
  • emit matching mined-only series for every phase on the mined-block path.

Motivation

The preserved memo-enabled field run reduced the median transaction phase to
1.795 ms. Its median state commit remained 34.338 ms. PR #781 separates writer
queue delay from writer execution. This PR splits writer execution so the fleet
can identify the next material optimization without inferring phase costs from
aggregate quantiles.

Safety

The change adds elapsed-time capture and histograms only. It does not move a
check, change state ownership, or alter chain selection.

The outer parallel_update duration includes task scheduling and completion.
The parallel_task.* durations overlap because block commitment, Sprout anchor
validation, and chain update run concurrently. Only parallel_update measures
their critical-path wall time.

Benchmark scope

This PR adds observability. It does not claim a runtime speedup. A synthetic
microbenchmark would not show whether these histograms partition the production
contextual interval. The state tests exercise every instrumented success and
error path. The next fleet run must compare each mined-only phase count with
the outer contextual count, then rank phase means from matching campaign
deltas. Concurrent parallel_task.* means must not be added together.

Verification

  • cargo test -p zakura-consensus -p zakura-state --lib --locked
    • 210 consensus tests passed
    • 520 state tests passed and 3 tests remained ignored
  • cargo clippy -p zakura-state -p zakura-consensus --all-targets -- -D warnings
  • cargo check -p zakura-state -p zakura-consensus --all-targets --locked
  • cargo fmt --all -- --check
  • git diff --check
  • ./scripts/changelog.py check

This PR adds docs/changelog/unreleased/782.md with an internal-only marker.

Stack

@evan-forbes
evan-forbes force-pushed the perf/contextual-profile-milestone branch from baf893d to 0a60c5b Compare August 23, 2026 04:43
@evan-forbes
evan-forbes force-pushed the perf/contextual-phase-metrics branch from da49f60 to a66e320 Compare August 23, 2026 04:43
@evan-forbes
evan-forbes force-pushed the perf/contextual-phase-metrics branch from a66e320 to ce7eaf6 Compare August 23, 2026 05:53
@evan-forbes
evan-forbes force-pushed the perf/contextual-profile-milestone branch from f9a5cea to e0904a8 Compare August 23, 2026 08:11
@evan-forbes
evan-forbes force-pushed the perf/contextual-phase-metrics branch from ce7eaf6 to 91c7ce2 Compare August 23, 2026 08:11
@evan-forbes
evan-forbes force-pushed the perf/contextual-profile-milestone branch from e0904a8 to cb86ca8 Compare August 23, 2026 16:46
@evan-forbes
evan-forbes force-pushed the perf/contextual-phase-metrics branch from 91c7ce2 to 8a61e72 Compare August 23, 2026 16:46
@evan-forbes
evan-forbes marked this pull request as ready for review August 23, 2026 17:25
@evan-forbes
evan-forbes force-pushed the perf/contextual-profile-milestone branch from cb86ca8 to da87178 Compare August 23, 2026 17:45
@evan-forbes
evan-forbes force-pushed the perf/contextual-phase-metrics branch from 8a61e72 to 09a498a Compare August 23, 2026 17:45
Main added the checked-in `rpc_openrpc.rs` artifact and its staleness
check in #764. This branch edits the `getblocktemplate` and `submitblock`
doc comments that the artifact derives from, so `cargo xtask
check-rpc-artifacts` fails after rebasing onto main. Regenerate the
artifact so it matches the doc comments.
@evan-forbes
evan-forbes force-pushed the perf/contextual-phase-metrics branch from 09a498a to 7de3197 Compare August 23, 2026 18:42
@evan-forbes
evan-forbes force-pushed the perf/contextual-phase-metrics branch from 7de3197 to d555395 Compare August 23, 2026 18:52
@evan-forbes
evan-forbes force-pushed the perf/contextual-profile-milestone branch from 267890e to b8b1f4c Compare August 23, 2026 18:52
@evan-forbes
evan-forbes force-pushed the perf/contextual-profile-milestone branch from b8b1f4c to bdf35bb Compare August 23, 2026 19:38
@evan-forbes
evan-forbes force-pushed the perf/contextual-phase-metrics branch from d555395 to abc601b Compare August 23, 2026 19:38
evan-forbes and others added 23 commits August 24, 2026 17:54
…ntory' into perf/contextual-profile-milestone
…ntory' into perf/contextual-profile-milestone
…ntory' into perf/contextual-profile-milestone
# Conflicts:
#	crates/zakura-state/src/service.rs
#	crates/zakura-state/src/service/tests.rs
@evan-forbes
evan-forbes changed the base branch from perf/contextual-profile-milestone to main September 4, 2026 17:18
@evan-forbes
evan-forbes force-pushed the perf/contextual-phase-metrics branch from fc47ef7 to d71d7ea Compare September 4, 2026 18:03
@evan-forbes
evan-forbes changed the base branch from main to perf/contextual-profile-milestone September 4, 2026 18:04
"state.contextual.mined.transparent_spend.duration_seconds",
transparent_spend_start.elapsed(),
);
let spent_utxos = spent_utxos?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The copied unspent outputs now stay in memory for the rest of validation, so we use more memory than before. We could free that copy as soon as the spending checks finish, like the old code did.

Base automatically changed from perf/contextual-profile-milestone to feat/optimistic-mined-block-inventory September 7, 2026 18:41
Base automatically changed from feat/optimistic-mined-block-inventory to main September 8, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants