Skip to content

Commit 8e37fa8

Browse files
committed
validation, log: improve logging in FlushSnapshotToDisk()
Use the `LOG_TIME_MILLIS_WITH_CATEGORY_MSG_ONCE` macro to improve the logging of snapshot persistance and no longer manually track the duration. before [snapshot] flushing coins cache (0 MB)... done (0.00ms) [snapshot] flushing snapshot chainstate to disk (0 MB)... done (0.00ms) after FlushSnapshotToDisk: flushing coins cache (0 MB) started FlushSnapshotToDisk: completed (0.00ms) FlushSnapshotToDisk: saving snapshot chainstate (0 MB) started FlushSnapshotToDisk: completed (0.00ms) The logging can be observed in the output of ./src/test/test_bitcoin -t validation_chainstate_tests -- DEBUG_LOG_OUT
1 parent 271252c commit 8e37fa8

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/validation.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4842,16 +4842,14 @@ bool ChainstateManager::ActivateSnapshot(
48424842

48434843
static void FlushSnapshotToDisk(CCoinsViewCache& coins_cache, bool snapshot_loaded)
48444844
{
4845-
LogPrintf("[snapshot] flushing %s (%.2f MB)... ", /* Continued */
4846-
snapshot_loaded ? "snapshot chainstate to disk" : "coins cache",
4847-
coins_cache.DynamicMemoryUsage() / (1000 * 1000));
4848-
4849-
const int64_t flush_now{GetTimeMillis()};
4845+
LOG_TIME_MILLIS_WITH_CATEGORY_MSG_ONCE(
4846+
strprintf("%s (%.2f MB)",
4847+
snapshot_loaded ? "saving snapshot chainstate" : "flushing coins cache",
4848+
coins_cache.DynamicMemoryUsage() / (1000 * 1000)),
4849+
BCLog::LogFlags::ALL);
48504850

48514851
// TODO: if #17487 is merged, add erase=false here if snapshot is loaded, for better performance.
48524852
coins_cache.Flush();
4853-
4854-
LogPrintf("done (%.2fms)\n", GetTimeMillis() - flush_now);
48554853
}
48564854

48574855
bool ChainstateManager::PopulateAndValidateSnapshot(

0 commit comments

Comments
 (0)