Part of #30289.
This adds a few optimizations to reduce TxGraph
’s memory usage, and makes sure that dynamic memory it uses doesn’t linger after shrinking clusters. Finally, it exposes a function GetMainMemoryUsage()
to compute TxGraph
’s approximate memory usage.
It makes the Cluster
type abstract, with two instances (SingletonClusterImpl
for 1-transaction clusters, and GenericClusterImpl
for others).
On my 64-bit system, I obtain the following numbers:
SingletonClusterImpl
: 48 bytes, plus 16 bytes malloc overhead in itsunique_ptr
, plus 8-byte pointer inm_clusters
GenericClusterImpl
: 104 bytes, plus 16 bytes malloc overhead in itsunique_ptr
, plus 8-byte pointer inm_clusters
, plus 72 bytes malloc overhead inside its vectors andDepGraph
, plus 40 bytes per transaction in those.TxGraphImpl::Entry
: 72 bytes per transactionTxGraphImpl::ChunkData
: 8 bytes, plus 56 bytes instd::set
overhead + malloc overhead, all per chunk.TxGraph::Ref
: 16 bytes per transaction
This overall amounts to 200 bytes per cluster, plus 64 bytes per chunk, plus 128 bytes per transaction, but only 224 bytes overall per singleton cluster.