Skip to content

Fuzzer: Adjust parameters by input size, sometimes#7276

Merged
kripken merged 12 commits intoWebAssembly:mainfrom
kripken:fuzz.adapt
Feb 14, 2025
Merged

Fuzzer: Adjust parameters by input size, sometimes#7276
kripken merged 12 commits intoWebAssembly:mainfrom
kripken:fuzz.adapt

Conversation

@kripken
Copy link
Copy Markdown
Member

@kripken kripken commented Feb 5, 2025

Rather than always have a fixed max of heap types, globals, etc. allow more if the
input size is large. This adds variety.

There is a cost to this variety, we go from 0.89% ignored runs to 1.1% (that is,
slightly more runs contain something that prevents us from doing the work
we want, like hitting a host limitation or seeing the testcase just traps). This
increase seems small enough to be reasonable, and we only do this half the
time, so the old behavior is still being tested at half throughput.

@kripken kripken requested a review from tlively February 5, 2025 18:28
Comment thread src/tools/fuzzing/fuzzing.cpp Outdated
// A typical random wasm input from fuzz_opt.py is fairly large (to minimize
// the process creation overhead of all the things we run from python), and
// the defaults are tuned to that.
double size = random.remaining();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why does random.remaining() correspond to the input size? This seems non-obvious, so perhaps is worth a comment.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I added a comment. We didn't read anything yet, so the remaining is the initial.

// the process creation overhead of all the things we run from python), and
// the defaults are tuned to that.
double size = random.remaining();
const double MEAN_SIZE = 40 * 1024;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this number taken from measurements? Do we expect it to change much over time? (Not that it would matter much if it did.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This corresponds to the mean size from fuzz_opt.py. I added a comment.

Comment thread src/tools/fuzzing/fuzzing.cpp Outdated

auto bits = random.get();
if (bits & 1) {
fuzzParams->MAX_NEW_GC_TYPES = fuzzParams->MAX_NEW_GC_TYPES * ratio;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we use *= ratio here and below?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done. For some reason I thought int *= double might coerce the rhs to int first...

Comment thread src/tools/fuzzing/fuzzing.cpp Outdated
// Only increase the number of tries. Trying fewer times does not help
// find more interesting patterns.
if (ratio > 1) {
fuzzParams->TRIES = fuzzParams->TRIES * ratio;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we give TRIES a more descriptive name?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hmm, I can't think of one. This is "number of tries we make, when we have something that might work or might fail". What do you suggest?

@kripken kripken merged commit d9fa84a into WebAssembly:main Feb 14, 2025
@kripken kripken deleted the fuzz.adapt branch February 14, 2025 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants