Repository navigation
|
Environment Symptom Measurements from one session (37c0c192, ~14 hours of normal use): Hook duration as recorded by DSH itself (hook/result.durationMs):
Tool call duration (tool/call -> tool/result), by tool:
The control that isolates it
Where I got to in the source Related
Questions
Numbers table (same as above, for clarity) |
Replies: 1 comment 4 replies
|
Looking at your numbers, I don’t think the extra time is coming from the tools themselves. read and grep don’t spawn anything, but they still average about 4.3-4.8 s. That’s almost exactly your PreToolUse average (about 4.0 s), and PreToolUse runs before every tool call. So most of the time on read/grep is the hook, not the tool. pwsh fits the same pattern: about 4.4 s of hook, plus about 6 s for the pwsh process itself (your echo 1 test shows that split). So it looks like one fixed cost every time ctx.shell starts a process, and pwsh adds its own startup on top. Since node.exe runs your scripts in 50-200 ms from a terminal, my guess is that ctx.shell doesn’t start node directly but goes through a shell first, and that shell is what’s slow to start. Things I’d check: Which shell ctx.shell uses on Windows. If it’s PowerShell, compare Measure-Command { pwsh -c exit } with Measure-Command { pwsh -NoProfile -c exit }. If the first one takes around 4 s, your profile or module autoloading is the cost. If (1) or (3) shows a shell in the middle, that would also explain why #5635 (running hooks through ctx.subprocess) is the right direction. |
Looking at your numbers, I don’t think the extra time is coming from the tools themselves.
read and grep don’t spawn anything, but they still average about 4.3-4.8 s. That’s almost exactly your PreToolUse average (about 4.0 s), and PreToolUse runs before every tool call. So most of the time on read/grep is the hook, not the tool. pwsh fits the same pattern: about 4.4 s of hook, plus about 6 s for the pwsh process itself (your echo 1 test shows that split).
So it looks like one fixed cost every time ctx.shell starts a process, and pwsh adds its own startup on top. Since node.exe runs your scripts in 50-200 ms from a terminal, my guess is that ctx.shell doesn’t start node directly but goes …