From b91ad83d432f58513299dc061cff7d6392d50047 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Tue, 24 Dec 2019 17:03:51 +0100 Subject: [PATCH] Minor speedup Use recv_bytes/send_bytes instead of recv/send where possible. This yields a bit less than 10% on my local benchmark, since the fuzzee and the fuzzers are saving one call to pickle's serialize/unserialize per cycle. I'm sure more performances could be obtained by changing the remaining recv/send calls, I might give it a try at some point. --- pythonfuzz/fuzzer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pythonfuzz/fuzzer.py b/pythonfuzz/fuzzer.py index acbe9d6..8cb8d8b 100644 --- a/pythonfuzz/fuzzer.py +++ b/pythonfuzz/fuzzer.py @@ -19,7 +19,7 @@ def worker(target, child_conn): cov = coverage.Coverage(branch=True, cover_pylib=True) cov.start() while True: - buf = child_conn.recv() + buf = child_conn.recv_bytes() try: target(buf) except Exception as e: @@ -87,9 +87,10 @@ def start(self): self._p = mp.Process(target=worker, args=(self._target, child_conn)) self._p.start() + while True: buf = self._corpus.generate_input() - parent_conn.send(buf) + parent_conn.send_bytes(buf) if not parent_conn.poll(self._timeout): self._p.kill() logging.info("=================================================================")