test: reduce runtime of p2p_opportunistic_1p1c.py #33048

pull glozow wants to merge 2 commits into bitcoin:master from glozow:2025-07-oppo-fast changing 1 files +35 −24
  1. glozow commented at 7:23 pm on July 23, 2025: member

    It was brought to my attention that the runtime of this test is Too Damn High. The test is slow due to the many wait_for_getdatas with delays (inbound peer + txid request) and the large volume of messages sent in the dos-related tests. This PR cuts the runtime by about 60% by reducing the number of messages/transactions and using setmocktime instead of waiting.

    On my machine, master:

    084.51s user 1.55s system 57% cpu 2:28.53 total
    

    After first commit (about 1min faster):

    028.29s user 0.88s system 35% cpu 1:22.84 total
    

    After second commit (about 30sec faster):

    028.17s user 0.87s system 59% cpu 49.082 total
    

    Reviewers should verify that the transactions in the DoS tests are still enough to cause evictions, and that the bumpmocktime amounts are not more than necessary.

    Alternatives:

    • If we don’t like mocking the times, we can use outbound connections for all the peers. However, that approach won’t improve the runtime as much because we impose a 2-second delay on all txid requests regardless of peer type.
    • Note that noban_tx_relay is not relevant for this test because all delays are related to downloading, not announcing.
  2. [test] cut the number of transactions involved in 1p1c DoS tests
    We just need enough transactions to push us above the orphanage limits
    and trigger trimming. Reducing the number of transactions cuts the
    runtime of this test significantly.
    70772dd469
  3. [test] setmocktime instead of waiting in 1p1c tests
    Significantly speed up the runtime of the test.
    eb65f57f31
  4. glozow added the label Tests on Jul 23, 2025
  5. DrahtBot commented at 7:24 pm on July 23, 2025: contributor

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

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33048.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK achow101, w0xlt

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  6. glozow force-pushed on Jul 23, 2025
  7. glozow commented at 7:25 pm on July 23, 2025: member
  8. achow101 commented at 8:57 pm on July 23, 2025: member

    The runtime is now much better, thanks!

    ACK eb65f57f319dc4e2ea8c83cf7e283c36f1c0d53b

    I checked that the changes looked sane, but did not exhaustively walkthrough the scenarios to determine whether evictions were occurring.

  9. w0xlt commented at 8:51 pm on July 24, 2025: contributor

    ACK https://github.com/bitcoin/bitcoin/pull/33048/commits/eb65f57f319dc4e2ea8c83cf7e283c36f1c0d53b

    On my machine, master: 43 s This PR: 27 s

    Even reducing the number of transactions and peer connections used in the DoS portions of the test, it still fills the orphan pool past its limit, ensuring that evictions occur. The use of mock time also makes the test more deterministic.

  10. fanquake merged this on Aug 1, 2025
  11. fanquake closed this on Aug 1, 2025


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-08-12 09:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me