From 592a3e937bcbba3358d85118189648d497edaeac Mon Sep 17 00:00:00 2001 From: MSCodeBase Agent Date: Sat, 26 Sep 2026 11:34:28 +0300 Subject: [PATCH] perf(dev): run the gate-zero suite in parallel in verify_diary verify_diary runs the full suite on every commit (pre-commit) and it was serial (~200-360s locally). Gate-zero now adds `-n auto` when pytest-xdist is importable, falling back to serial otherwise, so the gate keeps working in a minimal environment. The selection is unchanged (pyproject addopts keep -m 'not slow and not benchmark'); measured 197s -> 71s locally. --- scripts/verify_diary.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/verify_diary.py b/scripts/verify_diary.py index df541be0..950cc58c 100644 --- a/scripts/verify_diary.py +++ b/scripts/verify_diary.py @@ -439,8 +439,22 @@ def gate_zero_full_suite() -> Tuple[bool, str]: # писали записи tmp-файлов (a.py) в индекс коммита → «invalid object ... for # 'a.py'» при построении дерева partial-коммита. Санируем GIT_* для pytest. env = {k: v for k, v in os.environ.items() if not k.startswith("GIT_")} + # -n auto (pytest-xdist, dev dep): the selection is unchanged (pyproject + # addopts keep -m 'not slow and not benchmark'); only spread across + # cores — measured 197s -> 71s locally. Falls back to serial when xdist + # is not installed (minimal env), so the gate never breaks on a missing + # optional tool. + pytest_cmd = [ + sys.executable, "-m", "pytest", "tests/", + "-q", "--tb=line", "--no-header", + ] + try: + import xdist # noqa: F401 + pytest_cmd += ["-n", "auto"] + except ImportError: + pass proc = subprocess.Popen( - [sys.executable, "-m", "pytest", "tests/", "-q", "--tb=line", "--no-header"], + pytest_cmd, cwd=str(ROOT), stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,