Skip to content

Conversation

@theStack
Copy link
Contributor

This PR gives some love to the functional test p2p_feefilter.py by introducing the following changes:

master branch:
$ time ./p2p_feefilter.py
...
real    0m39.367s
user    0m1.227s
sys 0m0.571s

PR branch:
$ time ./p2p_feefilter.py
...
real    0m9.386s
user    0m1.120s
sys 0m0.577s

@fanquake fanquake added the Tests label Jul 22, 2020
Copy link
Member

@jonatack jonatack 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

Edit: verified the test runs significantly more quickly with the noban arg.

@theStack theStack force-pushed the 20200722-test-p2p_feefilter_improvements branch from bde6920 to 302388e Compare July 22, 2020 15:11
@theStack
Copy link
Contributor Author

Thans a lot for reviewing jonatack! Force-pushed with your suggested changes.

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

LGTM, a couple more comments below.

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we can eek some more perf by memoizing (untested):

Suggested change
test_framework.wait_until(lambda: sorted(invs_expected) == sorted(self.txinvs),
expected_txinvs = sorted(invs_expected)
test_framework.wait_until(lambda: sorted(self.txinvs) == expected_txinvs),

Copy link
Contributor Author

@theStack theStack Aug 4, 2020

Choose a reason for hiding this comment

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

Yes, that makes sense to do the sorting of the txinvs to test for only once. Did it with in-place sort of the passed list.

@theStack theStack force-pushed the 20200722-test-p2p_feefilter_improvements branch from 302388e to 2d43d84 Compare August 4, 2020 21:25
@theStack
Copy link
Contributor Author

theStack commented Aug 4, 2020

Rebased on master and added suggested changes by jonatack (only sort expected invs once, use correct terminology regarding noban permission terminology).

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

ACK 2d43d84

Restarted the stalled s390x Travis job.

Copy link
Member

Choose a reason for hiding this comment

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

c063dce9 nit: if you have to retouch, can remove "being" here and in line 87.

@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 6, 2020

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

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.

@theStack theStack force-pushed the 20200722-test-p2p_feefilter_improvements branch from 2d43d84 to ea74a3c Compare August 11, 2020 10:20
@theStack
Copy link
Contributor Author

Rebased.

@jonatack
Copy link
Member

re-ACK ea74a3c per git range-diff ce3bdd0e 2d43d84 ea74a3c

@laanwj laanwj requested review from instagibbs and maflcko August 12, 2020 18:33
Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

Looks fine, some style nits

4fbda7da50d508481d9a94b00e4dc994dad9465d

additionally:
    -> rename function with snake_case (s/allInvsMatch/wait_for_invs_to_match)
    -> move it from global namespace to the class FeefilterConn
…lay)

Most of the test time is spent in wait_for_invs() after sending to addresses,
i.e. the bottleneck is in relaying transactions. By whitelisting the peers via
-whitelist, the inventory is transmissioned immediately rather than on average
every 5 seconds, speeding up the test significantly:

before:
$ time ./p2p_feefilter.py
...
real    0m39.367s
user    0m1.227s
sys 0m0.571s

with this commit:
$ time ./p2p_feefilter.py
...
real    0m9.386s
user    0m1.120s
sys 0m0.577s
@theStack theStack force-pushed the 20200722-test-p2p_feefilter_improvements branch from ea74a3c to 9e78943 Compare August 12, 2020 23:39
@theStack
Copy link
Contributor Author

theStack commented Aug 12, 2020

Thanks for reviewing Marco. Force-pushed with your suggestions and a small log-message change proposed by jonatack previously (#19564 (comment)).

@instagibbs
Copy link
Member

code review ACK 9e78943

@jonatack
Copy link
Member

re-ACK 9e78943 per git range-diff 3ab2582 ea74a3c 9e78943

@maflcko maflcko merged commit a57af89 into bitcoin:master Aug 16, 2020
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 16, 2020
…toring, speedup)

9e78943 test: speedup p2p_feefilter.py by whitelisting peers (immediate tx relay) (Sebastian Falbesoner)
fe3f0cc test: use wait_until for invs matching in p2p_feefilter.py (Sebastian Falbesoner)
6d94192 test: add logging for p2p_feefilter.py (Sebastian Falbesoner)

Pull request description:

  This PR gives some love to the functional test `p2p_feefilter.py` by introducing the following changes:
  * add missing log messages for the `test_feefilter` subtest (the main one)
  * deduplicate code by using the utility function `wait_until` (already using the [recently introduced version](bitcoin@12410b1)) instead of a manual condition checking loop with `time.sleep`
  * improve naming of the function `matchAllInvs` (more expressive name, snake_case) and moving it from global namespace to the connection class `FeefilterConn`
  * speeding up the test significantly by the good ol' method of activating immediate tx relay (as seen on e.g. bitcoin#17121, bitcoin#17124, bitcoin#17340, bitcoin#17362, ...):
  ```
  master branch:
  $ time ./p2p_feefilter.py
  ...
  real    0m39.367s
  user    0m1.227s
  sys 0m0.571s

  PR branch:
  $ time ./p2p_feefilter.py
  ...
  real    0m9.386s
  user    0m1.120s
  sys 0m0.577s
  ```

ACKs for top commit:
  instagibbs:
    code review ACK bitcoin@9e78943
  jonatack:
    re-ACK 9e78943 per `git range-diff 3ab2582 ea74a3c 9e78943`

Tree-SHA512: fe21c1c5413df9165fea916b5d5f609d3ba33e7b5c3364b38eb824fcc55d9e6abddf27116cbc0b325913d451a73c44542040fb916aec9c46f805c6e12f6f10cf
@theStack theStack deleted the 20200722-test-p2p_feefilter_improvements branch December 1, 2020 09:58
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Sep 15, 2021
Summary:
> test: add logging for p2p_feefilter.py
bitcoin/bitcoin@6d94192

> test: use wait_until for invs matching in p2p_feefilter.py
>
> additionally:
>     -> rename function with snake_case (s/allInvsMatch/wait_for_invs_to_match)
>     -> move it from global namespace to the class FeefilterConn
bitcoin/bitcoin@fe3f0cc

> test: speedup p2p_feefilter.py by whitelisting peers (immediate tx relay)
>
> Most of the test time is spent in wait_for_invs() after sending to addresses,
> i.e. the bottleneck is in relaying transactions. By whitelisting the peers via
> -whitelist, the inventory is transmissioned immediately rather than on average
> every 5 seconds, speeding up the test significantly:
bitcoin/bitcoin@9e78943

This is a backport of [[bitcoin/bitcoin#19564 | core#19564]]

Test Plan:
before:
```
TEST             | STATUS    | DURATION

p2p_feefilter.py | ✓ Passed  | 29 s

ALL              | ✓ Passed  | 29 s (accumulated)
Runtime: 21 s
```

after:
```
TEST             | STATUS    | DURATION

p2p_feefilter.py | ✓ Passed  | 4 s

ALL              | ✓ Passed  | 4 s (accumulated)
```

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D10111
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 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.

6 participants