It can be useful to know, how many blocks and how many times the mempool was filtered.
Bloom filtering is CPU intense and thus informations about its usage can help to identify sources of resource consumption. Collecting statistics would be required to dynamic limit the amount of accepted bloom filtering.
This PR does only collect global statistics (total value and value per timeframe of currently 1h), though, I kept the design flexible. Extending this to per-node bloom-filter statistics is possible.
Also the time consumption in milliseconds for all filter processes will be collected, although, this value depends on your system workload and might not be very representative.
Statistics can be printed with the new RPC command getfilterstats.
Example:
/src/bitcoin-cli getfilterstats
{
"current_timeframe": {
"time_in_timeframe": 304,
"blocks": {
"filteredblocks_count": 1,
"filteredblocks_amountofbytes": 989168,
"filteredblocks_timeconsumption": 0
},
"mempool": {
"mempool_filter_count": 4,
"mempool_filter_amountoftxes": 1788,
"mempool_filter_timeconsumption": 113
}
},
"total": {
"blocks": {
"filteredblocks_count": 1,
"filteredblocks_amountofbytes": 989168,
"filteredblocks_timeconsumption": 0
},
"mempool": {
"mempool_filter_count": 4,
"mempool_filter_amountoftxes": 1788,
"mempool_filter_timeconsumption": 1788
}
}
}