Repository navigation
Pre-warm the MCP query pool + slim worker connections - #560
Merged
Merged
Conversation
Three fixes to the MCP read path, all measured on gin + n8n: - Warm floor: the pool lazily grew one worker at a time, so an 8-query burst serialized through the spawn ladder. A bounded warm floor (CODEGRAPH_QUERY_POOL_WARM, default 4, capped by pool size) keeps a few workers hot; drain() trickles growth on progress events and the post-warm spawn cap rises 2 -> 4 so a real burst still fills the pool. Pools without a default project stay lazy. - awaitReady: the first tools/call could land inside the ~40 ms window before the eager worker posts 'ready', take the in-process fallback, and pay a multi-second lazy module load on the transport thread (reproducibly ~6 s on Bun). Calls now wait out a bounded 4 s grace for a pending start before falling back. - Compact read-only worker connections: pooled workers opened full writer connections (64 MiB cache, 256 MiB mmap, migration/heal/WAL probes at every spawn). They now openSync readOnly + compact (16 MiB cache, no mmap) — pure readers skip writer-side setup, and the pool's summed RSS stops multiplying per worker. Measured: gin 8-query wave 134 -> ~90 ms (upstream-Node ~114); n8n busy process-tree RSS 4.54 -> 3.10 GiB on Node (upstream 3.85) and 1.24 GiB on Bun (upstream ~3.5); n8n wave 1.91 -> 2.04 s Node / 1.63 -> 1.75 s Bun stays ahead of upstream (2.39 / 1.96); gin cold first answer no longer falls off the ~6 s cliff.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Owner
Author
|
@coderabbitai review |
|
This was referenced Oct 27, 2026
github-actions Bot
pushed a commit
that referenced
this pull request
Oct 28, 2026
…s rate-limited API (colbymchenry#2939) install.ps1 resolved "latest" with one Invoke-RestMethod to the GitHub API, with no fallback, under ErrorActionPreference Stop. The API allows 60 unauthenticated requests an hour per IP and then answers 403, so `irm .../install.ps1 | iex` died with a raw "(403) Forbidden" on shared networks and in CI. A pinned CODEGRAPH_VERSION=1.6.2 was used as-is, so the download URL lacked the v that release tags carry and 404ed. install.sh (PR #336) and `codegraph upgrade` (resolveLatestVersion) already handle both; install.ps1 was never ported. Fix: step 2 is now a function between Resolve-CodeGraphVersion markers. It sends a HEAD to github.com/<repo>/releases/latest with System.Net.HttpWebRequest and AllowAutoRedirect off, reads the tag from the Location header with /releases/tag/([^/?#]+), falls back to the API inside try/catch, adds the v to a bare version, and keeps the friendly throw when both fail. Install-CodeGraphFiles is untouched (still equal to WINDOWS_SWAP_FUNCTION). Validation (Windows PowerShell 5.1.26100; pwsh 7 is not installed here): - Each arm's unmodified step 2, with Invoke-RestMethod shadowed so the API answers a local 403: main stops with "(403) Forbidden"; the fix resolves v1.6.2 from the real redirect with no API call. CODEGRAPH_VERSION=1.6.2: main builds .../download/1.6.2/... (HEAD 404), the fix .../download/v1.6.2/... (HEAD 302). With the API available, main makes one API call and the fix none. - New Windows-gated test runs the shipped resolver block in PowerShell against a local stand-in for github.com and the API: redirect read with one HEAD and no follow, API fallback for a 500 or a missing Location, the friendly error (no raw 403) when both fail, the v added to a pinned version with no request. 4 fail on main's install.ps1, 4 pass with the fix; upgrade.test.ts (the swap function pin) passes. - Both scripts parse with no errors in PowerShell 5.1. The install steps were not run: they always add the install to the user PATH. Reported in PR #560 by @hiyochi; this reimplements the fix independently. Co-Authored-By: Claude Opus 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.
Summary
Three measured fixes to the MCP read path:
CODEGRAPH_QUERY_POOL_WARM, default 4, capped by pool size) keeps a few workers hot;drain()trickles growth on progress events and the post-warm spawn cap rises 2 → 4. Pools without a default project stay lazy; idle retirement still drains to one warm worker.awaitReadygrace — the firsttools/callcould land inside the ~40 ms window before the eager worker postsready, take the in-process fallback, and pay a multi-second lazy module load on the transport thread — reproducibly ~6 s on Bun. Calls now wait out a bounded 4 s grace for a pending start before falling back.openSyncreadOnly+compact(16 MiB cache, no mmap): pure readers skip writer-side setup, and summed RSS stops multiplying per worker.Measured (bench harness, gin + n8n, mirrored arms)
Test plan
__tests__/query-pool.test.ts: 30 tests — warm-floor growth, bounded spawn cap,awaitReadyrace coverage, crash recovery, retirement, project-less poolsDIRECT_QUERY_POOL_MAX = 2cap all preservedStacked on
fork/consolidatedat543a4f64; independent of #558/#559.