bench(drive-abci): per-block phase timing behind DRIVE_BLOCK_PERF - #4573
bench(drive-abci): per-block phase timing behind DRIVE_BLOCK_PERF#4573PastaPastaPasta wants to merge 1 commit into
Conversation
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.
|
Warning Review limit reachedNext included review available in 59 minutes. View limit detailsLimit 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. Review configuration: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (6)
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. Comment |
|
🕓 Ready for review — 19 ahead in queue (commit fe6a596) |
Codecov Report❌ Patch coverage is 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
🚀 New features to boost your workflow:
|
Issue being fixed or feature implemented
There was no way to see where a block's time goes inside drive-abci.
ProcessProposallogged oneelapsed_time_ms— truncated to whole milliseconds — andFinalizeBlocklogged 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
Lapsvalue times successive phases of block execution and merges them into process-wide totals on drop.perf::end_blockreports the means everyDRIVE_BLOCK_PERF_EVERYblocks (default 500) as a single log line.Two design points worth noting:
DRIVE_BLOCK_PERF=1. The switch is aOnceLock<bool>read once; when off,Laps::newallocates nothing and everylapreturns immediately.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:
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:
For repository code-owners and collaborators only
🤖 Generated with Claude Code