[PR #4316] [CLOSED] perf(mcp): defer managed inspectors until first use #6165

Closed
opened 2026-10-31 01:12:21 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4316
Author: @leeguooooo
Created: 10/16/2026
Status: ❌ Closed

Base: main ← Head: perf/mcp-lazy-runtime


📝 Commits (1)

  • e9048e8 perf(mcp): 延迟加载未使用的 .NET 检查器

📊 Changes

5 files changed (+39 additions, -13 deletions)

View changed files

📝 src/application/managed/ManagedMemberComparisonService.ts (+2 -1)
📝 src/composition/binary.ts (+5 -3)
📝 tests/boundary/cli/cliStartupImports.test.ts (+28 -5)
📝 tests/boundary/mcp/serverLifecycleMcp.test.ts (+3 -3)
📝 tests/boundary/mcp/shutdown.test.ts (+1 -1)

📄 Description

MCP startup loaded the .NET PE/CIL implementation through binary composition and the path-comparison helper, before any managed tool was called. Defer both imports until use; managed-only session creation becomes async. No CLI/MCP contract changes.

The startup regression fails on 808339f0b and passes here, including a successful first managed inspection. All 54 focused tests passed (startup, managed CLI/MCP, member comparison, lifecycle and shutdown), as did check:fast, knip and architecture guards. npm run check stops on an existing formatting failure in src/adb/AdbProvider.ts, reproduced on the base revision. No external analysis engine was tested; this changes only local managed-code loading.

Measurements

Three alternating fresh-process runs per revision, macOS arm64 / Node 24.18.0, warm filesystem cache. Initialize + list all tools, then sample memory. No child processes spawned; peak RSS covers the server process family.

Median Base Change
Elapsed 1,093 ms 965 ms
CPU 1,239 ms 1,163 ms
Peak RSS 410.31 MiB 419.88 MiB
Retained heap after diagnostic GC 171.01 MiB 170.69 MiB

The memory saving is small; this does not establish an RSS improvement or resolve multi-session memory usage. The 207-tool catalog is byte-identical (3,134,906 bytes). Cold filesystem runs and agent token usage were not measured.

Author readiness

Human owner: @leeguooooo

  • 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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/4316 **Author:** [@leeguooooo](https://github.com/leeguooooo) **Created:** 10/16/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `perf/mcp-lazy-runtime` --- ### 📝 Commits (1) - [`e9048e8`](https://github.com/morluto/rea/commit/e9048e88388756f4ac417a0277ce75c5297202dd) perf(mcp): 延迟加载未使用的 .NET 检查器 ### 📊 Changes **5 files changed** (+39 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `src/application/managed/ManagedMemberComparisonService.ts` (+2 -1) 📝 `src/composition/binary.ts` (+5 -3) 📝 `tests/boundary/cli/cliStartupImports.test.ts` (+28 -5) 📝 `tests/boundary/mcp/serverLifecycleMcp.test.ts` (+3 -3) 📝 `tests/boundary/mcp/shutdown.test.ts` (+1 -1) </details> ### 📄 Description MCP startup loaded the .NET PE/CIL implementation through binary composition and the path-comparison helper, before any managed tool was called. Defer both imports until use; managed-only session creation becomes async. No CLI/MCP contract changes. The startup regression fails on `808339f0b` and passes here, including a successful first managed inspection. All 54 focused tests passed (startup, managed CLI/MCP, member comparison, lifecycle and shutdown), as did `check:fast`, `knip` and architecture guards. `npm run check` stops on an existing formatting failure in `src/adb/AdbProvider.ts`, reproduced on the base revision. No external analysis engine was tested; this changes only local managed-code loading. <details> <summary>Measurements</summary> Three alternating fresh-process runs per revision, macOS arm64 / Node 24.18.0, warm filesystem cache. Initialize + list all tools, then sample memory. No child processes spawned; peak RSS covers the server process family. | Median | Base | Change | |---|---:|---:| | Elapsed | 1,093 ms | 965 ms | | CPU | 1,239 ms | 1,163 ms | | Peak RSS | 410.31 MiB | 419.88 MiB | | Retained heap after diagnostic GC | 171.01 MiB | 170.69 MiB | The memory saving is small; this does **not** establish an RSS improvement or resolve multi-session memory usage. The 207-tool catalog is byte-identical (3,134,906 bytes). Cold filesystem runs and agent token usage were not measured. </details> ## Author readiness Human owner: @leeguooooo - [x] 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. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:12:21 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6165
No description provided.