> This follow-up to #21261 improves ProtectEvictionCandidatesByRatio() for better performance.
>
> Benchmarks are added; the performance improvement is between 2x and 5x for the benchmarked cases.
>
> The refactored code is well-covered by existing unit tests.
> p2p: iterate eviction protection only on networks having candidates in ProtectEvictionCandidatesByRatio().
> p2p: process more candidates per protection iteration for the usual case when some of the protected networks don't have eviction candidates, to reduce the number of iterations in ProtectEvictionCandidatesByRatio()
> p2p: earlier continuation when no remaining eviction candidates in ProtectEvictionCandidatesByRatio().
>
> With this change, `if (n.count == 0) continue;` will be true
> if a network had candidates protected in the first iterations
> and has no candidates remaining to be protected in later iterations.
This is a backport of [[https://github.com/bitcoin/bitcoin/pull/22284 | core#22284]]