perf(state): bypass write buffer for read-only state requests - #784
Merged
Conversation
evan-forbes
force-pushed
the
perf/contextual-phase-metrics
branch
from
August 23, 2026 05:53
a66e320 to
ce7eaf6
Compare
evan-forbes
force-pushed
the
perf/state-read-routing
branch
from
August 23, 2026 05:53
dfc104e to
34a2683
Compare
evan-forbes
force-pushed
the
perf/contextual-phase-metrics
branch
from
August 23, 2026 08:11
ce7eaf6 to
91c7ce2
Compare
evan-forbes
force-pushed
the
perf/state-read-routing
branch
from
August 23, 2026 08:11
34a2683 to
9331437
Compare
evan-forbes
force-pushed
the
perf/contextual-phase-metrics
branch
from
August 23, 2026 16:46
91c7ce2 to
8a61e72
Compare
evan-forbes
force-pushed
the
perf/state-read-routing
branch
from
August 23, 2026 16:46
9331437 to
c98987d
Compare
evan-forbes
marked this pull request as ready for review
August 23, 2026 17:28
evan-forbes
force-pushed
the
perf/state-read-routing
branch
from
August 23, 2026 17:45
c98987d to
c0b4b50
Compare
evan-forbes
force-pushed
the
perf/contextual-phase-metrics
branch
from
August 23, 2026 17:45
8a61e72 to
09a498a
Compare
evan-forbes
force-pushed
the
perf/state-read-routing
branch
from
August 23, 2026 18:42
c0b4b50 to
eacd326
Compare
evan-forbes
force-pushed
the
perf/contextual-phase-metrics
branch
2 times, most recently
from
August 23, 2026 18:52
7de3197 to
d555395
Compare
evan-forbes
force-pushed
the
perf/state-read-routing
branch
from
August 23, 2026 18:52
eacd326 to
c4c0002
Compare
evan-forbes
force-pushed
the
perf/contextual-phase-metrics
branch
from
August 23, 2026 19:38
d555395 to
abc601b
Compare
evan-forbes
force-pushed
the
perf/state-read-routing
branch
from
August 23, 2026 19:38
c4c0002 to
8893ea8
Compare
evan-forbes
changed the base branch from
perf/contextual-phase-metrics
to
main
August 23, 2026 19:38
evan-forbes
force-pushed
the
perf/state-read-routing
branch
from
August 23, 2026 19:41
8893ea8 to
767fa08
Compare
ValarDragon
approved these changes
Aug 27, 2026
ValarDragon
left a comment
Contributor
There was a problem hiding this comment.
Awesome! Nice job on this
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.
Motivation
The transaction verifier and mempool send read-only requests through the
serialized read-write state buffer. The read-write service immediately forwards
those requests to the existing read service.
The preserved 80-node campaign observed 12,589,364 requests through the outer
buffer. These changes can bypass that buffer for at least 7,868,996 requests.
The upper bound is 12,142,479 requests, or 96.45% of observed traffic.
The request count measures removed buffer work. It does not establish a latency
saving.
Solution
UTXO reads directly to
ReadStateService.AwaitUtxorequests and every write on the read-write service.ReadStateService.service.
guard.
Safety
The read-write state service already forwards these request variants to a clone
of the same read service. The change removes one outer buffer hop. It does not
change the query implementation, non-finalized snapshot source, request bounds,
or write ownership.
The routed requests stop incrementing the outer
service="state"requestseries. The existing
service="read_state"series continues to count them.Block
AwaitUtxoreadiness now falls inside the transaction-verifier timeout.Results
The release benchmark sends 100,000 sequential median-time-past reads per
sample. It wraps the production
TransactionStateRouterin a bound-one Towerbuffer for the baseline. The direct arm uses the same router and fixed response
without that buffer. Five invocations collected ten samples per arm.
This unloaded benchmark isolates dispatch. It does not include state query work
or CPU saturation. The preserved fleet counts show how often the node removes
the hop. They do not convert the unloaded result into an end-to-end latency
claim.
Validation
cargo bench -p zakura-consensus --bench state_read_routing --features internal-benchcargo test -p zakura-consensus --lib --locked: passedcargo test -p zakura --lib --locked: 405 passed; one baseline test failedcargo clippy -p zakura-chain -p zakura-consensus -p zakura-state -p zakura --all-targets -- -D warningscargo fmt --all -- --checkgit diff --checkThe baseline failure is
inbound_pruned_block_is_not_advertised_and_getdata_logs_error. The focusedtest also fails on untouched
main.Changelog
This PR adds
docs/changelog/unreleased/784.md.Stack
main.