Skip to content

perf(mcp)!: defer retained views in progressive catalogs - #9151

Merged
gensokyo-dev merged 1 commit into
mainfrom
perf/recent-tool-workflows
Nov 6, 2026
Merged

gensokyo-dev merged 1 commit into
mainfrom
perf/recent-tool-workflows

Conversation

@gensokyo-dev

@gensokyo-dev gensokyo-dev commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

An inline OpenAPI/GraphQL/trace/endpoint query was paying for the unused cross-domain inspect_analysis_view definition. MCP JS SDK 2.3.1 eagerly prepares output validators for its discovered catalog, adding several seconds before these first answers.

Load the view on demand through the existing hot/cold catalog owner. No new cache, tool, execution gateway or parser path. Full schemas and canonical validation remain intact when loaded. The default full catalog is exactly unchanged (241 tools / 4,257,977 bytes on the rebased main).

Follow-up qualification of #9090, #9104, #9127, #9140 and #9143. The report and JSON receipt retain ranges, digests and limitations.

Observed results

Three alternating suite repetitions, real small/large artifacts, normal JIT and stock SDK validation. Measurements use exact-name discovery; broad keyword discovery can also load the generic view and is not qualified for the same speedup. Initial hot/cold catalog: 781,713 → 90,374 bytes. Five inline-only tasks return identical analysis Evidence:

Task Median seconds through verified answer Incremental input/text token estimate
OpenAPI 13.80 → 6.46 9,669 → 6,336
GraphQL 13.42 → 7.56 11,898 → 8,565
Playwright trace 12.15 → 6.75 11,946 → 8,613
JS / HAR 10.61 → 5.31 8,296 → 4,963
OpenWrt FIT 10.21 → 6.28 11,468 → 8,135

Token estimates use tiktoken 0.14.0/o200k_base and count distinct input definitions, instructions, a fixed question, every argument and text reply. They are not actual model usage. Output schemas are counted separately as transport costs. No model calls or billing claims.

Six-case suite including retained follow-ups and all client/server cleanup: median wall 70.618 → 46.181 s, user+system CPU 75.316 → 47.741 s, sampled family peak RSS 1,195,388,928 → 1,046,691,840 bytes. Two CPU affinity, 4 GiB RSS guard/200 ms sampling, 1 GiB Node heaps; no compared run hit a guard. Filesystem caches were not flushed; later cases share warm harness/SDK code.

Tradeoff: later discovering the generic view adds a call and catalog refresh. That cohort slowed from 10.78 to 12.79 s and has no incremental-token benefit. Two cold-client batched controls avoid the extra discovery/refresh but establish no speedup; timing ranges overlap. This changes unused-schema costs, not artifact parsing speed. Model rendering/caching, reasoning, cold disk, other clients and sustained generic large-page JIT behavior remain unmeasured.

Validation performed

  • Public stdio regression — fails on the base as intended, passes on the candidate and again after rebase. Full canonical output schema equality, retained-source access/export and notification idempotence verified.
  • Progressive catalog source tests — 10 passed.
  • Exact targeted boundary runner: deferred discovery 4 variants passed; doctor inventory/identity 1 passed; HTTP reset/refresh 1 passed. Existing deferred tests also passed 29 other cases before the old count assertions were updated; CI will run the full files.
  • Full source typecheck; targeted lint (5 files), typed lint of changed production/public workflow; architecture guards — passed. Formatting passed.
  • npm run docs:build and npm run docs:check — passed, including 9 README consistency checks. Later edits clarify cache scope and add the integration record without changing links.
  • All six real workflows reran successfully after rebasing onto fbe7532fabb78de46bd00db845c1147b5325ad22; analysis Evidence digests match the qualified cohort. A same-base comparison confirms default-full exact equality; the upstream managed schema difference is kept separate from this optimization.

Independent oracles check original OpenAPI declarations, GraphQL source-line containment/digests, raw ZIP network records and the previously qualified OpenWrt byte ranges/hashes. Every paired analysis Evidence digest matches. Original trace/HAR captures and raw measurement harnesses remain local outside Git; exact real-data timing reproduction requires matching external fixtures. The public regression is self-contained.

Compatibility and scope

BREAKING CHANGE: In the opt-in hot-cold catalog, inspect_analysis_view is no longer initially loaded. Discover it before calling it; batch it with its producer when follow-ups are known. Clients that require upfront availability can keep the unchanged default full profile. CLI contracts, arguments, results, Evidence, caller selection, authority and complete export are unchanged.

The public stdio regression discovers an API producer, verifies selected facts without loading the generic view, removes its owned source file, then discovers the view with the complete canonical schema, queries retained facts and exports complete source Evidence. Related stdio/HTTP reset/doctor tests use policy or observed inventory/deltas rather than hardcoded catalog counts.

No target execution, provider installation, package/dependency changes or new mutation authority. Maintainer execution/mutation scope decision: not applicable. No binary fixtures or credentials committed.

Author readiness

Human owner: @gensokyo-dev (repository declaration exemption applies).

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Keep full schemas and canonical analysis unchanged while loading the cross-domain view through existing named discovery. Qualify real recent-tool workflows with token ledgers, latency, CPU, family RSS and retained-follow-up controls.

BREAKING CHANGE: The opt-in hot-cold catalog no longer preloads inspect_analysis_view. Discover it before calling it, batch with its producer when needed, or use the unchanged default full profile.
@greptile-apps

greptile-apps Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge with the documented discovery requirement for hot-cold clients.

Summary

This PR makes inspect_analysis_view load on demand in the opt-in hot-cold catalog.

  • Hot-cold catalogs load retained views only when clients ask.

Review limits: Tests were not run during this review. GitHub access required authentication, so supersession could not be checked.

Diagram

sequenceDiagram
  participant Client
  participant Catalog
  participant Analysis
  participant Evidence
  Client->>Catalog: Discover producer
  Catalog-->>Client: Refresh available tools
  Client->>Analysis: Request selected facts
  Analysis->>Evidence: Retain complete result
  Analysis-->>Client: Selected facts and parent Evidence ID
  Client->>Catalog: Discover inspect_analysis_view
  Catalog-->>Client: Original complete contract
  Client->>Analysis: Query retained parent
  Analysis->>Evidence: Read retained facts
  Analysis-->>Client: Selected follow-up facts
Loading

Reviews (2) · Last reviewed commit: "perf(mcp)!: defer retained views in prog..." · Reviewed by Greptile

@gensokyo-dev
gensokyo-dev merged commit bacc1e3 into main Nov 6, 2026
51 checks passed
@gensokyo-dev
gensokyo-dev deleted the perf/recent-tool-workflows branch November 6, 2026 14:44
Nabab-Hub pushed a commit to Nabab-Hub/rea that referenced this pull request Nov 12, 2026
Nabab-Hub pushed a commit to Nabab-Hub/rea that referenced this pull request Nov 17, 2026
Nabab-Hub pushed a commit to Nabab-Hub/rea that referenced this pull request Nov 19, 2026
@morluto morluto added area: mcp MCP server, transport, and tool registration performance Performance regressions, scaling limits, and bounded-resource work labels Nov 22, 2026
Nabab-Hub pushed a commit to Nabab-Hub/rea that referenced this pull request Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: mcp MCP server, transport, and tool registration performance Performance regressions, scaling limits, and bounded-resource work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants