diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index a54b7163d3f6..7db931f521d3 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -71,6 +71,15 @@ echo " (TZ=UTC LANG=C.UTF-8 PYTHONHASHSEED=0; clean env)" cd "$REPO_ROOT" +# ── Pre-compile .pyc bytecode cache ───────────────────────────────────────── +# Each test file runs in its own subprocess via run_tests_parallel.py. +# Pre-building the bytecode cache once here (instead of each subprocess +# compiling on first import) avoids redundant work across ~2000 processes. +# Uses git to list tracked .py files (skips venv, node_modules, etc). +echo "▶ pre-compiling bytecode cache" +"$PYTHON" -m compileall -q -j 0 -- $(git ls-files '*.py') >/dev/null 2>&1 || true + +echo "▶ launching test runner" exec env -i \ PATH="$PATH" \ HOME="$HOME" \ @@ -78,7 +87,6 @@ exec env -i \ LANG=C.UTF-8 \ LC_ALL=C.UTF-8 \ PYTHONHASHSEED=0 \ - PYTHONDONTWRITEBYTECODE=1 \ ${HERMES_RUN_SLOW_PET_TESTS:+HERMES_RUN_SLOW_PET_TESTS="$HERMES_RUN_SLOW_PET_TESTS"} \ ${EXTRA_PYTHONPATH:+PYTHONPATH="$EXTRA_PYTHONPATH"} \ ${EXTRA_PYTEST_PLUGINS:+PYTEST_PLUGINS="$EXTRA_PYTEST_PLUGINS"} \ diff --git a/scripts/run_tests_parallel.py b/scripts/run_tests_parallel.py index b9cf5a97e15b..602e033f3d6d 100755 --- a/scripts/run_tests_parallel.py +++ b/scripts/run_tests_parallel.py @@ -260,8 +260,7 @@ def _run_one_file( stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, - # skipping writing bytecode because we're running a bunch of parallel python processes on the same code - env={**os.environ, 'PYTHONDONTWRITEBYTECODE': '1'}, + env=os.environ, # POSIX: place the child at the head of its own process group so # _kill_tree can SIGKILL the group atomically. # Windows: this maps to CREATE_NEW_PROCESS_GROUP in CPython 3.12+;