Repository navigation
Description
Summary
Follow-up to #227 (closed). On Windows Git Bash, user-prompt-hook.sh in 0.21.0 still costs a p50 of ~2.5s and a max of ~31s on every prompt — the env-cache fast path is being taken, but the residual per-prompt work is still expensive on this platform under memory pressure.
#227 fixed the cold 27-process resolve chain. What remains is the warm path: sourcing lib-clock.sh + lib-env-cache.sh, the CTX=$( … ) command substitution, and the _remember_who / read CTX_PCT / dispatch sub-shells. Each $( … ) is a fork + Git Bash subshell — a few ms on Linux, but 50–300ms each on Windows Git Bash, and worse when the box is swapping.
Environment
- Windows 11, Claude Code in Git Bash (bash 5.x, so
printf '%(…)T'is used — the clock itself is not a fork) remember0.21.0, storage modelegacy(in-project.remember)- Box under sustained memory pressure (large Docker workload; frequent swap) — every
fork()is slow here doctor.shoutput, relevant lines:WARN jq: not found — using the python fallback (slower, single-key reads only)OK python: python3 -> …/AppData/Local/Microsoft/WindowsApps/python3 (Python 3.9.13)— this is the Microsoft Storepython3app-execution alias, which has a notable cold-start cost per invocation- Verdict:
capture is working(no FAIL) — this is purely a latency report, not a correctness one
Why it matters
On UserPromptSubmit the user waits for the hook synchronously, and (as the script's own comments note) a non-zero exit erases what they typed. A 2.5s p50 is a tax on every single turn; the 31s outliers are painful.
What helped
Setting REMEMBER_PROMPT_STAMP=stable (drops the clock, stamp becomes [user]) removes the CTX_PCT read + clock path. Reporting the numbers before/after once that's had a few sessions to settle.
Possible directions (for maintainers)
- On the fast path, collapse the remaining
$( … )sub-shells — build the stamp string with pure parameter expansion where possible (thestablepath already shows this is feasible). - When
jqis absent, the notice-JSON branch shells out topython3; on a box wherepython3is the WindowsApps shim that's a ~hundreds-of-ms hit. Could the no-jq path skip the process entirely whenNOTICE_MSGis empty (the common case)? A quick read of the script suggests it already does — worth confirming there's no straypython3/jqprobe on the empty-notice path. - Consider documenting
REMEMBER_PROMPT_STAMP=stableas the recommended setting for Windows Git Bash users specifically.
Happy to gather set -x timings on the fast path if that's useful.
Activity
docs(handover): next-session step 1 = fix the two-Prometheus shared-v…
Fewer warm-path forks (#511), env-cache key parity on Windows (#504),…
Fix #669 round 6: pass the regression test's fake path through env, n…
Add a Windows/Git-Bash benchmark for session-start-hook.sh (#669) (#671)
Cut $( ) subshell forks on SessionStart's config/timestamp/slug paths (…
fix(#829): decode JSON backslash escapes in the hook stdin extractors (…
test(#900): source-text pins skip a compiled hook; harness pins see t…
test(#900): source-text pins skip a compiled hook; harness pins see t…
test(#900): source-text pins skip a compiled hook; harness pins see t…
test(#900): source-text pins skip a compiled hook; harness pins see t…
test(#900): pin two compiled-hook pin hazards the fix/898 merge expos…
fix(#900): skip pins the compiled build cannot answer, not fail them
fix(#914): stop forking stat+date per file in the autonomous-log rete…