[zero] perf(zebra-consensus): overlap block-path UTXO lookups - #46
Open
aphelionz wants to merge 1 commit into
Open
[zero] perf(zebra-consensus): overlap block-path UTXO lookups#46aphelionz wants to merge 1 commit into
aphelionz wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves zebra-consensus block-path transaction verification performance by overlapping transparent UTXO state lookups (up to a fixed concurrency), avoiding the prior “one awaited round trip per input” behavior for high-input transactions.
Changes:
- Add a bounded concurrent UTXO lookup pipeline in
BlockTxVerifier::block_spent_utxosusingbuffer_unordered(64)while preserving input-index order for v5 sighash commitments. - Add a regression test that deadlocks on serial UTXO fetching to detect accidental re-serialization.
- Add a Criterion benchmark to measure block-path UTXO fetch performance under injected state-service latency.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| zebra/zebra-consensus/src/transaction.rs | Overlaps state AwaitUtxo requests with a fixed max concurrency and preserves spent-output ordering by input index. |
| zebra/zebra-consensus/src/transaction/tests.rs | Adds a concurrency regression test for block-path UTXO lookups (plus a new BoxError import). |
| zebra/zebra-consensus/Cargo.toml | Registers the new utxo_lookup benchmark target. |
| zebra/zebra-consensus/benches/utxo_lookup.rs | Adds a benchmark simulating ~1ms per-UTXO state latency to quantify overlap gains. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This was referenced Aug 25, 2026
aphelionz
added a commit
that referenced
this pull request
Aug 26, 2026
Path-gated informational job (not a required check): runs the script-cache and UTXO-lookup criterion benches on PRs and main pushes that touch the benched crates, and posts the timings to the step summary. Bench steps are guarded on their bench files existing, so this lands before #45/#46 and activates as they merge. rust-cache persists target/criterion, so criterion also reports a change estimate against the previous cached run. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
block_spent_utxos awaited one state round trip per transparent input, so a 1001-input consolidation paid the state latency 1001 times in series. Inputs served by known_utxos resolve inline; the rest run through buffer_unordered(64), and results carry their input index, so the spent-output order that v5 sighashes commit to is unaffected by completion order. The mempool path is unchanged. Batched lookups share timeout clocks, an accepted narrowing documented on MAX_CONCURRENT_UTXO_LOOKUPS. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
aphelionz
force-pushed
the
claude/overlap-utxo-lookups-2a26d1
branch
from
August 26, 2026 13:33
5c2dcc4 to
3833031
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The overlapping-UTXO-lookups half of #34, split out per its review; the caching half is #45. The two are independent and can merge in either order.
block_spent_utxosawaited one state round trip per transparent input; the lookups now run throughbuffer_unordered(64)(inputs served byknown_utxosresolve inline and never build a future). Results carry their input index, so the spent-output order that v5 sighashes commit to is unaffected by completion order. The mempool path is unchanged. One accepted narrowing, documented onMAX_CONCURRENT_UTXO_LOOKUPS: batched lookups start their 6-minute timeout clocks together, which only matters during out-of-order sync and recovers by the designed sync restart.The new test serves every
AwaitUtxobehind a batch barrier that releases only when 64 lookups are pending at once, so a regression to serial lookups deadlocks into the test's 10-second timeout instead of passing slowly (checked by hardcodingbuffer_unordered(1): the test fails at 10.1s).Benchmark (
cargo bench -p zebra-consensus --bench utxo_lookup): block verification of a 1001-input P2SH consolidation with ~1ms of injected latency perAwaitUtxo. Run the same bench on the base commit for the serial baseline:133/133
cargo nextest run -p zebra-consensus;fmtandclippy -D warningsclean.🤖 Generated with Claude Code