[PR #4350] [MERGED] perf: reduce MCP launcher and browser capture overhead #6191

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4350
Author: @leeguooooo
Created: 10/16/2026
Status: ✅ Merged
Merged: 10/17/2026
Merged by: @morluto

Base: main ← Head: perf/web-resource-reconciliation


📝 Commits (2)

  • b74c855 perf(browser): 为单次捕获复用脚本资源索引
  • e406370 docs(setup): 说明多会话直接启动以减少 npm 驻留

📊 Changes

4 files changed (+157 additions, -49 deletions)

View changed files

📝 docs/installation.md (+15 -0)
📝 src/browser/CdpPageCaptureScripts.ts (+20 -16)
📝 src/domain/webInventory.test.ts (+88 -13)
📝 src/domain/webInventory.ts (+34 -20)

📄 Description

Large page captures scanned the complete resource inventory for every script. Build URL indexes once per capture instead. Keep repeated raw observations ambiguous after public deduplication, preserve sanitized fallback uncertainty, and return independent candidate arrays. No index for empty script inventories; no cache across captures or CLI/MCP contract changes.

Also document direct global-CLI setup for concurrent MCP clients, avoiding one npm launcher per connection. This incorporates #4326; each REA connection keeps its own analysis state.

Validation: npm run docs:check passed after combining the documentation change. Earlier validation: 72 focused tests, npm run check, and real Chrome CLI/MCP verify:browser:scripts passed, including query-variant isolation and zero implicit refetches.

Measurements

Base 42fc6c53a, macOS arm64, Node 24.18.0, Chrome 155.0.8059.82. A loaded local page had 5,000 resources and 5,001 scripts; three alternating captures per revision returned identical script/resource inventories.

Capture Base Change
First elapsed 607 ms 205 ms
Later elapsed, median 399 ms 150 ms
Later Node CPU, median 407 ms 169 ms

For 10,000 scripts/resources, capture-stage warm medians were 544 → 58 ms, with byte-identical output. Median benchmark-process peak RSS was 199.4 → 206.8 MiB: this trades transient index memory for time. A separate whole-browser experiment reached 1.10 GiB sampled aggregate family RSS; it was not attributed per revision. Browser CPU, agent token usage and cold filesystem performance were not measured. These are local samples, not a universal speedup claim.

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/4350 **Author:** [@leeguooooo](https://github.com/leeguooooo) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/17/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `perf/web-resource-reconciliation` --- ### 📝 Commits (2) - [`b74c855`](https://github.com/morluto/rea/commit/b74c855653c09213e961b53e9159f9446db158d5) perf(browser): 为单次捕获复用脚本资源索引 - [`e406370`](https://github.com/morluto/rea/commit/e4063706b5c0297041c9c86e131bbea526237d90) docs(setup): 说明多会话直接启动以减少 npm 驻留 ### 📊 Changes **4 files changed** (+157 additions, -49 deletions) <details> <summary>View changed files</summary> 📝 `docs/installation.md` (+15 -0) 📝 `src/browser/CdpPageCaptureScripts.ts` (+20 -16) 📝 `src/domain/webInventory.test.ts` (+88 -13) 📝 `src/domain/webInventory.ts` (+34 -20) </details> ### 📄 Description Large page captures scanned the complete resource inventory for every script. Build URL indexes once per capture instead. Keep repeated raw observations ambiguous after public deduplication, preserve sanitized fallback uncertainty, and return independent candidate arrays. No index for empty script inventories; no cache across captures or CLI/MCP contract changes. Also document direct global-CLI setup for concurrent MCP clients, avoiding one npm launcher per connection. This incorporates #4326; each REA connection keeps its own analysis state. Validation: `npm run docs:check` passed after combining the documentation change. Earlier validation: 72 focused tests, `npm run check`, and real Chrome CLI/MCP `verify:browser:scripts` passed, including query-variant isolation and zero implicit refetches. <details> <summary>Measurements</summary> Base `42fc6c53a`, macOS arm64, Node 24.18.0, Chrome 155.0.8059.82. A loaded local page had 5,000 resources and 5,001 scripts; three alternating captures per revision returned identical script/resource inventories. | Capture | Base | Change | |---|---:|---:| | First elapsed | 607 ms | 205 ms | | Later elapsed, median | 399 ms | 150 ms | | Later Node CPU, median | 407 ms | 169 ms | For 10,000 scripts/resources, capture-stage warm medians were 544 → 58 ms, with byte-identical output. Median benchmark-process peak RSS was 199.4 → 206.8 MiB: this trades transient index memory for time. A separate whole-browser experiment reached 1.10 GiB sampled aggregate family RSS; it was not attributed per revision. Browser CPU, agent token usage and cold filesystem performance were not measured. These are local samples, not a universal speedup claim. </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:34 +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#6191
No description provided.