Skip to content

hook-augment restarts full daemon on every invocation, causing ~3s latency per call and hook timeouts #2058

Description

@Langsuyar64

Summary

The cbm-code-discovery-gate hook (installed by codebase-memory-mcp install into
Claude Code's PreToolUse:Grep hook) calls codebase-memory-mcp.exe hook-augment on
every single Grep tool call. In practice this takes ~3 seconds per invocation, and
occasionally exceeds the client's hook execution timeout entirely, blocking the tool
call it's supposed to only augment.

Environment

  • codebase-memory-mcp v0.10.8 (confirmed latest via GitHub releases at time of filing)
  • Windows 11, Claude Code CLI
  • Project graph DB: ~21MB (C-Users-...-TC_PayrollChecker.db)

Observed behavior

Direct timing of codebase-memory-mcp.exe hook-augment run 3x consecutively from the
project directory: 2.98s / 3.32s / 2.98s — consistent, not a cold-start fluke.

~/.cache/codebase-memory-mcp/logs/cbm-daemon.log shows the daemon fully tearing down
and cold-restarting on each invocation:

level=info msg=daemon.runtime_stopping reason=last_committed_client_disconnected
level=info msg=watcher.unwatch project=...
level=info msg=daemon.lifetime_end reason=runtime_exited
level=info msg=watcher.stop
level=info msg=daemon.stop
level=warn msg=mem.allocator.preloading_completed ...
level=info msg=mem.init budget_mb=3572 total_ram_mb=14290 source=ram_fraction
level=info msg=watcher.start interval_ms=multi-sec
level=info msg=ui.serving url=http://127.0.0.1:9749 port=9749
level=info msg=daemon.start version=0.10.8 pid=...

Each hook call appears to pay full daemon cold-start cost: memory allocator init,
binding the HTTP UI server on :9749, and establishing a git-based file-watcher
baseline — before it can answer. Real-world impact observed in Claude Code transcripts:
3 recorded PreToolUse:Grep hook runs in a 15-day window all hit the hook timeout
(6.1s, 7.3s, 7.7s), blocking those Grep calls entirely.

Also noticed in the same log: an indexing worker failure
(index.supervisor.worker_failed outcome=exit_nonzero exit_code=1) and a stray
24MB .stage.a05564 staging file left in the cache dir, possibly from an
interrupted reindex — may or may not be related.

Expected behavior

hook-augment should reuse a warm/persistent daemon (or otherwise avoid full
daemon boot — allocator init, UI server, watcher baseline) for what's meant to be
a lightweight per-tool-call augmentation hook, so it doesn't add multi-second
latency to every Grep call in the host CLI.

Workaround

Disabled the exe call in ~/.claude/hooks/cbm-code-discovery-gate.cmd (early
exit /b 0) since no config flag (codebase-memory-mcp config list) exposes
daemon-reuse or a lighter-weight hook path. The MCP server tools themselves
(search_graph, trace_path, etc.) are unaffected and still used heavily.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    editor/integrationEditor compatibility and CLI integrationparsing/qualityGraph extraction bugs, false positives, missing edgesstability/performanceServer crashes, OOM, hangs, high CPU/memoryux/behaviorDisplay bugs, docs, adoption UXwindowsWindows-specific issues

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions