Repository navigation
perf(hooks): cut per-tool-call process spawns from Claude Code hooks - #65
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Replace the stale hard-coded Linux path with STAPLER_SQUAD_DASHBOARDS_DIR, defaulting to $HOME/code/github.com/tstapler/stapler-squad/docs/observability/grafana/dashboards. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
RED panels for GetVCSStatus: handler and git-computation latency percentiles, Connect error/cancel rate, error ratio, in-flight, cache and coalescing hit rate, slot queue wait. Queries verified against VictoriaMetrics through Grafana's /api/ds/query. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Guard Linux-only /home/tstapler and /home/linuxbrew entries; on macOS /home is autofs, so every failed PATH lookup (~24ms) spawned od_user_homes (130-300/s), loading opendirectoryd and endpoint security. - Load zplug plugins statically (zplug on demand), cache completion output, single compinit -C, background keychain: interactive startup ~1.6s -> ~0.7s. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Answer the oh-my-zsh git plugin's `git version` from a cache keyed on the
git binary instead of forking it every shell.
- Drop `uname` forks on macOS (use $OSTYPE; .zshenv runs for every zsh).
- Use ${UID} instead of `id -u`, and only look up the fallback SSH agent
socket when the 1Password and GPG sockets are absent.
- Move zsh-only _cache_output into .shell/cache-output.zsh (allowlisted in
.gitignore): its `*(N)` glob made `bash -n .shell/exports.sh` fail, and
.bashrc sources that file. bash gets a stub that returns 1.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ites Resolve origin once (GIT_HOOK_ORIGIN_URL) instead of re-running ls-remote in each hook and drop-in, and only write user.name/core.sshCommand when changed, since writes take the .git/config lock shared by every worktree. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
(From the stash 'wip before pulling origin/master for pr-ship push'.) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…PATH guard Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…lerts Native host collector (Prometheus text on 127.0.0.1:64891) scraped by Alloy into VictoriaMetrics as job=host; Grafana dashboard with an Activity Monitor style overview, contention suspects and a host-vs-app row; Grafana alert rules for disk, swap, memory pressure and load. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
~/.cargo/config.toml sets rustc-wrapper=sccache, but a server spawned by cargo dies with its parent shell, so later builds silently lose caching. Run it under launchd (macOS) / systemd --user (Linux) and install sccache from the macOS Brewfile too. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Under EDR every spawned process is expensive (~30 spawns per Bash tool call). - pr-review-reminder: add tracked script that early-exits via a bash builtin `case` on the raw hook JSON (no jq/grep/python/cat on the non-matching path), registered with an `if: Bash(gh pr *)` filter so the process is not spawned at all for other commands. - core-hooks: drop the PreToolUse sdd-status-check (kept on Stop only) and replace the Stop check's three `find` walks with globs. - git shim: bypass _find_real_git (3x readlink + subshells) for local subcommands; network subcommands take the unchanged path. - llm-sync: dedup plugin hooks after expanding $HOME and dropping ~/.cargo/bin and ~/.local/bin prefixes. Before, re-running plugin install re-added `$HOME/...` copies of hooks already installed as absolute paths, doubling ssq-hooks and kibitzer per tool call. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cuts process spawns on the hot Claude Code hook paths. Evidence for the spawn problem: ~30 spawns per Bash tool call under CrowdStrike.
Measured on this machine (30 runs, mean):
ssq-hooks checkwithhookmetricswrapper (live setting; see Follow-up)pr-review-reminderhook, non-matching Bash calliffilter matches nothing)Write|EditPreToolUse check (in a large repo)find)git statusthrough the shimreadlink+ subshell forks, 104 ms medianChanges:
.claude/hooks/pr-review-reminder.sh(bash builtins only before a match; same output as the untracked script ongh pr create|ready|merge, byte-identical checked), linked via cfgcaddy, registered in core-hooks withif: Bash(gh pr *)(Claude Code >= 2.1.89; local is 2.1.319).findversion across none/requirements/plan/validation states).git-ssh-fallback: non-network subcommands exec the real git before_find_real_git, reusing_extract_subcommand's logic;fetch/clone/push/pull/ls-remote/submodule/remotestill take the full path (verified with a stub real git, including-C/-cforms)._effective_commandnow also expands$HOMEand drops~/.cargo/bin/~/.local/bin. Before this, running llm-sync against the live settings.json added$HOME/.local/bin/ssq-hooks checkand$HOME/.cargo/bin/kibitzer hookcopies next to the installed absolute-path entries (reproduced on a copy), doubling those hooks per tool call. Two new tests intest_claude_plugin_installer.py; all 6 pass._HOOK_WRAPPER_REis unchanged and still stripshookmetrics.Follow-up (not in this diff): the
hookmetricswrapping and the untrackedpr-review-reminderentry exist only in the live~/.claude/settings.json, which llm-sync only appends to. Applying this needs a one-time edit of that file. The latency metric is dropped forssq-hooks checkandpr-review-reminder;hookmetricsremains on the rarely-run hooks.Not verified:
git-ssh-fallback.batshangs at its second test both before and after this change (pre-existing); the 10 unit-style tests I ran (is_network_op, extract_subcommand, self-test, executable) pass.🤖 Generated with Claude Code