Repository navigation
Description
Part of #660.
Measured
tests/test_session_start_windows_benchmark_669.py's harness (tests/spawn_counting.py, counts execs) on main at 1c8301c, macOS, after #675, #676, #677 and #678 landed today:
| tree | jq present cold / warm | jq absent cold / warm |
|---|---|---|
| main this morning (v0.31.0 + #668 cache) | 76 / 39 | 93 / 76 |
| main now | 49 / 30 | 34 / 32 |
The 30 warm spawns on the jq-present path, by command (all foreground -- the harness runs the hook to exit; detached work never reaches the log):
rm -fx9 -- one exec per temp file (dispatch-timeout.*,dispatch-stderr.*,save-session.pid,capture-gap-skipped,session-start-stdin.*,session-start-ctx.*,remember-config-*x2, ...). Onerm -f a b cat exit, or[ -e ]-gated, is 1-2.catx5 (x9 jq-less) --session-history-hint.txt,start-context.cache,session-start-ctx.*,capture-alive,capture-gap-reported.$(<file)is a bash builtin read; zero exec.sedx2 strippingtrap -poutput (s/trap -- '//;s/' EXIT//) -- SessionStart: fork tax -- $(config) x13, lib-slug sed build x22, log's printf|tr -- replace with builtins (Part of #660) #665 named these and they are still there (a file it did not touch:lib-memory-dir.sh/bootstrap-dirs.shtrap plumbing). Parameter expansion does it.sedx1 building the slug (the UTF-8 byte-range program) -- one exec per start, could be skipped when the path is pure ASCII.statx2 -- GNU-cfails on macOS then BSD-fruns; 1 on Linux/Windows. Fine as is.sleep 1x1 -- the dispatcher's supervise watcher, forked+exec'd even for a hook child that exits in milliseconds (50-git-restore.sh with the feature off, the default). Gate the watcher on the budget actually being finite, or start it only after the child has outlived a firstkill -0check.mv -fx3,cpx1 -- the three-way config merge still copies/renames the merged config every start; the SessionStart: cache the injected context, the flattened config and the tool verdicts across starts, validated by mtime (Part of #660) #668 cache covers the flatten, not the merge. When only the bundledconfig.jsonexists (no user, no project config) the merge is acpthat could be a path assignment.dirnamex1,ls -tx1,mkdir -px1,trx1 (thelog()control-byte scrub SessionStart: fork tax -- $(config) x13, lib-slug sed build x22, log's printf|tr -- replace with builtins (Part of #660) #665 kept on purpose),git rev-parsex1,jqx1 (session_was_saved) -- one each.
jq-less only (the fresh Git for Windows default):
- the SessionStart: cache the injected context, the flattened config and the tool verdicts across starts, validated by mtime (Part of #660) #668 start-context cache does NOT hit: every warm start re-
catsidentity.md,core-memories.md,now.md,recent.md,archive.mdand runswc -con them -- 7 spawns the jq path no longer pays. Whatever the cache-validity check reads (an mtime list via$JQ?) is not answered by_jq_fallback, so it reads as "stale" every time. python3 -Vruns on every warm start -- the SessionStart: cache the injected context, the flattened config and the tool verdicts across starts, validated by mtime (Part of #660) #668 tools cache is not published on SessionStart: drop the unconditional python -V probe from the foreground path (Part of #660) #662's lazy resolve path, so the probe is redone each time the jq-less path first needs an interpreter.
Cost
Reasoned, not measured on Windows: 30 execs at blakeh8's own 50-200 ms per spawn under Git Bash is 1.5-6 s; the floor after the items above is ~10-12 spawns on both paths, ~0.5-2.4 s. The jq-less cache miss alone is 8 spawns that the jq path already does not pay.
Fix shape
One lane, hot path only, in this order of payoff: (1) make the start-context cache and the tools cache work on the jq-less path (positive control: jq masked off PATH, second start shows no cat identity.md and no python3 -V; negative: with the cache file deleted they run once); (2) $(<file) for every cat on the path; (3) one rm -f at exit for the temp files, or gate on -e; (4) trap -p strip via parameter expansion; (5) the sleep 1 watcher gated on a finite budget. Pin the result with the existing benchmark budgets (JQ_PRESENT_WARM_SPAWN_BUDGET and the jq-absent twin in tests/test_session_start_windows_benchmark_669.py), lowered to the new number.
[AI-generated]
Activity
Skip the coreutils-spawn assertions on win32: Git/bin/bash.exe prepen…
SessionStart warm-path: fix the #679 benchmark harness, remove real p…
fix(#722,#724,#726): update the byte-pin guard's stale sanctioned-div…
fix(#722,#724,#726): escape placeholder tokens, sandbox the nested su…
Self-review round 2 for #1051: zero-cost cache-served start, no marker
Fix #1051: apply the session_start_max_bytes budget even on a day rol…