Skip to content

mempool: Slight performance nit when erasing from setEntries

Summary

When re-reading all of the mempool code in master I noticed that in 2 places, a working setEntries (which is an alias for a std::set<CTxMemPool::txiter>) was being erased-from inefficiently.

In these two places we are grabbing the first txiter from the set then we are erasing it. In the extant code, the txiter is being passed as a key to the set. Instead, we should be erasing using the slightly more efficient std::set(std::set::iterator) overload, which does not need to do any O(log N) lookups.

This MR is basically just a tiny performance nit.

Test Plan

  • ninja all check-all

Also perhaps try this here versus master (maybe you will notice a perf. diff against master although given the way these tx's are set up, you may not):

  • ninja bench_bitcoin && src/bench/bench_bitcoin -filter='Evict.*'

Merge request reports