Skip to content

perf(mcp): reduce global dispatch catalog construction churn #861

Description

@ScriptedAlchemy

Separate from #810: the typed RMCP connection benchmark now measures steady-state dispatch only after explicitly warming the process-global dispatch catalog.

Evidence

A fresh mcp.server.construct Hotpath measurement on the eager-construction experiment recorded 505,598,728 allocated bytes across 3,762,998 allocations (one constructor call). The catalog is a process-global LazyLock; eagerly resolving it in McpServer::new_with_context changes when this work is paid, not its size.

A hermetic project-scoped production-MCP construction-only fixture opened the server, did not bind a listener or establish an RMCP connection, retained it for two seconds for process sampling, then shut it down. It compared 9adc7c4 with the unpublished eager experiment d185c420:

metric 9adc baseline eager experiment delta
profiler wall 3.512 s 4.453 s +0.941 s
process HWM 192,748 KiB 222,468 KiB +29,720 KiB
retained RSS 182,939,648 B 221,360,128 B +38,420,480 B
retained-RSS delta 72,757,248 B 112,431,104 B +39,673,856 B

The eager experiment is deliberately not being integrated. It demonstrates the lifecycle cost that a real reduction must avoid, not a fix.

Acceptance

  • Localize the dominant allocations inside catalog construction and reduce the actual construction work; do not merely prewarm or move it between first dispatch and project open.
  • Keep a no-RMCP project-open journey free of catalog construction. Measure its wall time, retained RSS, and HWM with the same hermetic process fixture, and report first real RMCP use separately.
  • Preserve the typed dispatch route, cancellation, selected-project leases, delivery settlement, and response identity; verify the real broker/RMCP wire journey rather than a provider lookalike.
  • Keep the steady-state benchmark explicit about its prewarmed catalog scope so future dispatch-byte numbers cannot be interpreted as cold process-start costs.

No live TraceDecay profile or daemon was used for these measurements.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions