This PR adds a statistics collector class which aims to collect various types of statistics up to the configurable maximum memory target. At the moment, only mempool statistics will be collected.
Motivation
Adding more statistics and visualization to the GUI would leverage its usage. To do so, we need stats that are collected even when the visualization is not visible (example: the GUI network graph will only draw data when it's visible which is kinda unusable)
How it works
This PR adds a simple stats manager that polls stats over a repetitive CScheduler task.
The samples are not guaranteed to be const-time. Each sample contains a time delta to the last one (uint16_t).
API
-statsenabledefault disabled-statsmaxmemorytarget10MB default maximal memory target to use for statistics.RPC:
getmempoolstats
[
{
"percision_interval": 2,
"time_from": 1494252401,
"samples": [
[
11,
1,
1008,
0
], ....
}...
]
Features
-> CScheduler driven sample collecting (current interval 2000ms) -> Relevant mempool data (size, memory requirement, minfee) gets written to an atomic cache (no additional locking required) -> Multiple precision levels (currently three, 2s, 60s, 1800s) -> Memory target that will calculate how many samples do fit in the given target -> Sample do only have a 2byte time-delta to the last sample, allowing to save some memory -> Flexible design, adding more data-points should be simple (bandwidth, utxo-stats, etc.).