Skip to content

Conversation

Cmdv
Copy link
Contributor

@Cmdv Cmdv commented Oct 16, 2025

Fix: Reduce snapshot frequency during initial sync

Fixes issue #1992 by making ledger state snapshot intervals configurable and significantly reducing snapshot frequency during initial sync to improve performance.

Changes:

  • Added snapshot_interval configuration with following (default: 500) and lagging (default: 100,000, previously 10,000) parameters
  • Fixed bug in timeToSnapshot function that was ignoring the lagging interval (previously hardcoded to False)
  • When near tip, snapshots continue every 500 blocks for quick rollback recovery

New configuration:

 {
   "snapshot_interval": {
     "following": 500,
     "lagging": 100000
   }
 }

@Cmdv Cmdv requested a review from a team as a code owner October 16, 2025 09:13
@Cmdv Cmdv force-pushed the 1992-custom-snapshots-freq branch from 5facdcc to 87ad121 Compare October 16, 2025 09:19
case (syncSt, unBlockNo bNo) of
(SyncFollowing, bno) -> bno `mod` leSnapshotEveryFollowing env == 0
(SyncLagging, _) -> False
(SyncLagging, bno) -> bno `mod` leSnapshotEveryLagging env == 0
Copy link
Contributor

@kderme kderme Oct 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this actually increases the frequency of snapshots instead of reducing it. As the ticket suggests

During syncing dbsync takes a snapshot every epoch. ... We should 
take them much more rarely, at least for the majority of the syncing. 
When dbsync reaches the tip of the chain, for example it's within 3-5
epochs from the tip, it can continue with snapshots for every epoch.

These lines could be relevant https://github.com/IntersectMBO/cardano-db-sync/pull/2006/files#diff-414b9fb12c496ccef0f8796908e01b3c282a0d1db1434da6d53756104e524f21R333

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