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

fuzz: Speed up *_package_eval fuzz targets a bit #31457

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Dec 10, 2024

Each target is at least 10% faster for me when running over the current set of qa-assets, which seems nice.

@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 10, 2024

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/31457.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

@DrahtBot DrahtBot added the Tests label Dec 10, 2024
@@ -195,8 +195,8 @@ FUZZ_TARGET(ephemeral_package_eval, .init = initialize_tx_pool)
MockTime(fuzzed_data_provider, chainstate);

// All RBF-spendable outpoints outside of the unsubmitted package
std::set<COutPoint> mempool_outpoints;
std::map<COutPoint, CAmount> outpoints_value;
std::unordered_set<COutPoint, SaltedOutpointHasher> mempool_outpoints;
Copy link
Member

Choose a reason for hiding this comment

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

Using a SaltedOutpointHasher probably requires to call SeedRandomStateForTest(SeedRand::ZEROS) each iteration. Otherwise non-determinism might happen due to e.g. different order when iterating over the sets.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch. This means:

  • Other tests may also need a re-seed on every iteration, if they interact with data, sorted by a salted hasher
  • The speed-up may actually come from invalidating the fuzz inputs, making a change like this harder to test

@maflcko maflcko marked this pull request as draft December 10, 2024 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants