Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: refactor use of getrawmempool in functional tests for efficiency #22707

Conversation

mjdietzx
Copy link
Contributor

@mjdietzx mjdietzx commented Aug 15, 2021

I don't think this changes the intention of the test. But it does shave ~30 seconds off the time it takes to run. From what I've seen our CI macOS 11 native [gui] [no depends] runs mempool_updatefrom.py in ~135 seconds. After this PR it should run in ~105 seconds

I noticed this improvement should probably be made when testing performance/runtimes of #22698. But I wanted to separate this out from that PR so the affects of each is decoupled

Edit: The major change in this PR is improving mempool_updatefrom.py's runtime as this is a very long running test. Then made the same efficiency improvements across all the functional tests as it made since to do that here

@DrahtBot DrahtBot added the Tests label Aug 15, 2021
@fanquake fanquake requested review from ariard and glozow August 16, 2021 03:05
Copy link
Member

@glozow glozow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK, it certainly saves time to just fetch the entry we need instead of the entire mempool, particularly because this test puts a lot of transactions in there. It is significantly faster on my machine as well.

Should do this for other functional tests as well, e.g:

test/functional/mempool_compatibility.py
test/functional/rpc_fundrawtransaction.py
test/functional/mempool_package_limits.py

(From a quick grep for getrawmempool(True) and getrawmempool(verbose=True) and eliminating the ones that should actually use getrawmempool)

test/functional/mempool_updatefromblock.py Outdated Show resolved Hide resolved
@mjdietzx
Copy link
Contributor Author

Thanks @glozow - good suggestions, I'll follow up with these shortly

@mjdietzx mjdietzx force-pushed the test_improve_mempool_updatefromblock_efficiency branch from 99fb430 to 47c48b5 Compare August 16, 2021 13:36
@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 16, 2021

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #22689 (rpc: deprecate top-level fee fields in getmempool RPCs by josibake)
  • #21515 (Erlay: bandwidth-efficient transaction relay protocol by naumenkogs)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

Copy link
Member

@josibake josibake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review and Concept ACK

+1 for always preferring getmempoolentry over getrawmempool when you are referencing specific txns.

left a suggestion about using deprecated fee fields, but like i mentioned, it might be out of scope for this PR.

i would also suggest updating the title and description of the PR to reflect that you are globally replacing references to getrawmempool (right now it's still specific to mempool_updatefrom)

after updating the title and description, 86dbd54 and 7734971 should be squashed

you could even squash all three, since both changes fall under refactoring for efficiency 🤷‍♂️

@mjdietzx mjdietzx changed the title test: improve mempool_updatefrom efficiency by using getmempoolentry for specific txns test: refactor use of getrawmempool in functional tests for efficiency Aug 17, 2021
@mjdietzx
Copy link
Contributor Author

Thanks for the review @josibake ! Updated PR title/description accordingly

left a suggestion about using deprecated fee fields, but like i mentioned, it might be out of scope for this PR.

I think this is/should be done in your PR #22689. If we have merge conflicts one of us will just need to rebase depending on whose PR gets merged first.

@theStack
Copy link
Contributor

Concept ACK

Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested ACK 47c48b5

On my machine, the speed-up of mempool_updatefromblock.py is quite impressive (>2x):

master branch:

$ time ./test/functional/mempool_updatefromblock.py
    3m18.16s real     2m04.55s user     0m33.54s system

PR branch:

$ time ./test/functional/mempool_updatefromblock.py
    1m29.11s real     0m34.37s user     0m14.79s system

Copy link
Member

@darosior darosior left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK

@maflcko maflcko merged commit 4fc15d1 into bitcoin:master Aug 20, 2021
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 20, 2021
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants