Skip to content

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

Closed

Description

@blakeh8

Summary

On Windows (Git Bash hooks), session-start-hook.sh averages ~12.5 s per session start — measured across 36 real session starts over 14 days on v0.29.1. This is steady-state latency, not the intermittent consolidation block from #646: it's paid on essentially every start.

Measurements

Taken from Claude Code's own transcript hook records (durationMs on hook attachments), aggregated across all sessions in the window:

Hook n avg max
session-start-hook.sh (SessionStart) 36 12,491 ms 114,379 ms
user-prompt-hook.sh (UserPromptSubmit) 502 1,046 ms 7,107 ms

For contrast, other SessionStart hooks in the same sessions (plain bash scripts, similar size) average 0.5–1.3 s, so this isn't generic shell overhead — though Windows process-spawn cost is a plausible multiplier (each subprocess/jq invocation under Git Bash costs ~50–200 ms, so a hook that shells out dozens of times pays for it roughly 10× harder than on Unix).

Caveats stated honestly:

Environment

  • Plugin: remember v0.29.1 via the claude-plugins-official marketplace (pinned sha 1f5d3f9)
  • Claude Code 2.1.268, native install
  • Windows 11 (ARM64), hooks executed under Git Bash
  • Heavily used install (the plugin works well — this is purely about start latency)

Ask

Whatever the fix shape is — fewer subprocess invocations on the hot path, batching the jq reads, or pushing more of the start work into the backgrounded phase the #646 fix established — a Windows-representative timing budget for the foreground portion of session start would be the win. Happy to run instrumented builds or provide more granular timings from this machine if useful.


Measured and drafted with Claude Code session diagnostics; posted by the account owner.

Activity

  1. added
    lane-capture
    priority:medium
    on Sep 11, 2026
  2. self-assigned this
    on Sep 11, 2026
  3. fdaviddpt commented on Sep 11, 2026

    @fdaviddpt
    Contributor

    Fewer jq forks on the promo path landed in #661 (10 -> 4 per session start, measured on macOS). It does not close this issue -- that reduction is one part of the hook's foreground path, not the whole ~12.5s average this issue measured, so #660 stays open pending a Windows-representative re-measure.

    @blakeh8 if you're up for it, a re-measure on the next release (once the star-ask/promo change from #661 ships) would help confirm whether the promo path was actually the bulk of the hot-path cost on Git Bash, or whether there's more to account for elsewhere in the hook.

    [AI-generated]

  4. removed their assignment
    on Sep 11, 2026
  5. jqit-ricky commented on Sep 12, 2026

    @jqit-ricky

    We measured the SessionStart hook against a real, populated memory store. Environment: Windows 11 (Git for Windows), Claude Code 2.1.269, VS Code extension 2.1.269, remember plugin 0.30.0 from the marketplace.

    Condition Time stdout Forked commands
    Fresh store 0.3-2 s - -
    Quiet machine 23.5 s ~455 KB ~1,400
    Under load (3 workers + 1 QA session) 188.3 s ~455 KB ~1,400

    Exit code was 0 every time. We traced the hook with PS4='+$EPOCHREALTIME ' bash -x: about 1,400 forked commands per run. On this machine a Git Bash fork costs 90 ms idle, 263 ms under load (normal is 10-30 ms). Fork count drives most of the wall-clock time, and it gets worse exactly when the machine is busiest. The single largest gap was a 6.95 s wait inside the before_session_start dispatch (hooks.d/before_session_start/50-git-restore.sh). That step's own header budgets only 0.17-0.22 s for itself.

    This collides with the VS Code extension's hard-coded 60,000 ms subprocess initialisation limit (see #646), which has no setting or variable to raise it. Under load, this hook alone exceeds that limit threefold. The resulting error is Subprocess initialization did not complete within 60000ms - check authentication and network connectivity, which misleadingly points at authentication or network rather than the hook's own runtime.

    One concrete suggestion: declare the SessionStart hook "async": true in hooks.json. The CLI already supports async hooks on SessionStart. Claude Code's own default SessionStart timeout is 600 s, ten times the extension's budget, so long runs are already expected (hooks guide, Limitations). Async would let memory context arrive on the first turn instead of blocking initialisation.

    If async isn't preferred, a smaller fallback exists. Stop awaiting the before_session_start dispatch, or at least 50-git-restore.sh, in the foreground. That step is where the largest single delay sits relative to its own stated budget.

    Happy to share the full trace if useful.

    JQiT Pty Ltd

  6. added
    cohort-11
    on Sep 12, 2026
  7. 48 remaining items

  8. added 2 commits that reference this issue on Oct 11, 2026
  9. added
    cohort-26
    on Oct 11, 2026
  10. erdogan-deniz commented on Oct 19, 2026

    @erdogan-deniz

    A data point from another Windows box on 0.43.1, in case it helps narrow or close this.

    Environment: Windows 11 Pro build 26300, x64 (Ryzen 5 5600H), Defender real-time on, store on local NTFS. Claude Code 2.1.286 (VS Code extension), Git Bash 5.2.26, jq 1.8.2, remember 0.43.1 from claude-plugins-official (pinned ccd4506).

    1. The hook alone. I ran session-start-hook.sh directly against a copy of a real store (about 0.8 MB of .remember) with a synthetic SessionStart payload, traced with BASH_XTRACEFD. Two runs, both 2.6 s wall. The trace has about 3,700 lines and no single step above 0.07 s. By file: log.sh 0.87 s, lib-memory-context.sh 0.38 s, session-start-hook.sh 0.30 s, lib-memory-dir.sh 0.28 s. That is in line with your CI numbers.

    2. In situ. Hook durationMs from Claude Code transcripts on 18–19 Oct, 547 starts (startup, resume and compact combined): p50 3.8 s, p75 6.0 s, p90 10.3 s, max 138 s. The other SessionStart hooks in the same sessions have p50 0.5–0.9 s.

    3. The tail. The slow starts cluster where several sessions start at once. In one project, three starts fell within the same second, probably the editor restoring sessions. The plugin's own session-start took lines show 11–12 s for each of them.

    Caveat: until 19 Oct this machine was hitting the #1034 / #1036 PostToolUse bug, because the marketplace still serves 0.43.1. Hung post-tool hooks were each spinning a core during that time, so the in-situ tail above is inflated. After I dropped 0.43.2's post-tool-hook.sh in locally there have been only 6 starts (p50 9.0 s, mostly resumes while other sessions were open). That is too few to conclude anything.

    Takeaway: I found nothing new inside the hook. The foreground cost is about 2.5 s of Git Bash forks, and the user-visible tail comes from concurrent starts. The "async": true idea from the 12 Sep comment would target exactly that tail. Separately, the marketplace pin is still at 0.43.1, so other Windows users with long transcripts keep getting the 600 s PostToolUse stalls until it moves to 0.43.2.

  11. fdaviddpt commented on Oct 19, 2026

    @fdaviddpt
    Contributor

    Thank you @erdogan-deniz — this is the clearest picture yet: the hook alone is ~2.6 s with no slow step, and the tail comes from concurrent starts.

    On "async": true: we checked Claude Code's hook docs. An async hook's additionalContext is delivered "on the next conversation turn", so Claude's first answer in every session would come without your memory — that breaks remember's core promise. Interactive sessions already run SessionStart in the background (you can type immediately; only Claude's first response waits for the context), so the remaining cost is that first-response wait, and it grows when several sessions start in the same second and compete for Git Bash forks. The lever there is fewer forks on the foreground path, not async.

    Your caveat matters too: 0.43.1's PostToolUse stall (#1034/#1036) was spinning cores during your sample. 0.43.2 fixes it; the marketplace bump is pending at anthropics/claude-plugins-official#6802. Once you're on it, a re-measure of concurrent starts would tell us how much of the tail is left.

    [AI-generated]

  12. kheirou commented on Oct 22, 2026

    @kheirou

    Data point, Windows 11 Home build 26300, Claude Code 2.1.308, Git Bash, remember 0.43.1 → 0.44.1. Startup measured as the slowest SessionStart hook, median of 5–7 runs, empty project dir:

    • jq missing → installed: hook 5.2 s → 1.6 s. The Python fallback was the biggest single cost; it might be worth a doctor FAIL (not WARN) on Windows.
    • features.plugin_promos: false: 1.6 s → 1.4 s.
    • 0.44.1 vs 0.43.1, run directly against a real store: PostToolUse 311 → 265 ms, UserPromptSubmit flat at about 300 ms.

    Like @erdogan-deniz, I found no single slow step in the trace. What's left is about 35 process starts at about 37 ms each.

  13. added
    priority:high
    and removed
    priority:medium
    on Oct 31, 2026
  14. added 4 commits that reference this issue on Nov 1, 2026
  15. fdaviddpt commented on Nov 1, 2026

    @fdaviddpt
    Contributor

    Closing with measurements. On Windows (GitHub's windows-latest runner, Git Bash, Python 3.9 to 3.12), SessionStart now takes about 1.0 to 1.6 s on an ordinary start (middle of 3 runs) and about 1.4 to 1.9 s on the very first start, down from the ~12.5 s you measured on v0.29.1. That comes from the work done since (fewer helper processes, a cached memory section, background work moved out of the way). #1096 keeps this measurement in our Windows tests so it cannot quietly get slow again.

    These are CI numbers, not a real PC, so if your own machine is still noticeably slow on a recent version, please reopen with your timings and we will dig in.

    [AI-generated]

  16. added a commit that references this issue on Nov 9, 2026
    71557f9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

cohort-11cohort-12cohort-13cohort-14cohort-15cohort-16cohort-17cohort-18cohort-19cohort-20cohort-21cohort-22cohort-23cohort-24cohort-25cohort-26lane-capturepriority:high

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions