Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull initial chain compaction out of init() and into the syncer #2738

Merged

Conversation

antiochp
Copy link
Member

@antiochp antiochp commented Apr 9, 2019

We added a chain.compact() on startup in #2127 to ensure nodes that did not run 24/7 still had the opportunity to compact their local storage (like a laptop that is running only intermittently).

This PR pulls this initial chain.compact() call out from Chain::init() and into the syncer, specifically on initial transition to NoSync.
It never really belonged there as Chain::init() should not be responsible for going off and cleaning local storage up as it starts up.

This postpones the compaction process to after the initial sync, rather than having it run before we start syncing.

Additionally we add a 60 block threshold to prevent a node triggering multiple chain compactions if restarted frequently (like we do during dev and testing).

This should make the node a bit more responsive initially and should allow a node to begin syncing a little quicker on startup.

Example where we skip chain compaction because we recently ran one -

20190409 16:18:48.975 DEBUG grin_chain::chain - compact: head: 120396, tail: 110315, diff: 10081, horizon: 10080
20190409 16:18:48.975 DEBUG grin_chain::chain - compact: skipping compaction - threshold is 60 blocks beyond horizon.

@antiochp antiochp force-pushed the compact_on_startup_threshold branch from 07ceee8 to f573ea4 Compare April 9, 2019 15:15
Copy link
Contributor

@ignopeverell ignopeverell left a comment

Choose a reason for hiding this comment

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

LGTM!

@ignopeverell ignopeverell merged commit e8c5035 into mimblewimble:master Apr 12, 2019
@antiochp antiochp deleted the compact_on_startup_threshold branch April 13, 2019 11:59
@antiochp antiochp added this to the 1.1.0 milestone Jun 5, 2019
@antiochp antiochp added the release notes To be included in release notes (of relevant milestone). label Jun 5, 2019
@antiochp antiochp changed the title pull initial chain compaction out of init() and into the syncer Pull initial chain compaction out of init() and into the syncer Jun 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement release notes To be included in release notes (of relevant milestone).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants