Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: jnano on December 25, 2017, 09:23:47 AM



Title: Why does Core rewrite the chainstate after startup?
Post by: jnano on December 25, 2017, 09:23:47 AM
Why does Bitcoin Core rewrite large parts of the chainstate after startup?
It happens even when very few new blocks were downloaded, and it takes a long while, sometimes 30 minutes (on HDD).


Title: Re: Why does Core rewrite the chainstate after startup?
Post by: LoyceV on December 25, 2017, 09:39:21 AM
Why does Bitcoin Core rewrite large parts of the chainstate after startup?
It checks some older blocks, without knowing all technical details I can tell it's to ensure it's on the right chain.

Quote
It happens even when very few new blocks were downloaded, and it takes a long while, sometimes 30 minutes (on HDD).
Is your computer very limited on RAM? It used to take about 1 minute with chainstate on my hdd, and it's reduced to just seconds with chainstate on my SSD.

Your nickname looks familiar, haven't we discussed Bitcoin Core's performance before?
Edit: we did (https://bitcointalk.org/index.php?topic=2475676.msg25398974#msg25398974). I still think your performance problems must be related to your computer (hardware or operating system).


Title: Re: Why does Core rewrite the chainstate after startup?
Post by: jnano on December 25, 2017, 10:19:40 AM
Yes, we've talked about similar I/O issues before. It's another one related to the bad/no caching behavior of Core.
I'm not talking about syncing here, just a chainstate rewrite even when it's fully synced, or at worst a handful of blocks away (the UI doesn't show the syncing progress overlay).

So I wonder why it needs to do a lengthy rewrite on startup, considering that after it's settled, when downloading blocks later on there isn't such a lengthy process. There's something unique about what it does on startup. Maybe insight into that could allow me to optimize Core's settings, or find another way to dodge the issue. Maybe it'll get bugfixed.

As before, there's nothing special with my computer. It's perfectly fine, everything besides Core works as it should. It's just running Core that's always such a chore. :)

Your RAM drive idea helped with syncing (though it requires manual work), but after syncing and copying the files back to HDD, I still need to run it from the HDD. And then, in many cases, also the chainstate rewrite gets real tedious. Now, if the the caching code is improved it would surely help, but I'm still curious why there's a need for that major rewrite, unrelated to syncing, on every startup.

BTW, Litecoin Core behaves better, at least partially. Though there I'm on an older version, 0.14.2. Also the different/smaller blockchain might affect the behavior.