Skip to content

bench(drive-abci): per-block phase timing behind DRIVE_BLOCK_PERF - #4573

Open
PastaPastaPasta wants to merge 1 commit into
v4.2-devfrom
bench/block-phase-timing
Open

bench(drive-abci): per-block phase timing behind DRIVE_BLOCK_PERF#4573
PastaPastaPasta wants to merge 1 commit into
v4.2-devfrom
bench/block-phase-timing

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Sep 1, 2026

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

There was no way to see where a block's time goes inside drive-abci. ProcessProposal logged one elapsed_time_ms — truncated to whole milliseconds — and FinalizeBlock logged nothing at all, so more than half the per-block cost was unattributed.

That gap hid two costs that scale with chain history and together accounted for most of a mainnet sync:

Neither is visible without per-phase numbers. Both were found with this.

What was done?

A Laps value times successive phases of block execution and merges them into process-wide totals on drop. perf::end_block reports the means every DRIVE_BLOCK_PERF_EVERY blocks (default 500) as a single log line.

Two design points worth noting:

  • Off unless DRIVE_BLOCK_PERF=1. The switch is a OnceLock<bool> read once; when off, Laps::new allocates nothing and every lap returns immediately.
  • Accumulated, not logged per block. An earlier version emitted a line per block and the JSON formatting landed inside the spans being measured, inflating exactly the phases under investigation. Means are reported periodically instead.

The mean is over blocks rather than over samples, so a phase that only runs on some blocks shows its share of the per-block cost rather than its cost when it fires. Sample counts are reported alongside, which is how the fire rate of a phase becomes visible.

Phases covered: the block-proposal path (epoch info, block-cache clear, state clone, core info, chain lock, withdrawals, DAO events, state transitions, fees, root hash, validator set) and the finalize path (proposal validation, commit signature verification, drive cache, state cache, commit, checkpoint).

Example output:

block perf  height=195000 blocks=500
  core_info=1220 fbp_verify_commit=567 sps_serialize=607 chainlock=456
  fb_commit=354 wd_status=335 dao=187 state_clone=154 fees=150 ...

How Has This Been Tested?

Used throughout a full mainnet replay, genesis to 424,981, and for every A/B measurement behind #4569, #4570, #4571 and #4572.

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

Breaking Changes

None. Inert unless the environment variable is set.

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

Times each phase of ProcessProposal and FinalizeBlock and reports the means every DRIVE_BLOCK_PERF_EVERY blocks (default 500). Off unless DRIVE_BLOCK_PERF=1, and accumulated in memory rather than logged per block, so the measurement does not pay for a log line inside the spans it measures.

This is what located the two per-block costs that scale with chain history: an unbounded withdrawal-document query and GroveDB checkpoint creation during replay.
@github-actions github-actions Bot added this to the v4.2.0 milestone Sep 1, 2026
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 59 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: Team

Run ID: 2df2b70f-e894-4d03-969a-492d15e16dad

📥 Commits

Reviewing files that changed from the base of the PR and between c0e9a86 and fe6a596.

📒 Files selected for processing (6)
  • packages/rs-drive-abci/src/abci/handler/finalize_block.rs
  • packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs
  • packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs
  • packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs
  • packages/rs-drive-abci/src/lib.rs
  • packages/rs-drive-abci/src/perf.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 Sep 1, 2026

Copy link
Copy Markdown
Collaborator

🕓 Ready for review — 19 ahead in queue (commit fe6a596)
Queue position: 20/42 · 2 reviews active
ETA: start ~00:49 UTC · complete ~01:36 UTC (median 47m across 30 recent reviews; 2 slots)
Queued 17h ago · Last checked: 2026-09-01 17:40 UTC

@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 42.13836% with 92 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.93%. Comparing base (17a2962) to head (fe6a596).
⚠️ Report is 7 commits behind head on v4.2-dev.

Files with missing lines Patch % Lines
packages/rs-drive-abci/src/perf.rs 23.91% 70 Missing ⚠️
.../src/execution/engine/run_block_proposal/v0/mod.rs 62.85% 13 Missing ⚠️
...s/rs-drive-abci/src/abci/handler/finalize_block.rs 66.66% 4 Missing ⚠️
...execution/engine/finalize_block_proposal/v0/mod.rs 73.33% 4 Missing ⚠️
...bci/src/execution/engine/run_block_proposal/mod.rs 80.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           v4.2-dev    #4573      +/-   ##
============================================
- Coverage     87.57%   84.93%   -2.64%     
============================================
  Files          2748     2787      +39     
  Lines        357005   369955   +12950     
============================================
+ Hits         312647   314225    +1578     
- Misses        44358    55730   +11372     
Components Coverage Δ
dpp 83.92% <ø> (-4.46%) ⬇️
drive 83.89% <ø> (-2.50%) ⬇️
drive-abci 89.30% <42.13%> (-0.59%) ⬇️
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value 92.92% <ø> (ø)
platform-wallet ∅ <ø> (∅)
drive-proof-verifier 41.28% <ø> (-7.37%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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