Skip to content

Fix #660: measure Windows SessionStart warm start via CI, confirm it already resolved - #1096

Merged
fdaviddpt merged 4 commits into
mainfrom
fix/660
Nov 1, 2026
Merged

fdaviddpt merged 4 commits into
mainfrom
fix/660

Conversation

@fdaviddpt

@fdaviddpt fdaviddpt commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

#660 was opened on a ~12.5s average SessionStart hook latency on Windows/Git
Bash, measured on v0.29.1. The issue's own long comment thread shows several
rounds of fork-count reductions (#661, #679, #842, #1069,
#1079/#1060/#1086) and several independent Windows re-measurements, the most
recent (kheirou, 2026-10-22) finding "no single slow step" left in the hook
and a ~1.4-1.6s hook-only time once jq is installed.

This PR does not change the hook. It strengthens #669's existing benchmark
(tests/test_session_start_windows_benchmark_669.py, which already drives
the real hook under real Git Bash on every windows-latest CI leg) in two
ways, then uses the strengthened benchmark's own CI output to answer #660
with a real, CI-measured number instead of a comment-thread estimate:

  1. Median of 3 warm runs, not one sample -- a single warm run is one
    shared-runner noise sample, matching how the issue's own re-measurement
    comments got a usable number by hand ("median of 5-7 runs").
  2. A real bug in Windows benchmark numbers are invisible in a passing CI run: emit them to the job summary (Part of #660, follow-up to #669) #673's own design: the benchmark's summary line was
    printed to both stdout and stderr specifically so it "reaches a log that
    shows even when the run is green" -- but pytest's default capture mode
    intercepts a direct stderr write during every test, pass or fail, and
    only replays it on FAILURE. The summary never actually reached CI's own
    job log on a passing run. Fixed with capfd.disabled(), pytest's own
    documented escape hatch, with a standalone regression test
    (test_benchmark_summary_line_survives_capture_660) proving the
    mechanism via a nested pytest subprocess with a positive/negative
    control pair.

The real numbers (observed, this PR's own windows-latest CI run, all

4 Python versions, run #41326677982)

scenario cold warm (median of 3)
jq present 1.59-1.87s 1.35-1.58s
jq absent 1.44-1.68s 1.03-1.30s

Consistent across Python 3.9/3.10/3.11/3.12 on windows-latest, and
consistent with the issue thread's own most recent independent
re-measurements. No single step dominates, matching erdogan-deniz's and
kheirou's own findings. This is well under a couple of seconds, and well
under the ~12.5s this issue was opened on.

Decision

Closing #660: the fork-reduction work landed in earlier releases
(#661/#679/#842/#1069/#1079/#1060/#1086) already fixed this, and this PR's
own CI run is the first time the repo has measured and reported that fact
from CI itself rather than from a comment-thread estimate. The strengthened
benchmark stays in place as an ongoing regression guard (spawn-count budgets
unchanged; the existing 45s wall-clock ceiling catches a genuine hang, by
design -- see the file's own module docstring for why wall time is reported
rather than tightly gated).

Changelog fragment added: changelog.d/660.fixed.md.

One adjacent finding, not fixed here (filed separately recommended)

The spawn-count shim (tests/spawn_counting.py) reported only 3-4 spawns
for the jq-present scenario and 0-3 for jq-absent on every windows-latest
leg in this PR's own CI run -- far below both the spawn budgets (90/150)
and this file's own OBSERVED macOS baseline (43 cold / 24 warm) in its
module docstring. The wall-clock numbers above are real and were read
directly off the job log, but the LOW spawn counts suggest the shim is not
actually intercepting most real subprocess calls on this Windows runner
image (most likely cause: shim PATH-prefix resolution not matching how Git
Bash resolves commands under windows-latest's current image), which would
mean the spawn-count budget assertions are not actually exercising most of
what they are meant to catch on Windows specifically, even though they pass.
Worth its own investigation; not attempted here since it is a different
mechanism (counting, not timing) and risks widening this PR's blast radius
well past #660's own ask.

Test plan

  • pytest tests/test_session_start_windows_benchmark_669.py locally
    (darwin): 8 passed.
  • python3 .oss/assemble_changelog.py --check: ok.
  • This PR's own windows-latest CI run (4 Python versions): all green,
    real numbers read directly from the job logs (see table above).

Closes #660

[AI-generated]

fdaviddpt and others added 4 commits November 1, 2026 16:26
#669's benchmark already prints a cold/warm wall-clock table (step
summary + record_property) on every windows-latest CI leg, but each
scenario took exactly one warm sample -- one shared-runner noise
sample, not a number. The issue's own re-measurement thread
(kheirou, erdogan-deniz) got a usable number by hand only by running
several times and taking the median.

Run the warm half WARM_RUN_COUNT (3) times per scenario and report
the median, with every individual run's time/spawn-count printed
alongside it, so a reader sees both the summary number and the raw
samples it came from. Cold stays a single sample -- it can only be
genuinely cold once per scenario, since that run is what populates
the #668 caches whose absence it measures. Spawn-count budgets are
unchanged (still read off one run; the count is deterministic by
code path, not something averaging helps with).

Verified locally (darwin): cold 1.78s/40 spawns, warm median
0.097s/26 spawns over 3 runs (0.102s, 0.097s, 0.090s) -- consistent
with the file's own existing OBSERVED-here numbers.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Discovered while reading this PR's own windows-latest CI job log for
the median numbers the previous commit added: a grep for the benchmark
summary line found zero matches on a leg where both benchmark tests
passed, contradicting #673's own stated design ("stderr ... reaches a
log that shows even when the run as a whole is green").

The reason: pytest's default capture mode ("fd") redirects the real
OS file descriptors 1 and 2 for the duration of every test, pass or
fail, and only replays what it caught if the test fails (or -rA/-s is
passed). print(file=sys.stderr) is a direct write() to fd 2, so it was
captured right along with stdout and simply discarded on a green run
-- the "prints to both streams" design never actually worked for the
case it exists for.

Wrap the two summary prints in `capfd.disabled()`, pytest's own
documented escape hatch for exactly this. Added a standalone
pytester-based regression test (test_benchmark_summary_line_survives_
capture_660) that drives the real fixture through a nested pytest
subprocess with a positive/negative control pair, independent of the
heavy hook-driving fixtures the rest of this file needs -- so this
mechanism stays pinned even if the real hook benchmark is ever
skipped or slow to iterate on.

Verified locally: `pytest tests/test_session_start_windows_benchmark_669.py::test_session_start_hook_benchmark_with_jq_present -q`
(no -s) now prints the real "#669 benchmark [...]" summary line to the
terminal on a passing run; before this commit it printed nothing.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Added after reading this PR's own windows-latest CI run (4 Python
versions, all green): warm median 1.0-1.6s, no single dominant step
left, consistent with the issue thread's own most recent independent
re-measurements (kheirou, erdogan-deniz). Plain-language entry per
.oss.json's changelog_dir convention; passes
.oss/assemble_changelog.py --check.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@fdaviddpt fdaviddpt changed the title Report #660 Windows SessionStart warm start as a median of several runs Fix #660: measure Windows SessionStart warm start via CI, confirm it already resolved Nov 1, 2026
@fdaviddpt
fdaviddpt merged commit 71557f9 into main Nov 1, 2026
19 checks passed
@fdaviddpt
fdaviddpt deleted the fix/660 branch November 1, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SessionStart hook averages ~12.5s on Windows (Git Bash) — measured over 36 session starts on v0.29.1

1 participant