Repository navigation
Cold /api/studies: one routing build instead of 551 (28–40 s → 1.5 s over MCP) - #42
Merged
Merged
Conversation
…t runs A cold /api/studies took 28–40 s with GENIE over MCP (4–5 s direct). It looks up every study's access at once (Promise.all over 551 studies), each lookup needs the routing table, and while the first build waited on the network every other lookup found the table empty and started its own: 551 builds for one answer — 551 MCP calls to the simulated peer, or 1,102 small queries direct. studyRouting() now keeps the build in progress, so callers that arrive during it wait for the same one. It runs detached from any one reader's cancellation, since it answers them all; a failed or partial build is still not kept. test/routing.test.ts: 50 concurrent lookups on a cold process ask the peer for its studies once (it sees 50 without the change). Measured on a fresh production build (three cold starts each, then a warm request): over MCP: cold 28.5–39.9 s, 552 MCP calls → 1.3–1.5 s, 2 calls direct: cold 4.3–5.1 s → 0.7–0.9 s warm: ~0.03 s either way, before and after. scripts/gate.sh green (1263 unit, 253 e2e). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QLBVrkqBG7J7pqX6Qygx3z
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Problem
The first
/api/studiesafter a deploy took 28–40 s with GENIE over MCP. With GENIE direct it took 4–5 s.The endpoint looks up every study's access at once (
Promise.allover 551 studies). Each lookup needs the routing table. While the first build waited on the network, every other lookup found the table empty and started its own build: 551 builds for one answer. Over MCP that's 551 calls to the simulated peer; direct, it's 1,102 small queries.Fix
studyRouting()keeps the build in progress, so callers that arrive during it wait for the same one. The build runs detached from any single reader's cancellation, since it answers them all. A failed or partial build is still not kept.test/routing.test.ts: 50 concurrent lookups on a cold process ask the peer for its studies once. Without the fix the test sees 50.Measured
On a fresh production build: three cold starts each, then a warm request.
Warm requests take about 0.03 s either way, before and after.
scripts/gate.shgreen (1263 unit tests, 253 e2e checks).🤖 Generated with Claude Code
https://claude.ai/code/session_01QLBVrkqBG7J7pqX6Qygx3z