Carrying non-kernel related fields in the cache sizes for the indexes is confusing for kernel library users. The cache sizes are set currently with magic numbers in bitcoin-chainstate. The comments for the cache size calculations are not completely clear. The constants for the cache sizes are also currently in txdb.h
, which is not an ideal place for holding all cache size related constants.
Solve these things by moving the kernel-specific cache size fields to their own struct and moving the constants to either the node or the kernel cache sizes.
This slightly changes the way the cache is allocated if (and only if) the txindex and/or blockfilterindex is used. Since they are now given precedence over the block tree db cache, this results in a bit less cache being allocated to the block tree db, coinsdb and coins caches. The effect is negligible though, i.e. cache sizes with default dbcache reported through the logs are:
master:
0Cache configuration:
1* Using 2.0 MiB for block index database
2* Using 56.0 MiB for transaction index database
3* Using 49.0 MiB for basic block filter index database
4* Using 8.0 MiB for chain state database
5* Using 335.0 MiB for in-memory UTXO set (plus up to 286.1 MiB of unused mempool space)
this PR:
0Cache configuration:
1* Using 2.0 MiB for block index database
2* Using 56.2 MiB for transaction index database
3* Using 49.2 MiB for basic block filter index database
4* Using 8.0 MiB for chain state database
5* Using 334.5 MiB for in-memory UTXO set (plus up to 286.1 MiB of unused mempool space)
This PR is part of the libbitcoinkernel project.