I ran a small external python simulation to get a rough sense of how often the early-exit fee loop would actually stop much earlier than a full sum under realistic mempool conditions.
Using a model with 3000 txs (fees = feerate × vsize, realistic feerate ranges, small per-tick mempool drift, and occasional high-fee arrivals), the results were:
– threshold=0: median touch fraction ≈ 0.97, meaning in a typical run the loop still scans about 97% of transactions before returning; about 43 % of trials didn’t beat the old total at all.
– threshold=100.000: median = 1.0, early exit never triggered within a tick.
On my machine (Apple M2 Max), summing all 3000 fees takes about 0.4 µs, so the median time saved by early-exit was around 0.01 µs (10 ns) (essentially negligible).
This could suggest that early-exit almost never helps in practice, while the std::accumulate has the benefits already discussed.