A memory resource similar to std::pmr::unsynchronized_pool_resource
, but optimized for node-based containers. The goal is to be able to cache more coins with the same memory usage, and allocate/deallocate faster.
This is a reimplementation of #22702. The goal was to implement it in a way that is simpler to review & test
-
There is now a generic
PoolResource
for allocating/deallocating memory. This has practically the same API asstd::pmr::memory_resource
. (Unfortunately I cannot use std::pmr because libc++ simply doesn’t implement that API). -
Thanks to sipa there is now a fuzzer for PoolResource! On a fast machine I ran it for ~770 million executions without finding any issue.
-
The estimation of the correct node size is now gone, PoolResource now has multiple pools and just needs to be created large enough to have space for the unordered_map nodes.
I ran benchmarks with #22702, mergebase, and this PR. Frequency locked Intel i7-8700, clang++ 13.0.1 to reindex up to block 690000.
0bitcoind -dbcache=5000 -assumevalid=00000000000000000002a23d6df20eecec15b21d32c75833cce28f113de888b7 -reindex-chainstate -printtoconsole=0 -stopatheight=690000
The performance is practically identical with #22702, just 0.4% slower. It’s ~21% faster than master:
Note that on cache drops mergebase’s memory doesnt go so far down because it does not free the CCoinsMap
bucket array.