mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-15 01:58:09 +02:00
validation: do not wipe utxo cache for stats/scans/snapshots
Since #28280, the cost of a non-wiping sync of the UTXO cache is only proportional to the number of dirty entries, rather than proportional to the size of the entire cache. Because of that, there is no reason to perform a wiping flush in case the contents of the cache is still useful. Split the FlushStateMode::ALWAYS mode into a FORCE_SYNC (non-wiping) and a FORCE_FLUSH (wiping), and then use the former in scantxoutset, gettxoutsetinfo, snapshot creation. Co-authored-by: l0rinc <pap.lorinc@gmail.com> Co-authored-by: cedwies <141683552+cedwies@users.noreply.github.com>
This commit is contained in:
@@ -110,6 +110,7 @@ FLUSHMODE_NAME = {
|
||||
1: "IF_NEEDED",
|
||||
2: "PERIODIC",
|
||||
3: "FORCE_FLUSH",
|
||||
4: "FORCE_SYNC",
|
||||
}
|
||||
|
||||
|
||||
@@ -385,7 +386,7 @@ class UTXOCacheTracepointTest(BitcoinTestFramework):
|
||||
bpf["utxocache_flush"].open_perf_buffer(handle_utxocache_flush)
|
||||
|
||||
self.log.info("stop the node to flush the UTXO cache")
|
||||
UTXOS_IN_CACHE = 2 # might need to be changed if the earlier tests are modified
|
||||
UTXOS_IN_CACHE = 3 # might need to be changed if the earlier tests are modified
|
||||
# A node shutdown causes two flushes. One that flushes UTXOS_IN_CACHE
|
||||
# UTXOs and one that flushes 0 UTXOs. Normally the 0-UTXO-flush is the
|
||||
# second flush, however it can happen that the order changes.
|
||||
@@ -415,7 +416,7 @@ class UTXOCacheTracepointTest(BitcoinTestFramework):
|
||||
bpf["utxocache_flush"].open_perf_buffer(handle_utxocache_flush)
|
||||
|
||||
self.log.info("prune blockchain to trigger a flush for pruning")
|
||||
expected_flushes.append({"mode": "NONE", "for_prune": True, "size": 0})
|
||||
expected_flushes.append({"mode": "NONE", "for_prune": True, "size": BLOCKS_TO_MINE})
|
||||
self.nodes[0].pruneblockchain(315)
|
||||
|
||||
bpf.perf_buffer_poll(timeout=500)
|
||||
|
||||
Reference in New Issue
Block a user