Saturday, January 3, 2026
HomeBitcoinbitcoin core - What's saved in dbcache and with what precedence?

bitcoin core – What’s saved in dbcache and with what precedence?

Solely deserialized UTXOs are held within the dbcache. Deserialized UTXOs are bigger than the serialized illustration on disk, so even whereas the chainstate is barely 11 GB, it could be bigger in reminiscence.

The -maxmempool configuration parameter limits the quantity of reminiscence utilized by the mempool in MB. Unused mempool reminiscence is used as extra dbcache.

Previous blocks are solely saved on disk, they aren’t cached.

That mentioned, there may be a misunderstanding right here:
The UTXO set is primarily saved on disk. When a node processes unconfirmed or confirmed transactions, it can load all the mandatory UTXOs for inputs from disk into the cache. When a brand new block is processed, it can additionally cache any outputs created by the confirmed transactions within the block.

The UTXO cache acts as a write-buffer. The UTXO set modifications are saved in reminiscence till the dbcache is full after which all the cache is flushed to disk (emptying the cache). If a UTXO is created and spent earlier than the cache is flushed, it’s by no means written to disk. The UTXO state can also be synchronized to disk as soon as per day (as soon as per hour throughout IBD) even when the dbcache will not be full. Then solely the soiled entries are written to disk and the remaining cache is saved heat (not emptying the cache).

Nodes don’t reload all the UTXO cache when beginning. UTXOs solely get cached because of transactions being validated, so besides proper after IBD with a really massive dbcache, a node will usually by no means maintain all the UTXO set in reminiscence. The node will nonetheless solely allocate as a lot reminiscence because it makes use of, so a bigger than essential dbcache is not going to waste reminiscence.

I assume that every one of this would be the identical for Knots, however I’m not aware of that code base.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments