Skip to content

perf(drive-abci): fetch the next core height's masternode and quorum lists ahead of time - #4556

Closed
PastaPastaPasta wants to merge 1 commit into
dashpay:v4.2-devfrom
PastaPastaPasta:perf/core-rpc-prefetch
Closed

perf(drive-abci): fetch the next core height's masternode and quorum lists ahead of time#4556
PastaPastaPasta wants to merge 1 commit into
dashpay:v4.2-devfrom
PastaPastaPasta:perf/core-rpc-prefetch

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Replaying history, about two thirds of mainnet blocks advance the core chain-locked height by one, and each of those blocks blocks on two Core RPCs in turn: protx listdiff for the masternode diff, then quorum listextended.

Measured replaying mainnet with per-block phase timing:

phase µs/block
core_info total 1,168
protx listdiff 501
quorum listextended 462
— applying the results 191

So ~0.96 ms of the ~7 ms a block costs is drive-abci sitting on a Core round trip, and Core has spare capacity while it waits.

What was done?

The heights are consecutive, so start the next pair as soon as the current one returns.

A CorePrefetcher holds one in-flight speculative fetch of each kind, keyed on the height (and base height, for the diff) it was started for. get_quorum_listextended and get_protx_diff_with_masternodes take the speculative answer when the key matches what they were asked for, and start the next guess either way. A key mismatch falls through to a real call, so a wrong guess costs nothing but a discarded response.

Two things keep it from misbehaving at the tip, where the next core block does not exist yet:

  • The speculative call runs on its own connection, so it never sits in front of a real one. jsonrpc's HTTP transport serialises requests behind a single socket mutex, so sharing the connection would defeat the point.
  • A failed guess backs the prefetcher off for the next 32 calls rather than asking Core for a block it does not have on every block. Core height advances roughly once per 2.5 minutes at the tip, so that is about one wasted request per 80 minutes.

A node that cannot open the second connection logs a warning and runs without prefetching.

How Has This Been Tested?

Interleaved A/B on a fixed window at mainnet height 190k, four runs alternating:

ms/block core_info
without 10.45, 9.65 1,525 µs
with 9.66, 9.48 1,164 µs

rpc_protx_diff 682 → 514 µs, rpc_quorum_list 670 → 470 µs. Note these runs shared one dashd with two other syncing nodes, so the residual wait is partly RPC contention from the harness rather than a limit of the approach.

Also exercised across a full mainnet replay, genesis to 424,981, with every committed app hash matching a reference sync.

cargo test -p drive-abci --lib — 2,770 passed.

Breaking Changes

None. One extra Core RPC connection per node, and speculative requests that Core answers from data it already has.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

…lists ahead of time

Replaying history, about two thirds of mainnet blocks advance the core chain-locked height by one, and each of those blocks waits on protx listdiff and then quorum listextended — together about a millisecond of the seven a block costs, nearly all of it Core's round trip.

The heights are consecutive, so start the next pair as soon as the current one returns, on a second connection so a speculative call never sits in front of a real one. A guess that fails — the normal case at the tip, where the next core block does not exist yet — backs the prefetcher off for the next 32 calls instead of asking again every block. A node that cannot open the second connection logs a warning and runs without prefetching.
@github-actions github-actions Bot added this to the v4.2.0 milestone Aug 31, 2026
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 17 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 38b0697d-0341-44f1-9ad1-7c6084b4abc3

📥 Commits

Reviewing files that changed from the base of the PR and between 17a2962 and 5dee747.

📒 Files selected for processing (3)
  • packages/rs-drive-abci/src/rpc/core.rs
  • packages/rs-drive-abci/src/rpc/mod.rs
  • packages/rs-drive-abci/src/rpc/prefetch.rs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@thepastaclaw

thepastaclaw commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

🕓 Ready for review — 17 ahead in queue (commit 5dee747)
Queue position: 18/33 · 2 reviews active
ETA: start ~09:09 UTC · complete ~10:13 UTC (median 1h 4m across 30 recent reviews; 2 slots)
Queued 8h 38m ago · Last checked: 2026-09-01 00:30 UTC

@PastaPastaPasta

Copy link
Copy Markdown
Member Author

Superseded by #4572, which is the same change from a branch in dashpay/platform rather than my fork.


🤖 Posted autonomously by Claude on behalf of pasta.

@PastaPastaPasta
PastaPastaPasta deleted the perf/core-rpc-prefetch branch September 1, 2026 00:39
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