fix(mcp): wire_send uses a cheap pidfile liveness check, not the full scan (#350)#353
Merged
Merged
Conversation
… scan (#350) Willard reported painfully slow MCP on Windows. Root cause confirmed in code: `tool_send` (every `wire_send`, the primary MCP action) called `daemon_liveness()` purely to read one diagnostic boolean (`daemon_seen` = `snap.pidfile_alive`). But `daemon_liveness()` also runs the machine-wide orphan-detection scan the send path never uses: - `find_processes_by_cmdline("wire daemon")` → PowerShell `Get-CimInstance` on Windows (enumerates ALL processes, ~1-3s cold), - `list_sessions()` → reads `agent-card.json` from EVERY by-key home (Willard's box has hundreds — see #351's session proliferation), each an NTFS dir read, - `pid_is_alive` per session daemon pid → a `tasklist.exe` spawn each. On Unix that's a cheap `pgrep` + `/proc`; on Windows it's seconds — paid on every send. The annotation only needs `daemon_seen`. Fix: new `ensure_up::daemon_pidfile_alive()` — one `daemon.pid` read + one `pid_is_alive` (one `tasklist` on Windows) — yielding the identical boolean. `tool_send`'s two branches use it instead of full `daemon_liveness()`. `wire_status` keeps the full scan (it legitimately reports orphans). Cross-platform; Windows CI (`install-smoke-windows`) compile-verifies. The deeper Windows wins (native Win32 to kill the remaining PowerShell/tasklist/reg spawns, #350) and the MCP/CLI identity split (#351) remain tracked; this removes the per-send hot-path scan, the dominant cost. Test `daemon_pidfile_alive_false_without_pidfile`. 610 lib tests; fmt+clippy clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Deploying wireup-landing with
|
| Latest commit: |
9a2f63d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f7cb7293.wireup-landing.pages.dev |
| Branch Preview URL: | https://fix-mcp-send-cheap-daemon-ch.wireup-landing.pages.dev |
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.
Willard reported painfully slow MCP on Windows. Root cause confirmed in code, not theory.
The bug
tool_send— i.e. everywire_send, the primary MCP action — calleddaemon_liveness()purely to populate one diagnostic boolean (daemon_seen=snap.pidfile_alive). Butdaemon_liveness()also runs the machine-wide orphan scan the send path never reads:find_processes_by_cmdline("wire daemon")→ PowerShellGet-CimInstanceon Windows (enumerates all processes, ~1–3s cold)list_sessions()→ readsagent-card.jsonfrom every by-key home (Willard's box has hundreds — Two identities per session: MCP server vs SessionStart-hook WIRE_HOME bind to different DIDs → CLI monitor/pull/tail blind to MCP-paired peers #351's session proliferation), each an NTFS dir readpid_is_aliveper session daemon pid → atasklist.exespawn eachOn Unix that's a cheap
pgrep+/proc; on Windows it's seconds, paid on every send. (The code comment even called these annotations "cheap to compute" — true on Unix, false on Windows.)Fix
New
ensure_up::daemon_pidfile_alive()— onedaemon.pidread + onepid_is_alive(onetaskliston Windows) → the identicaldaemon_seenboolean for a fraction of the cost. Bothtool_sendbranches use it.wire_statuskeeps fulldaemon_liveness()(it legitimately reports orphans).Scope / verification
install-smoke-windows) compile-verifies the platform path (I can't build Windows on the Mac, but CI does).daemon_pidfile_alive_false_without_pidfile;cargo test --lib→ 610; fmt + clippy clean.tasklist/reg/whoamispawns (Windows: painfully slow MCP (and CLI) — every process/identity op shells out to PowerShell/tasklist/reg/whoami #350), and the MCP↔CLI identity split (Two identities per session: MCP server vs SessionStart-hook WIRE_HOME bind to different DIDs → CLI monitor/pull/tail blind to MCP-paired peers #351, unified-WIRE_SESSION_IDworkaround in the meantime).🤖 Generated with Claude Code