test: Add arguments for creating a slimmer TestingSetup #30399

pull TheCharlatan wants to merge 2 commits into bitcoin:master from TheCharlatan:noNetChainTest changing 4 files +18 −8
  1. TheCharlatan commented at 9:08 PM on July 5, 2024: contributor

    This adds arguments to some of the testing setup constructors for creating an environment without networking and a validation interface. This is useful for improving the performance of the utxo snapshot fuzz test, which constructs a new TestingSetup on each iteration.

    Using this slimmed down TestingSetup in future might also make the tests a bit faster when run in aggregate.

  2. DrahtBot commented at 9:08 PM on July 5, 2024: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK maflcko, dergoegge
    Concept ACK brunoerg, BrandonOdiwuor

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    No conflicts as of last run.

  3. DrahtBot added the label Tests on Jul 5, 2024
  4. in src/test/fuzz/utxo_snapshot.cpp:40 in 049719b385 outdated
      36 | +        /*chain_type*/ ChainType::REGTEST,
      37 | +        /*extra_args*/ AddNoLogArgs({}),
      38 | +        /*coins_db_in_memory*/ true,
      39 | +        /*block_tree_db_in_memory*/ true,
      40 | +        /*setup_net*/ false,
      41 | +        /*setup_validation_interface*/ false)};
    


    maflcko commented at 1:58 PM on July 8, 2024:

    some notes:

    • make_unique code is not checked via clang-tidy named args.
    • Listing all options that are not changed from the default seems verbose and brittle.

    See #30407 for a fix.


    fanquake commented at 4:22 PM on July 15, 2024:

    #30407 is now merged.

  5. maflcko commented at 1:58 PM on July 8, 2024: member

    Concept ACK. Thanks!

  6. brunoerg commented at 2:14 PM on July 8, 2024: contributor

    Concept ACK

  7. DrahtBot added the label Needs rebase on Jul 15, 2024
  8. TheCharlatan force-pushed on Jul 19, 2024
  9. TheCharlatan commented at 11:12 AM on July 19, 2024: contributor

    Rebased 049719b3858f2ae88cc2752ffe240b667c3d2996 -> 598dd9c3df8afbab92f706e1d4ce72bd3fa83e95 (noNetChainTest_0 -> noNetChainTest_1, compare)

    • Fixed conflict with #30407 , and adapted commit changes to use the new options
  10. test: Add arguments for creating a slimmer setup
    Adds more testing options for creating an environment without networking
    and a validation interface. This is useful for improving the performance
    of the utxo snapshot fuzz test, which constructs a new TestingSetup on
    each iteration.
    9e2a723d5d
  11. fuzz: Use BasicTestingSetup for coins_view target f46b220256
  12. in src/test/fuzz/utxo_snapshot.cpp:38 in 598dd9c3df outdated
      30 | @@ -31,7 +31,14 @@ void initialize_chain()
      31 |  FUZZ_TARGET(utxo_snapshot, .init = initialize_chain)
      32 |  {
      33 |      FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
      34 | -    std::unique_ptr<const TestingSetup> setup{MakeNoLogFileContext<const TestingSetup>()};
      35 | +    std::unique_ptr<const TestingSetup> setup{
      36 | +        MakeNoLogFileContext<const TestingSetup>(
      37 | +            ChainType::REGTEST,
      38 | +            TestOpts{
      39 | +                .extra_args = AddNoLogArgs({}),
    


    maflcko commented at 11:16 AM on July 19, 2024:

    Looks like this is called twice, no?

  13. TheCharlatan force-pushed on Jul 19, 2024
  14. TheCharlatan commented at 11:41 AM on July 19, 2024: contributor

    Updated 598dd9c3df8afbab92f706e1d4ce72bd3fa83e95 -> f46b2202560a76b473e229b77303b8f877c16cac (noNetChainTest_1 -> noNetChainTest_2, compare)

    • Addressed @maflcko's comment, removed redundant call for adding the no log argument.
  15. DrahtBot removed the label Needs rebase on Jul 19, 2024
  16. maflcko commented at 12:14 PM on July 19, 2024: member

    review ACK f46b2202560a76b473e229b77303b8f877c16cac

    Seems fine to do. I haven't benchmarked this commit, but I expect the peak memory usage of the coins_view fuzz target to go down. Also, the utxo_snapshot fuzz target may be faster and use less peak memory.

    (When I benchmarked an earlier version of this, I didn't find a significant speedup, but I may have done something wrong and the changes here seem useful either way)

  17. DrahtBot requested review from brunoerg on Jul 19, 2024
  18. BrandonOdiwuor commented at 5:12 PM on July 19, 2024: contributor

    Concept ACK

  19. brunoerg commented at 1:27 PM on July 23, 2024: contributor

    (When I benchmarked an earlier version of this, I didn't find a significant speedup, but I may have done something wrong and the changes here seem useful either way)

    Same here. The changes lgtm but I tried to benchmark it and I didn't see any significant improvement. Not sure if I did it right.

  20. maflcko commented at 4:01 PM on July 23, 2024: member

    Upgrading my review with a test:

    • FUZZ=utxo_snapshot /usr/bin/time --format='%MKB' ./src/test/fuzz/fuzz -runs=1 ../b-c-qa-assets/fuzz_seed_corpus/utxo_snapshot/ gives: 2MB less peak memory (~1%) and 600 less cov (~10%) (which is desired here, to avoid reporting non-fuzzing coverage in a fuzz target) and no speedup/slowdown
    • Same for FUZZ=coins_view gives: 50MB less peak memory (~25%) and no other change

    lgtm

  21. fanquake requested review from dergoegge on Jul 23, 2024
  22. in src/test/util/setup_common.h:55 in f46b220256
      51 | @@ -52,6 +52,8 @@ struct TestOpts {
      52 |      std::vector<const char*> extra_args{};
      53 |      bool coins_db_in_memory{true};
      54 |      bool block_tree_db_in_memory{true};
      55 | +    bool setup_net{true};
    


    dergoegge commented at 4:16 PM on July 23, 2024:

    nit: A bit weird that this will be available as an option on all testing setups when only TestingSetup and it's derived classes care about it.


    maflcko commented at 4:22 PM on July 23, 2024:

    I did this on purpose when adding TestOpts, because deriving a nested stack of TestOpt classes would make designated initializers harder, something like { { { .inner = true } }, .outer = false}, instead of just { .inner = true , .outer = false}. (Not sure if there were also compiler warnings in the first case)

  23. dergoegge approved
  24. dergoegge commented at 4:17 PM on July 23, 2024: member

    utACK f46b2202560a76b473e229b77303b8f877c16cac

  25. DrahtBot requested review from BrandonOdiwuor on Jul 23, 2024
  26. maflcko commented at 11:13 AM on July 25, 2024: member

    test-only pull with two ACKs, rfm?

  27. fanquake merged this on Jul 25, 2024
  28. fanquake closed this on Jul 25, 2024

  29. bitcoin locked this on Jul 25, 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: 2026-04-15 15:13 UTC

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