> bench: add benchmark for checkblockindex
> validation: improve performance of CheckBlockIndex
>
> by not saving all indexes in a std::multimap, but only
> those that are not part of the best header chain.
> The indexes of the best header chain are stored in a vector,
> which, in the typical case of a mostly linear chain with
> a few forks, results in a much smaller multimap, and increases
> performance noticeably for long chains.
>
> This does not change the actual consistency checks that are being
> performed for each index, just the way the block index tree is
> stored and traversed.
>
> Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Bench before:
```
| ns/op | op/s | err% | total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
| 165,601.17 | 6,038.60 | 0.2% | 0.01 | `CheckBlockIndex`
```
Bench after
```
| 67,085.14 | 14,906.43 | 0.3% | 0.01 | `CheckBlockIndex`
```
> validation: allow to specify frequency for -checkblockindex
>
> This makes it similar to -checkaddrman and -checkmempool, which
> also allow to run the check occasionally instead of always / never.
>
> Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
This is a backport of core#28339