Summary: As a subcomponent to: #1696
I think it may be near-term easy and important to bound the space usage of the mempool txs. (Note I am not proposing accounting for the LRU cache overhead, or mempoolTx struct overhead, just bounding the total amount of tx data itself)
Problem: At the moment, every tx in the mempool can be of size max(maxMsgSize, BlockDataSize), and the former is a constant of 1MB. In a lot configurations, block data size may be large, which would open up the mempool to taking a lot of ram. Under default mempool size, it would be 5000 * max_block_size. With 200KB blocks, thats 1GB of RAM, with 1MB blocks, that opens yourself up to 5GB of RAM consumed. I think both of these are too much to open up sentries under default
Proposed solution: Add a max_bytes field to the mempool config options. Before adding a tx to the mempool, check if it will cause the mempool to exceed its max_bytes limit. When removing txs in Update, subtract the corresponding amount from the max_bytes field. max_txs is a useful thing to still keep, as there are many things that depend on the number of txs as well. (Recheck time, etc.)
Summary: As a subcomponent to: #1696
I think it may be near-term easy and important to bound the space usage of the mempool txs. (Note I am not proposing accounting for the LRU cache overhead, or mempoolTx struct overhead, just bounding the total amount of tx data itself)
Problem: At the moment, every tx in the mempool can be of size
max(maxMsgSize, BlockDataSize), and the former is a constant of1MB. In a lot configurations, block data size may be large, which would open up the mempool to taking a lot of ram. Under default mempool size, it would be5000 * max_block_size. With 200KB blocks, thats 1GB of RAM, with 1MB blocks, that opens yourself up to 5GB of RAM consumed. I think both of these are too much to open up sentries under defaultProposed solution: Add a
max_bytesfield to the mempool config options. Before adding a tx to the mempool, check if it will cause the mempool to exceed its max_bytes limit. When removing txs in Update, subtract the corresponding amount from themax_bytesfield.max_txsis a useful thing to still keep, as there are many things that depend on the number of txs as well. (Recheck time, etc.)