Skip to content

user-prompt-hook.sh still ~2.5s p50 / 31s max on Windows Git Bash in 0.21.0 (follow-up to #227) #511

Closed

Description

@welshDog

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)
  • remember 0.21.0, storage mode legacy (in-project .remember)
  • Box under sustained memory pressure (large Docker workload; frequent swap) — every fork() is slow here
  • doctor.sh output, 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 Store python3 app-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)

  1. On the fast path, collapse the remaining $( … ) sub-shells — build the stamp string with pure parameter expansion where possible (the stable path already shows this is feasible).
  2. When jq is absent, the notice-JSON branch shells out to python3; on a box where python3 is the WindowsApps shim that's a ~hundreds-of-ms hit. Could the no-jq path skip the process entirely when NOTICE_MSG is empty (the common case)? A quick read of the script suggests it already does — worth confirming there's no stray python3/jq probe on the empty-notice path.
  3. Consider documenting REMEMBER_PROMPT_STAMP=stable as the recommended setting for Windows Git Bash users specifically.

Happy to gather set -x timings on the fast path if that's useful.

Activity

  1. self-assigned this
    on Sep 3, 2026
  2. added
    priority:medium
    on Sep 3, 2026
  3. added a commit that references this issue on Sep 3, 2026
  4. added 8 commits that reference this issue on Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

priority:medium

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions