From 7e40bb138cc46245f7efd6544a446df1a65644e7 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Fri, 16 Oct 2026 14:55:18 +0200 Subject: [PATCH] ci_mirror: build the clean venv with uv (18.3 s -> 2.1 s cold) The venv rebuild after a requirements.txt change was the largest cold-path cost of `scripts/check_gate_stamp.sh full`. uv is also what CI installs with, so the mirror gets closer to CI, not further. The interpreter is passed as a path: `--python python3` let uv pick an active ~/.venv (3.13) that crdt-sync 0.9.2 (>=3.14) cannot install into. pip stays as fallback. Measured under capped.sh (4G, 20 %): `full` warm 10.9 s; fully cold (no venv, empty PRE_COMMIT_HOME, empty mypy cache) 45.9 s, floor = the pylint hook env install (~24 s, only after .pre-commit-config.yaml changes). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Xfj1sxKH9VBPqpcAni8Jry --- scripts/ci_mirror.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/ci_mirror.sh b/scripts/ci_mirror.sh index 4c8908a..0ef0546 100755 --- a/scripts/ci_mirror.sh +++ b/scripts/ci_mirror.sh @@ -64,6 +64,20 @@ ensure_venv() { log "requirements.txt changed — rebuilding clean venv (mirrors CI install)" rm -rf "$VENV_DIR" + # uv is what CI installs with (`uv pip install -r`), and it rebuilt this + # venv in 2.1 s where venv + pip took 18.3 s (2026-10-16) -- the largest + # cold-path cost of `check_gate_stamp.sh full`. pip stays as the fallback. + if command -v uv >/dev/null 2>&1; then + # A PATH, not the bare name: `--python python3` let uv prefer an + # active ~/.venv (3.13) over the python3 the pip path would use. + uv venv --quiet --python "$(command -v python3)" "$VENV_DIR" \ + || fail "uv venv for the clean venv" + uv pip install --quiet --python "$VENV_DIR/bin/python" -r "$REQ_PATH" \ + || fail "uv pip install -r $REQUIREMENTS_FILE (a dep may be undeclared)" + printf '%s' "$current" > "$HASH_FILE" + log "clean venv ready (uv)" + return + fi python3 -m venv "$VENV_DIR" "$VENV_DIR/bin/python" -m pip install --quiet --upgrade pip \ || fail "pip self-upgrade in the clean venv"