From cda76194a468d55f713b84fd25eb808dab0ebd5e Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Fri, 23 Oct 2026 18:28:49 -0700 Subject: [PATCH] [Fuzzing] Default BINARYEN_CORES=4 in fuzz_opt.py Every wasm-opt, wasm-merge, wasm-ctor-eval, and wasm-metadce subprocess spawned by fuzz_opt.py initializes a Binaryen ThreadPool sized to hardware_concurrency() (e.g. 128 threads on a 128-core workstation) and synchronizes across condition variables for each function-parallel pass. On small fuzzer modules, thread creation and barrier synchronization dominate execution time and cause severe contention when running multiple fuzzer workers in parallel. Default BINARYEN_CORES to 4 so parallel pass execution is still exercised without spawning a thread per hardware core in every subprocess. Steady-state throughput increases by +97.7% (1.37 -> 2.71 iters/s, 1.98x) for a single worker and +186.4% (25.77 -> 73.78 iters/s, 2.86x) across 32 parallel workers on a 128-thread machine. --- scripts/fuzz_opt.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py index c97d9cb252e..05b57a5d12d 100755 --- a/scripts/fuzz_opt.py +++ b/scripts/fuzz_opt.py @@ -49,6 +49,10 @@ assert sys.version_info >= (3, 10), 'requires Python 3.10' +# Limit default thread pool size per subprocess so parallel passes are still +# exercised without spawning a thread per hardware core on every invocation. +os.environ.setdefault('BINARYEN_CORES', '4') + # parameters # feature options that are always passed to the tools.