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

Log/report in 10% steps during VerifyDB #8136

Merged
merged 1 commit into from
Jun 7, 2016

Conversation

jonasschnelli
Copy link
Contributor

By default Bitcoin-Core does verify the last 288 blocks. This can take a couple of minutes on slow systems.

This PR adds a simple progress report during VerifyDB in 10% steps into the debug log.
I think misusing the debug.log for this – relatively long taking process – is okay.

Example:

2016-06-02 11:56:01 init message: Verifying blocks...
2016-06-02 11:56:01 Verifying last 288 blocks at level 3
[0%]...[10%]...[20%]...[30%]...[40%]...[50%]...[60%]...[70%]...[80%]...[90%]...[DONE].
No coin database inconsistencies in last 289 blocks (68239 transactions)

@sipa
Copy link
Member

sipa commented Jun 2, 2016

Perhaps we should also reduce the number 288. Maybe a limit specified in number of transactions is better?

@jonasschnelli
Copy link
Contributor Author

Agree with @sipa, but could be a different PR (very likely more controversial).

@sipa
Copy link
Member

sipa commented Jun 2, 2016 via email

@dcousens
Copy link
Contributor

dcousens commented Jun 2, 2016

concept ACK

@dcousens
Copy link
Contributor

dcousens commented Jun 2, 2016

edit: moved comment to #8138 (comment)

int percentageDone = std::max(1, std::min(99, (int)(((double)(chainActive.Height() - pindex->nHeight)) / (double)nCheckDepth * (nCheckLevel >= 4 ? 50 : 100))));
if (reportDone < percentageDone/10) {
// report every 10% step
LogPrintf("[%d%%]...", percentageDone);
Copy link
Member

Choose a reason for hiding this comment

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

It's inventive to print a partial line here instead of a full line - however this can only work if there is nothing else happening in the background, otherwise partial log messages will mix.
As this is only called during AppInit2 I suppose it's safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think its fragile but okay as long as it is somewhere on the upper section of AppInit2(). :-)

@jonasschnelli
Copy link
Contributor Author

Fixed @laanwj nit.

@laanwj
Copy link
Member

laanwj commented Jun 7, 2016

Tested with -printtoconsole:

2016-06-07 07:16:19 [0%%]...[10%]...[20%]...[30%]...[40%]...[50%]...[60%]...[70%]...[80%]...[90%]...[DONE].
No coin database inconsistencies in last 21 blocks (30100 transactions)
2016-06-07 07:20:17  block index          242905ms
  • For some reason the second line doesn't get a time/date header. This seems like a bug in LogPrintf. To work around maybe use a separate LogPrintf line there same as you did for the 0%.
  • Also: the first is %%, the second and latter are %. This is an effect of a printf without argument being not a printf at all but a literal string print. https://github.com/bitcoin/bitcoin/blob/master/src/util.h#L94

@jonasschnelli
Copy link
Contributor Author

Thanks for testing!
Fixed the 0%% text typo as well as the missing time/date header (switched to a single line for the [DONE] part.

@laanwj
Copy link
Member

laanwj commented Jun 7, 2016

Tested ACK 8b78486

2016-06-07 13:21:01 Verifying last 288 blocks at level 3
2016-06-07 13:21:01 [0%]...[10%]...[20%]...[30%]...[40%]...[50%]...[60%]...[70%]...[80%]...[90%]...[DONE].
2016-06-07 13:23:39 No coin database inconsistencies in last 23 blocks (35781 transactions)

Slightly tangential: the progress reporting is quite distorted, by far most of the time is spent at 0%, then it seems to take a sprint for 100%.

@laanwj laanwj merged commit 8b78486 into bitcoin:master Jun 7, 2016
laanwj added a commit that referenced this pull request Jun 7, 2016
8b78486 Log/report in 10% steps during VerifyDB (Jonas Schnelli)
codablock pushed a commit to codablock/dash that referenced this pull request Dec 22, 2017
8b78486 Log/report in 10% steps during VerifyDB (Jonas Schnelli)
andvgal pushed a commit to energicryptocurrency/gen2-energi that referenced this pull request Jan 6, 2019
8b78486 Log/report in 10% steps during VerifyDB (Jonas Schnelli)
furszy added a commit to PIVX-Project/PIVX that referenced this pull request Jun 28, 2021
73d7288 [Doc] Mention reindex-chainstate in the release notes (random-zebra)
c45c0ec Skip MoneySupply update during reindex/reindex-chainstate (random-zebra)
efe193f Scan for better chains in ThreadImport (random-zebra)
0aceea3 Make ProcessNewBlock dbp const and update comment (Pieter Wuille)
8255e82 [Cleanup] Remove fVerifyingBlocks global flag (random-zebra)
30c7aed Add -reindex-chainstate that does not rebuild block index (random-zebra)
79d5cb2 Verify DB with original default check-level 3 (random-zebra)
ed96859 Reduce default number of blocks to check at startup (Pieter Wuille)
d4516fa Log/report in 10% steps during VerifyDB (Jonas Schnelli)
cce2c9e doc: Mention dbcache increase in release notes (random-zebra)
11dc022 [GUI] Update default db cache size in the options model (random-zebra)
9b7f764 Bump `-dbcache` default to 300MiB (Wladimir J. van der Laan)

Pull request description:

  This was attempted already in #1864 and #1907.
  Third time's a charm.

  Now the speed is acceptable and (unlike what was happening in #1907) the process can be interrupted.
  Further, as it is performed in ThreadImport, the GUI is open and functional during the chainstate reindex, instead of being seemingly stuck at the splash screen.

  This PR also includes a few improvements coming from bitcoin#10919, bitcoin#8273, bitcoin#8136 and bitcoin#8611.

  Here's a quick comparison of the data I had testing here (empty wallet with GUI, empty pivx.conf / default values).
  The reindexes have been performed with 0 network connections.

  <table>
  <tr>
  <th>Mainnet (height=2847011)</th><th>Master</th><th>this PR</th>
  </tr><tr>
  <td>online sync</td><td>8 hr 13 min</td><td>6 hr 42 min</td>
  </tr><tr>
  <td>-reindex (offline)</td><td>7 hr 14 min</td><td>6 hr 21 min</td>
  </tr><tr>
  <td>-reindex-chainstate (offline)</td><td>N/A</td><td>6 hr 13 min</td>
  </tr><tr>
  <td>startup (synced node)</td><td>100 sec</td><td>83 sec</td>
  </tr><tr>
  <td>RAM (synced node)</td><td>1.65 GiB</td><td>1.5 GiB</td>
  </tr><tr>
  <td>utxo_cache (synced node)</td><td>28.9MiB</td><td>39.5MiB</td>
  </tr>
  </table>

ACKs for top commit:
  furszy:
    re-ACK 73d7288, tested again.

Tree-SHA512: fb828d89692ccb6105eae5411b70a3c7a129d98d3101121cf604171de1b818a8c68b3771cc69fcf0a04642fe1327ee7ce360a72ecd7ef019b1614bd83c081de5
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants