Work decoupled from #26966 per request.
The aim is to remove an unnecessary disk read operation that currently takes place with every new arriving block (or scanned block during background sync). Instead of reading the last filter header from disk merely to access its hash for constructing the next filter, this work caches it, occupying just 32 more bytes in memory.
Also, reduces cs_main
lock contention during the index initial sync process. And, simplifies the indexes initialization and shutdown procedure.
Testing Note:
To compare the changes, added a pretty basic benchmark in the second commit. Alternatively, could also test the changes by timing the block filter sync from scratch on any network; start the node with -blockfilterindex
and monitor the logs until the syncing process finish.
Local Benchmark Results:
*Master (c252a0fc0f4dc7d262b971a5e7ff01508159193b):
ns/op | op/s | err% | total | benchmark |
---|---|---|---|---|
132,042,516.60 | 7.57 | 0.3% | 7.79 | BlockFilterIndexSync |
*PR (43a212cfdac6c64e82b601c664443d022f191520):
ns/op | op/s | err% | total | benchmark |
---|---|---|---|---|
126,915,841.60 | 7.88 | 0.6% | 7.51 | BlockFilterIndexSync |