Repository navigation
Merged
Conversation
#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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 drivesthe real hook under real Git Bash on every
windows-latestCI leg) in twoways, then uses the strengthened benchmark's own CI output to answer #660
with a real, CI-measured number instead of a comment-thread estimate:
shared-runner noise sample, matching how the issue's own re-measurement
comments got a usable number by hand ("median of 5-7 runs").
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 owndocumented escape hatch, with a standalone regression test
(
test_benchmark_summary_line_survives_capture_660) proving themechanism via a nested pytest subprocess with a positive/negative
control pair.
The real numbers (observed, this PR's own
windows-latestCI run, all4 Python versions, run #41326677982)
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 spawnsfor 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 wouldmean 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.pylocally(darwin): 8 passed.
python3 .oss/assemble_changelog.py --check: ok.windows-latestCI run (4 Python versions): all green,real numbers read directly from the job logs (see table above).
Closes #660
[AI-generated]