0

Whenever a transaction is received by a node, the node verifies its validity. To that end, it checks for each transaction input whether that input is part of the UTXO set. It is my understanding that the UTXO set is stored in the chainstate database, which is held in a LevelDB structure.

I previously thought that he UTXO set was kept available in memory, but since I've learned that it is currently about 1.2GiB in size that seems unlikely.

So, I assume the chainstate-db is stored on disk, but accessed multiple times per second to check transaction inputs. What amount of memory usage does this induce on a node?

1
  • It needs to be stored on disk to preserve it when closing and then opening the application. However most (or on systems with enough memory: all) of it is also in RAM. Every time it needs to scan through the UTXO set, it will load the used chunks into memory and keep them there as long as possible. I imagine after a few scans most of it will be in memory. If it does not fit in memory, it will quickly increase the disk I/O and slow everything down.
    – Jannes
    Apr 26, 2016 at 10:10

1 Answer 1

1

You are right UTXO set is stored on disk on .bitcoin/chainstate directory using leveldb. It is stored in compressed state and the current size is around 1.5GB

To speed up access bitcoind uses an in memory cache which can be configured using -dbcache option.

So, I assume the chainstate-db is stored on disk, but accessed multiple times per second to check transaction inputs. What amount of memory usage does this induce on a node?

Accessing the leveldb database itself is like accessing any other nosql database. You basically lookup the key which is the utxo and get a value as output which you need to deserialize and store in a memory variable

2
  • So, essentially, it'll fill -dbcache amount of memory long term with some spikes whenever I access the db?
    – Murch
    Apr 27, 2016 at 8:29
  • Yes, there is also memory taken by mempool which can be controlled by maxmempoolsize. Also there are some minor caches maintained by leveldb and other parts of code which I am not aware of. These are memory cache options documented for configuration in bitcoin Apr 28, 2016 at 5:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.