Page MenuHomePhabricator

mempool: Slight performance nit when erasing from setEntries
ClosedPublic

Authored by Fabien on Feb 27 2023, 14:18.

Details

Reviewers
PiRK
Group Reviewers
Restricted Project
Commits
rABC4d6e97182f60: 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.

Port of bchn#1175.
Depends on D13171.

There is no change in behavior.

Test Plan
ninja all check-all

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien requested review of this revision.Feb 27 2023, 14:18
This revision is now accepted and ready to land.Feb 27 2023, 14:21

Failed tests logs:

====== Bitcoin ABC functional tests with the next upgrade activated: rpc_deprecated.py ======

------- Stdout: -------
2023-02-27T14:31:43.129000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20230227_142948/rpc_deprecated_28
2023-02-27T14:31:43.525000Z TestFramework (INFO): Check isfinaltransaction returns false when looking for unknown transactions
2023-02-27T14:31:43.529000Z TestFramework (INFO): Check isfinalblock and isfinaltransaction returns false when the quorum is not established
2023-02-27T14:31:48.439000Z TestFramework (INFO): Check the getblocktemplate output with and without -deprecatedrpc=getblocktemplate_sigops
2023-02-27T14:31:51.620000Z TestFramework (INFO): Check the getblockchaininfo output with and without -deprecatedrpc=softforks
2023-02-27T14:31:51.659000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 136, in main
    self.run_test()
  File "/work/test/functional/rpc_deprecated.py", line 151, in run_test
    assert 'ancestorcount' in utxo
AssertionError
2023-02-27T14:31:51.710000Z TestFramework (INFO): Stopping nodes
2023-02-27T14:31:51.912000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20230227_142948/rpc_deprecated_28
2023-02-27T14:31:51.912000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20230227_142948/rpc_deprecated_28/test_framework.log
2023-02-27T14:31:51.912000Z TestFramework (ERROR): 
2023-02-27T14:31:51.912000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20230227_142948/rpc_deprecated_28' to consolidate all logs
2023-02-27T14:31:51.912000Z TestFramework (ERROR): 
2023-02-27T14:31:51.912000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2023-02-27T14:31:51.913000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2023-02-27T14:31:51.913000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC functional tests with the next upgrade activated: rpc_deprecated.py

Rebase to fix the build failure

Failed tests logs:

====== Bitcoin ABC functional tests with the next upgrade activated: rpc_deprecated.py ======

------- Stdout: -------
2023-02-27T15:30:45.191000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20230227_152901/rpc_deprecated_28
2023-02-27T15:30:45.588000Z TestFramework (INFO): Check isfinaltransaction returns false when looking for unknown transactions
2023-02-27T15:30:45.592000Z TestFramework (INFO): Check isfinalblock and isfinaltransaction returns false when the quorum is not established
2023-02-27T15:30:50.319000Z TestFramework (INFO): Check the getblocktemplate output with and without -deprecatedrpc=getblocktemplate_sigops
2023-02-27T15:30:59.074000Z TestFramework (INFO): Check the getblockchaininfo output with and without -deprecatedrpc=softforks
2023-02-27T15:30:59.110000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 136, in main
    self.run_test()
  File "/work/test/functional/rpc_deprecated.py", line 151, in run_test
    assert 'ancestorcount' in utxo
AssertionError
2023-02-27T15:30:59.161000Z TestFramework (INFO): Stopping nodes
2023-02-27T15:30:59.463000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20230227_152901/rpc_deprecated_28
2023-02-27T15:30:59.463000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20230227_152901/rpc_deprecated_28/test_framework.log
2023-02-27T15:30:59.463000Z TestFramework (ERROR): 
2023-02-27T15:30:59.463000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20230227_152901/rpc_deprecated_28' to consolidate all logs
2023-02-27T15:30:59.463000Z TestFramework (ERROR): 
2023-02-27T15:30:59.463000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2023-02-27T15:30:59.463000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2023-02-27T15:30:59.463000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC functional tests with the next upgrade activated: rpc_deprecated.py