Skip to content

perf(drive-abci): don't create GroveDB checkpoints while replaying history - #4570

Open
PastaPastaPasta wants to merge 1 commit into
v4.2-devfrom
perf/checkpoint-skip-during-replay
Open

perf(drive-abci): don't create GroveDB checkpoints while replaying history#4570
PastaPastaPasta wants to merge 1 commit into
v4.2-devfrom
perf/checkpoint-skip-during-replay

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Sep 1, 2026

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

A node replaying mainnet history creates and destroys tens of thousands of GroveDB checkpoints.

Protocol version 11 (mainnet height 318,704) turns checkpoints on:

should_checkpoint: Some(0),
update_checkpoints: Some(0),

with frequency_seconds: 600, num_checkpoints: 3. The interval is in chain time, and mainnet blocks are ~2.5 minutes apart, so that is a checkpoint every four blocks. At replay speed that is roughly 37 a second, each one a RocksDB checkpoint over the whole database — hard-linking every SST, flushing and copying the WAL — plus a copy of the platform state, and all but the last three deleted again immediately.

Measured with per-block phase timing, replaying mainnet:

fb_checkpoint = 15,122 µs/block

against roughly 7,000 µs for everything else in a block put together. A finished mainnet sync left four checkpoint directories on disk out of some 26,000 created:

drive-db/checkpoints:  369259  424972  424976  424979   (100M)

The last three are four blocks apart, which is the cadence.

It shows up as an I/O stall rather than CPU: during the affected range drive-abci sat at 0.38 of one core with the system 47–73% idle and the disk at 2,000–4,000 tps.

What was done?

Skip checkpoint creation for blocks more than ten minutes old. Checkpoints are restore points for a running node; a node catching up has no use for restore points into blocks it is about to replace, and it writes its first real checkpoint on reaching the tip.

The age test is a new utils::is_historical_block, with unit tests — the predicate is the testable part, since a historical replay makes every block historical by construction.

Checkpoints live outside the tree, so no app hash changes.

How Has This Been Tested?

Same 3,000-block window from mainnet height 331,648, two local peers, back to back:

blocks/s ms/block fb_checkpoint
before 47.6 21.01 12,136 µs
after 121.6 8.23 0

−60.8% per block. The 47.6 blocks/s reproduces what a full sync does over that range.

Full mainnet replay, genesis to 424,981, with this change on top of an otherwise identical build: 4,684.9 s → 3,032.9 s, 35% of the whole sync. Every committed app hash matched a reference sync across all 424,971 heights.

cargo test -p drive-abci --lib should_checkpoint utils::replay — 11 passed.

One existing test needed updating: test_first_block_should_always_checkpoint built its context with block_time_ms = 1_000_000, which is 1970 and now reads as history. It uses a current timestamp, and a companion test covers the new behaviour for an old block.

Breaking Changes

None for a node that is running. Once it reaches the tip it checkpoints exactly as it does today.

A node still catching up keeps no checkpoints, where before it kept three covering the last thirty minutes of chain time. Nothing during sync depends on them: a node that is interrupted picks up where it left off and carries on by itself, with no operator action, the same as it does today.

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

…story

Protocol version 11 turns checkpoints on, with a policy of one every 600 seconds of chain time keeping the last 3. Mainnet blocks are about 2.5 minutes apart, so that is a checkpoint every four blocks — which at replay speed is roughly 37 a second, each one a RocksDB checkpoint over the whole database plus a copy of the platform state, and all but the last three deleted again immediately.

Measured at 15.1 ms a block from height 318,704, against about 7 ms for everything else in a block put together. A finished mainnet sync had four checkpoint directories left on disk out of some 26,000 created.

Checkpoints are restore points for a running node, so skip them for blocks more than ten minutes old and write the first real one on reaching the tip. They live outside the tree, so no app hash changes.
@thepastaclaw

thepastaclaw commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

🕓 Ready for review — 8 ahead in queue (commit 302f7ef)
Queue position: 9/52 · 2 reviews active
ETA: start ~19:24 UTC · complete ~20:18 UTC (median 54m across 30 recent reviews; 2 slots)
Queued 2d 15h ago · Last checked: 2026-09-03 15:40 UTC

@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.22%. Comparing base (7c77247) to head (302f7ef).
⚠️ Report is 21 commits behind head on v4.2-dev.

Files with missing lines Patch % Lines
...tform_events/block_end/should_checkpoint/v0/mod.rs 93.33% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           v4.2-dev    #4570      +/-   ##
============================================
- Coverage     87.68%   87.22%   -0.46%     
============================================
  Files          2778     2786       +8     
  Lines        359190   361994    +2804     
============================================
+ Hits         314960   315767     +807     
- Misses        44230    46227    +1997     
Components Coverage Δ
dpp 89.05% <ø> (ø)
drive 86.06% <ø> (-0.57%) ⬇️
drive-abci 89.71% <93.33%> (-0.18%) ⬇️
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.

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 56 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: 1695c1f3-b821-49ee-8ce0-577f7a058835

📥 Commits

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

📒 Files selected for processing (3)
  • packages/rs-drive-abci/src/execution/platform_events/block_end/should_checkpoint/v0/mod.rs
  • packages/rs-drive-abci/src/utils/mod.rs
  • packages/rs-drive-abci/src/utils/replay.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.

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