Skip to content

Commit 677ad31

Browse files
authored
[Fuzzing] Use random.randbytes in fuzz_opt.py (#9332)
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.
1 parent a6ed9ad commit 677ad31

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎scripts/fuzz_opt.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def random_size():
114114

115115
def make_random_input(input_size, raw_input_data):
116116
with open(raw_input_data, 'wb') as f:
117-
f.write(bytes([random.randint(0, 255) for x in range(input_size)]))
117+
f.write(random.randbytes(input_size))
118118

119119

120120
def run(cmd, stderr=None, silent=False):

0 commit comments

Comments
 (0)