Skip to content

[Fuzzing] Use random.randbytes in fuzz_opt.py - #9332

Merged
tlively merged 1 commit into
mainfrom
fuzzer-throughput-randbytes
Oct 31, 2026
Merged

tlively merged 1 commit into
mainfrom
fuzzer-throughput-randbytes

Conversation

@tlively

@tlively tlively commented Oct 31, 2026

Copy link
Copy Markdown
Member

make_random_input() previously generated random bytes using a Python list comprehension calling random.randint(0, 255) up to 200,000 times per input file (~18.5ms average per call). Replace this loop with random.randbytes(input_size) (~0.3ms average per call, ~50x faster).

Steady-state throughput increases by +7.8% (3.08 -> 3.32 iters/s) for a single worker and +7.4% (81.78 -> 87.85 iters/s) across 32 parallel workers.

make_random_input() previously generated random bytes using a Python list comprehension calling random.randint(0, 255) up to 200,000 times per input file (~18.5ms average per call). Replace this loop with random.randbytes(input_size) (~0.3ms average per call, ~50x faster).

Steady-state throughput increases by +7.8% (3.08 -> 3.32 iters/s) for a single worker and +7.4% (81.78 -> 87.85 iters/s) across 32 parallel workers.
@tlively
tlively requested a review from a team as a code owner October 31, 2026 03:10
@tlively
tlively requested review from stevenfontanella and removed request for a team October 31, 2026 03:10

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the make_random_input function in scripts/fuzz_opt.py to use random.randbytes instead of a list comprehension with random.randint, which simplifies the code and improves performance. There are no review comments to address, and I have no further feedback to provide.

@tlively
tlively merged commit 677ad31 into main Oct 31, 2026
17 checks passed
@tlively
tlively deleted the fuzzer-throughput-randbytes branch October 31, 2026 19:37
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