Skip to content

perf: bound VS Code analysis and mutation memory below 2 GB - #258

Merged
mherod merged 14 commits into
mainfrom
codex-vscode-performance
Oct 21, 2026
Merged

mherod merged 14 commits into
mainfrom
codex-vscode-performance

Conversation

@mherod

@mherod mherod commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

VS Code analysis and mutations could retain 6–7 GB of parser state. The measured fixture workloads now stay below the 2,000,000,000-byte acceptance ceiling, including the caller and analysis processes, while preserving complete reports, similarity scores, ordered edits, applied bytes, and rollback behavior.

Large analyses use bounded workers, streamed graph metadata, disposable planning processes, and bounded similarity caches. Exact overlap bounds sift similarity candidates without changing greedy grouping or output order. Incremental graph updates reuse unchanged records. Unknown package entrypoints retain explicit explanations and cannot authorize destructive verdicts.

Standalone MCP isolation uses the shared 2,048-source-file threshold. Sizing resolves the actual project config, includes unique sibling-package sources in workspace mode, and handles source-subdirectory and explicit-project requests. Small projects retain warm caches. Writes and verification remain in the caller. Workers are terminated only while still live, preventing the Linux Bun hang after a successful worker exit.

Validation

  • Full suite: 1,336 passed, 0 failed, 4,746 assertions across 107 files. Typecheck, lint, compiled CLI/MCP builds, library build, and package-size checks pass locally; final CI status is shown by the PR checks.
  • Regression tests cover resolved isolation scope, workspace deduplication, identical isolated/in-process reports, deterministic cache-invalidation timestamps, clean exit/error/cancellation handling, and compiled worker assets.
  • Pinned VS Code 225a0fa530ceff3013168a5c023290d0e8a4024b: worst mutation CLI peak 1.010 GB; read-only CLI 1.191 GB; 21-call applied MCP session 1.776 GB; mixed previews 1.417 GB. Full similarity output preserves all 3,809 groups exactly.
  • Rename/move previews reduce peak memory by 87%/84% against the corrected full-program baseline, with approximately 5.2/7.9 seconds additional latency.

Detailed methodology and measurement provenance are in the performance report. These recorded fixture benchmarks were not rerun for the requirements repair and final scope-selection fixes.

Requirements

Preserves all 82 scenario blocks and their metadata. Oversized register cells move verbatim to linked details, and every physical requirements line is within 200 Unicode code points. The receipt contains portable validator provenance and separate passing structure, document-quality, and implementation evidence. Repository guidance now matches the validator contract.

Fixes #259.

Tradeoffs and boundaries

Large-project MCP calls discard parser caches after each call, raising warm-call latency substantially (the recorded VS Code analyze case rises from about 1.2 s to 30 s), and heavy jobs are serialized. Small projects and ordinary library callers retain their caches.

This is measured fixture acceptance, not an OS-enforced cap. The fixture has no installed dependencies: missing required types produce an incomplete verification result before starting the full compiler. Rename rolls back; plain move preserves its existing leave-applied policy. Successful VS Code typechecking and memory use with dependencies installed are not claimed.

Record fresh CLI and repeated/concurrent MCP timings, process peak RSS,
and complete report parity against a pinned clean source fixture.
Reject timeouts, process errors, output drift, and the 2 GB ceiling.

The first full run passes all 15 CLI outputs and all 20 MCP reports but
exposes a 3.74 GB mixed-session peak. Preserve that failing baseline
and prioritize MCP retention in the documented five-job plan.
Keep parsing and grouping in disposable worker VMs with bounded scheduling
and clean exit checks. Cache one immutable declaration and grouping snapshot,
avoid decoding declarations for repeated reports, and use compact numeric
fingerprints without changing similarity scores or ordering.

The pinned VS Code mixed session peaks at 1.868 GB instead of 3.741 GB.
All 20 MCP reports, 15 fresh CLI reports and 3,809 complete similarity groups
match their baselines. Preserve synchronous library search and add the async
worker path for CLI, MCP and library command calls.

Share cache-reset operations with workspace discovery so companion maps
are cleared together without duplicating reset implementations.
Validate source membership, imported source mtimes and resolver filesystem
inputs before reusing plain graph records. Reparse small edits without retaining
ASTs and bound incremental resolution history with periodic full rebuilds.
Invalidate discovery on source additions, renames and deletions, including
outside include roots and explicitly included hidden directories.

Add a disposable VS Code edit harness that compares complete ordered records
against fresh graphs without materializing duplicate whole-graph JSON strings.
Report exact unresolved targets and manifest paths through analyze and unused.
Prove emitted entrypoint mappings with explicit compiler layouts and preserve
unknown usage for incomplete, ambiguous or out-of-graph package surfaces.
Include emitter settings in graph cache validity and retain config provenance.

Give standalone test projects their own package boundary and test public,
imported, internal and dead exports alongside failure and invalidation cases.
Add a VS Code comparator allowing only the documented additive explanations.
Stream move and rename graphs and lexical scopes, compact edit spans, and apply
plans only after the analysis process exits cleanly. Isolate standalone MCP
analysis jobs and reclaim similarity temporaries between bounded batches.
Preserve complete reports, ordering, conflicts, verification and rollback.

Preflight missing type dependencies without claiming a successful check. Count
native parent and worker peaks together and exercise repeated, concurrent and
applied fixture workloads. Include workers in source, compiled and library
entrypoints, including nested bundles. Repeated MCP calls trade cache hits for
bounded retention; record that latency cost with the benchmark evidence.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T12:57:29.811808Z 904c480 New commits
🔒 Security Review ✅ Completed 2026-10-21T08:42:50.519850Z 8a1d9d8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@mherod

mherod commented Oct 21, 2026

Copy link
Copy Markdown
Owner Author

Merge gate: requirements audit blocked by #259

CI is green on 13c9016 (run 39585535408, ~6 min — the worker-termination fix resolves the Linux hang). Lint, typecheck and the full local suite (1,334 tests) pass, and there are no review threads or linked issues.

The diff changes the engines behind many declared scenarios (ANLY-, AUDIT-, BATCH-*, find/similar/move/rename), so a focused requirements audit is required before merge. That audit cannot run:

Layer Result
Structure FAIL — 8 errors, all in .requirements-status.json: four persisted command properties ($.validator, $.validation.structure, $.validation.documentQuality, $.validation.implementation) each embedding a user home-directory path
Document quality NOT RUN — 21 physical lines over 200 code points; no repository-owned override exists
Implementation NOT RUN — the audit stops at the structure gate, so no per-scenario Fidelity is reported

REQUIREMENTS.md itself passes assert-canonical (82 canonical records, sha256 ff6b237c…). This PR modifies neither requirements artifact; the failure is pre-existing on main.

Owner / next action: repair the receipt and line lengths under #259 on main, then re-run the focused audit on this head and merge.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 13c9016181

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/mcp-tools/isolated-read-only.ts Resolved
Comment thread src/core/graph-incremental.test.ts Resolved
mherod added a commit that referenced this pull request Oct 21, 2026
runWorkerJob always awaited worker.terminate() in finally, including
after the worker had already emitted exit. On the Linux runner (Bun
1.3.14) terminating an exited worker blocks or kills the caller
(cf. oven-sh/bun#11335): main CI has hung until cancellation since
136fd75, and published 1.8.3 carries the same path. Track the exit and
terminate only a live worker. Fail a hung CI job after 20 minutes
instead of the 6 hour default.

Refs #258
Preserve all 82 scenarios and relocate oversized register cells to linked
details. Replace machine-specific receipt commands with portable validator
provenance and current clause/test evidence, and align repository guidance.
Give source and manifest rewrites distinct mtimes so incremental graph tests
do not depend on filesystem timestamp resolution.
Resolve ancestor and explicit projects before counting source ownership.
Include unique sibling-package sources in workspace analysis so narrowed
report directories cannot keep large graphs in the long-lived server.

Preserve warm small-project execution and exact isolated report parity.
Refresh source provenance and validation evidence after the isolation-scope
and cache-test corrections. Preserve all product scenarios and metadata.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(requirements): repair receipts rejected by the validator

1 participant