Make use of #17487.
Benchmark results available here: #17487 (comment)
Make use of #17487.
Benchmark results available here: #17487 (comment)
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
See the guideline for information on the review process.
Type | Reviewers |
---|---|
ACK | Sjors |
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
5032@@ -5033,15 +5033,19 @@ bool ChainstateManager::ActivateSnapshot(
5033 return true;
5034 }
5035
5036-static void FlushSnapshotToDisk(CCoinsViewCache& coins_cache, bool snapshot_loaded)
5037+static void FlushSnapshotToDisk(CCoinsViewCache& coins_cache, bool snapshot_loaded, bool erase=true)
5038 {
5039 LOG_TIME_MILLIS_WITH_CATEGORY_MSG_ONCE(
5040 strprintf("%s (%.2f MB)",
5041 snapshot_loaded ? "saving snapshot chainstate" : "flushing coins cache",
(erase ? "syncing" : "flushing") + "coins cache"
5035@@ -5036,12 +5036,12 @@ bool ChainstateManager::ActivateSnapshot(
5036 static void FlushSnapshotToDisk(CCoinsViewCache& coins_cache, bool snapshot_loaded)
5037 {
5038 LOG_TIME_MILLIS_WITH_CATEGORY_MSG_ONCE(
5039- strprintf("%s (%.2f MB)",
5040- snapshot_loaded ? "saving snapshot chainstate" : "flushing coins cache",
5041+ strprintf("%s coins cache (%.2f MB)",
If you’re touching this, maybe use LogPrintf
and add [snapshot]
.
Maybe make it [[nodiscard]]
?
4257@@ -4258,7 +4258,9 @@ bool Chainstate::ReplayBlocks()
4258 }
4259
4260 cache.SetBestBlock(pindexNew->GetBlockHash());
4261- cache.Flush();
4262+ if (!cache.Flush()) {
4263+ return AbortNode("Failed to write to coin database");
return error(…)
. What’s the difference with AbortNode
?
Benchmark results available here:
https://github.com/bitcoin/bitcoin/pull/17487#issuecomment-557226923
We've historically done this check in most places, so make sure we're
doing it uniformly.
5046
5047- snapshot_loaded ? coins_cache.Sync() : coins_cache.Flush();
5048+ if (snapshot_loaded ? coins_cache.Sync() : coins_cache.Flush()) {
5049+ return true;
5050+ } else {
5051+ return AbortNode("Failed to write to coin database");
AbortNode
vs. error
though.
AbortNode()
is used elsewhere in the function that this function is called from, although I did change another reference that you pointed out was inconsistent.
@Sjors how did you detect that RAM wasn’t being freed? Did you verify that the flush did not happen based on an absence of logs?
Measures of memory can be deceptive; I remember bitcoinperf spuriously detecting an increase in memory usage because once claimed, the process’ resident set size (RSS) doesn’t necessarily go down upon free.