Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

perf(hooks): SessionStart p95 7.1 s from about 26 per-plugin prerequisites rows; use one shared async runner

オープン
#6,633 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
活発
技術スタック
json, powershell, shell

調査の方向性

Start with the SessionStart row in plugins/harness-ops/hooks/hooks.json (around lines 507-526) and the shared lib/prerequisites.sh and lib/prerequisites.ps1, including the notice latch at lines 15-40 of prerequisites.sh. First settle the PPID discrepancy by checking which half of the row runs under a Claude Code hook launch. Done means one combined SessionStart runner replaces the per-plugin rows, grep -l prerequisites.ps1 plugins/*/hooks/hooks.json returns 0 or 1, and a session without node shows one notice.

索引モデルが issue の本文から書いたものです。

説明

needs-human needs-triage

Related: #6244 (Windows performance audit tracker), #6251 (matcher fix, closed), #6130 (node-notice exit 127), #4373 (hook fan-out umbrella).

Problem

Every plugin that needs a prerequisite check registers its own SessionStart row. 26 hooks.json files carry a prerequisites.sh / prerequisites.ps1 node-notice row, and 8 formatter plugins add a prerequisites.mjs probe row. Each row starts its own process tree, and SessionStart gates the first response. The hooks docs say: "SessionStart runs on every session, so keep these hooks fast" (https://code.claude.com/docs/en/hooks#sessionstart).

Measured

Method: OTEL hook_execution_complete.total_duration_ms for SessionStart on the windows lane (melo-desk-001), plus direct timing of one row on the same host (date +%s%N around the command, 3 runs).

what value
SessionStart wall-clock, p95 7.1 s (go-faster run 20261008T152359Z, hooks area)
plugin SessionStart rows with a prerequisites check 26 hooks.json files (grep -l prerequisites.ps1 plugins/*/hooks/hooks.json)
powershell -NoProfile -ExecutionPolicy Bypass -File lib/prerequisites.ps1 node-notice ... alone 196 / 158 / 158 ms
sh lib/prerequisites.sh node-notice ... alone 31 / 30 ms
the whole row as written, run under bash -c 52 / 50 / 49 ms
bare node -e 0 / bare bash -c true 52 ms / 29 ms

Discrepancy to settle first: the row is sh prerequisites.sh node-notice ...; ${PPID:+exit}; powershell ... prerequisites.ps1 .... Under Git Bash PPID is set, so the row exits before the PowerShell half and costs about 50 ms, not about 150 ms. The reported ~147 ms per row (22 plugins) applies only where the PowerShell half runs, which is the #6130 case (/bin/sh is not bash). Confirm which half runs inside Claude Code hook launches on this host (a debug log of one startup shows it) before sizing the saving.

Either way the rows are ~26 separate process launches that each answer the same question (is node on PATH), and they run before the first response.

Where

Example (plugins/harness-ops/hooks/hooks.json:507-526, same shape in 25 other plugins, e.g. plugins/eol-normalizer/hooks/hooks.json, plugins/actionlint/hooks/hooks.json:57):

"command": "sh \"${CLAUDE_PLUGIN_ROOT}/lib/prerequisites.sh\" node-notice /harness-ops:check; ${PPID:+exit}; powershell -NoProfile -ExecutionPolicy Bypass -File \"${CLAUDE_PLUGIN_ROOT}/lib/prerequisites.ps1\" node-notice /harness-ops:check",
"timeout": 10

Files with the row: actionlint, animation, autonomy, bash-format, biome-format, context-budget, context-guard, desktop-notification, discovery, disk-hygiene, eol-normalizer, explainer-video, go-format, guardrails, harness-ops, instruction-placement, markdown-format, multi-agent, powershell-format, rate-limit-guard, ruff-format, session-flow, source-control, speech, testing, typos-format.

Proposed fix

  1. One shared prerequisites runner: a single SessionStart row (in one always-enabled plugin, for example harness-ops) that checks node once and the per-plugin binaries from each plugin's prerequisites.json, and prints one combined notice. The per-plugin rows are then removed.
  2. Mark that one row "async": true. The prerequisites notice is advisory and carries no decision, so it loses nothing by arriving on the next turn.

Basis: async hooks run "in the background without blocking Claude", cannot block or return decisions, and are not subject to timeout once running; output is delivered on the next conversation turn (https://code.claude.com/docs/en/hooks#run-hooks-in-the-background, Limitations: "Each execution creates a separate background process. There is no deduplication across multiple firings"). Basis for keeping the row cheap: https://code.claude.com/docs/en/hooks#sessionstart.

Risk to check: a plugin that disables itself without node (the notice's job) must still surface the warning once; the notice latch (lib/prerequisites.sh:15-40) has to move into the shared runner.

Expected saving

Start-up process count drops from about 26 to 1 (plus the 8 formatter probes folded in). If the PowerShell half runs on the affected hosts: about 22 x 147 ms of CPU removed, and the 7.1 s p95 should fall by whatever share the rows hold on the critical path (hooks run in parallel, so the p95 improves through less contention rather than a sum). Where the half is skipped: about 26 x 50 ms of CPU. The wall-clock saving needs the after-measurement below.

Verify after the fix

  • grep -l 'prerequisites.ps1' plugins/*/hooks/hooks.json | wc -l returns 0 (or 1 for the runner).
  • /harness-ops:observability latency SessionStart p50/p95 over at least 100 fires before and after (OTEL hook_execution_complete, event SessionStart).
  • Kill node from PATH in a test session: one combined notice appears, once per session.
主要言語
Shell
スター
22
フォーク
2
平均マージ
7時間 8分
マージ済み PR(30日)
874

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

melodic-software/claude-code-plugins のほかの issue

melodic-software/claude-code-plugins の issue をすべて見る

似ている issue

Shell/Bash の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。