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

pkg/fuzzer: use a MAB to decide on exec fuzz vs exec gen #4632

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

a-nogikh
Copy link
Collaborator

@a-nogikh a-nogikh commented Apr 2, 2024

I'm currently running experiments to see whether it brings any fuzzing performance improvements.


Cc #1950

Let's try to use a plain delta-epsylon MAB for this purpose.

To better track its effect, also calculate moving averages of the "new max signal" / "execution time" ratios for exec fuzz and exec gen.

Copy link

codecov bot commented Apr 2, 2024

Codecov Report

Attention: Patch coverage is 91.66667% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 62.1%. Comparing base (b90978b) to head (dbd3f2d).

Additional details and impacted files
Files Coverage Δ
pkg/fuzzer/stats.go 100.0% <100.0%> (ø)
pkg/ipc/ipc.go 52.5% <100.0%> (+0.4%) ⬆️
pkg/fuzzer/fuzzer.go 85.2% <97.6%> (+3.4%) ⬆️
syz-manager/http.go 0.0% <0.0%> (ø)
pkg/learning/mab.go 94.4% <94.4%> (ø)
pkg/learning/window.go 90.3% <90.3%> (ø)
syz-manager/rpc.go 0.0% <0.0%> (ø)

... and 1 file with indirect coverage changes

Let's try to use a plain delta-epsylon MAB for this purpose.

To better track its effect, also calculate moving averages of the
"new max signal" / "execution time" ratios for exec fuzz and exec gen.
@a-nogikh a-nogikh changed the title WIP: pkg/fuzzer: use MAB to distinguish between exec fuzz and exec gen pkg/fuzzer: use a MAB to decide on exec fuzz vs exec gen Apr 3, 2024
@a-nogikh a-nogikh marked this pull request as ready for review April 3, 2024 09:42
Extra CallInfo // stores Signal and Cover collected from background threads
Calls []CallInfo
Extra CallInfo // stores Signal and Cover collected from background threads
ElapsedSec float64 // total execution time in seconds
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would store this as time.Duration. Floats are pretty specific thing, if something wants floats (learning), it should convert the standard time to floats.
Also if we add per-syscall execution time, storing it as seconds will be somewhat strange since most syscalls execute within microseconds.

@a-nogikh
Copy link
Collaborator Author

a-nogikh commented Apr 3, 2024

Okay, this particular approach will likely not work well because the "new signal / execution time" ratio can have a pretty large range of values. The bounded learning rate, even being as small as 0.0005, would not cope with extreme outliers.

I'm currently testing how useful it may be if we just look at the probability of generating any new coverage. This is the easiest implementation-wise.

The "new signal / execution time" ratio itself still sounds like a much better target, but we need to map it to a smaller range of values to use as a reward for a MAB. Perhaps keep some history of values of the last N "new signal / execution time" values and see what share of them is less than the current observed value? Then it would nicely map to [0;1].

The only caveat is that if N is large, we might need some tricky data structures to determine this rate efficiently (balanced trees should be able do it in O(log N), not sure if we can do it better?).

@dvyukov
Copy link
Collaborator

dvyukov commented Apr 3, 2024

Maybe we could map coverage and execution time to some logarithmic buckets: 1, 10, 100, or finer-grained 1,2,5,10,20,50,100...?
Also amount of coverage may be very different for different syscalls, some may give some huge chunks of coverage, and some just few coverage points.

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