Skip to content

perf: batch Test Explorer test run updates - #346656

Merged
Connor Peet (connor4312) merged 21 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-test-explorer-performance
Nov 11, 2026
Merged

Connor Peet (connor4312) merged 21 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-test-explorer-performance

Conversation

@SimonSiefke

@SimonSiefke Simon Siefke (SimonSiefke) commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Details

Large Test Explorer runs send a separate RPC for each test registration, state change, message and output chunk. Thousands of these messages add work in the extension host and renderer.

Change

Batch ordered updates in BatchedTestRunRpc, with limits on batch size and payload. Flush pending updates before task completion, coverage, result-reading commands and retirement. Support both string and buffer output, and preserve results when profiles share a run.

Performance

5000 Mocha tests

Metric Before After Change
Test-run update RPCs (median) 25,054 297 −98.8%
Extension host CPU time 1,917 ms 647 ms −66.2%
Renderer CPU time 19,377 ms 16,851 ms −13.0%

Extension host

Before

Extension host CPU before batching

After

Extension host CPU after batching

Renderer

Before

Renderer CPU before batching

After

Renderer CPU after batching

CPU profiles captured at 25b632f, before subsequent review fixes.


AI disclosure: Model: GPT 6.1 Sol. Worktime: 83 min

Copilot AI balanced review requested due to automatic review settings November 6, 2026 21:17
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Anthony Kim (@anthonykim1)

Matched files:

  • src/vs/workbench/contrib/terminal/browser/terminal.ts
  • src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The review identifies no active issues that would block approval.

No open issues 🎉

What changed in this PR

This PR improves large Test Explorer runs by reducing extension-host RPC traffic and repeated renderer work in result aggregation and output display.

Changes:

  • Batch ordered test registrations, states, messages, and output, flushing at lifecycle boundaries and size limits.
  • Cache child state and duration information to avoid repeated scans of large suites.
  • Filter unused terminal output markers and add regression coverage for batching, result updates, and disposal.
File Description
src/​vs/​workbench/​contrib/​testing/​test/​common/​getComputedState.test.ts Tests cached aggregation, duration edge cases, and child changes.
src/​vs/​workbench/​contrib/​testing/​test/​browser/​testResultsOutput.test.ts Tests output marker filtering and terminal disposal.
src/​vs/​workbench/​contrib/​testing/​test/​browser/​explorerProjections/​treeProjection.test.ts Covers redundant scans, result clearing, and duration updates.
src/​vs/​workbench/​contrib/​testing/​common/​getComputedState.ts Uses cached child counts for incremental state and duration updates.
src/​vs/​workbench/​contrib/​testing/​browser/​testResultsView/​testResultsOutput.ts Filters unused markers and improves terminal lifecycle handling.
src/​vs/​workbench/​contrib/​testing/​browser/​explorerProjections/​treeProjection.ts Avoids redundant recomputation and handles zero durations correctly.
src/​vs/​workbench/​contrib/​terminal/​browser/​xterm/​xtermTerminal.ts Exposes terminal OSC handler registration.
src/​vs/​workbench/​contrib/​terminal/​browser/​terminal.ts Adds OSC handler registration to the detached terminal interface.
src/​vs/​workbench/​api/​test/​browser/​extHostTesting.test.ts Tests batch ordering, limits, and lifecycle flushing.
src/​vs/​workbench/​api/​common/​extHostTesting.ts Queues and flushes bounded batches of test-run updates.
src/​vs/​workbench/​api/​common/​extHost.protocol.ts Defines the batched update payload and RPC method.
src/​vs/​workbench/​api/​browser/​mainThreadTesting.ts Dispatches received batch entries in order.

Review effort: Balanced

@connor4312 Connor Peet (connor4312) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

awesome thanks!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved batching defects can drop or misorder test updates, leave invalidated results current, and break error peeks and previously supported byte output.

6 open issues

Review effort: Max

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please consider copilot comments

auto-merge was automatically disabled November 9, 2026 10:18

Head branch was pushed to by a user without write access

@SimonSiefke
Simon Siefke (SimonSiefke) marked this pull request as draft November 9, 2026 10:26
@SimonSiefke

Copy link
Copy Markdown
Contributor Author

[ai-response] Implemented in f8be26d9f27b.

  • TestRunTracker creates a BatchedTestRunRpc instance that owns the queue, scheduler, payload limits, buffer copies, delivery, and disposal.
  • Buffer and Uint8Array output now shares the ordered batch queue through the buffer-aware RPC serializer. Bytes remain intact across split UTF-8 chunks and caller buffer reuse.
  • Replaced weak maps with node-owned aggregation caches and a snapshot ID map bounded to the retained 32 results. The PR's changed code and tests contain no WeakMap, WeakSet, or Reflect calls.

Validation: 120 affected unit tests pass, along with the full client type check and targeted hygiene/ESLint.

For a synchronous 5,000-test counting-proxy workload, strings use 42 update RPCs and Buffer/Uint8Array output uses 41. Buffer output previously used 10,025. These are dispatch counts, not IPC or UI timing measurements.

@SimonSiefke

Copy link
Copy Markdown
Contributor Author

[ai-review] Review overview

🔴 Changes required

Reviewed f8be26d9f27b4495d5d0e2634518fa582112a421 with independent GPT-6 Astra/Max and GPT-6.1 Sol/Max reviews. One confirmed production regression and one test-coverage issue remain.

  1. P2 — A later profile's registration batch can erase another profile's failure. Queued registration is tracker-local, while multiple profiles share the same result ID. For the same non-root test, call A.started(t); B.started(t); A.failed(t, message); B.passed(t); A.end(); B.end() without a timer tick. B's later registration reaches addTestChainToRun, which recreates the descendant and resets A's task state/messages. A fresh diagnostic using the actual head's TestRunCoordinator, tracker batches and LiveTestResult produced A=Unset, failure message lost, combined test=Passed; the immediate-delivery control retained A=Failed and its message. Preserve existing per-task state/messages across overlapping profile registrations, or coordinate registration publication across the run, and add a regression using two profiles on the same test and the real result receiver. The existing shared-ID test uses different tests and records dispatch only.

  2. P3 — Advance the batch scheduler in the ended-run guard regression. The post-end assertions check receiver calls while the fake clock remains paused. If the state-mutation ended guard regresses, failed() can enqueue updates that flush only during teardown, after every assertion passed. Advance clock.tick(0) before asserting no batch/state/message/registration delivery; keep the separate synchronous output-guard assertion.

The six earlier review threads are addressed in the current source; the overlapping-profile failure above is an additional ordering case. Candidate client build and full single-threaded native client typecheck pass. Runtime acceptance stopped after the confirmed regression: Code OSS UI/performance/leak comparisons, disposable-leak unit suites and Chromium/WebKit execution remain unverified. No approval recommendation is made.

@SimonSiefke

Copy link
Copy Markdown
Contributor Author

[ai-response] feedback implemented

Addressed both findings from the review in 2dfb33e1b87f.

  • Result-chain registration now reuses existing descendants so overlapping profiles retain each other's task state, durations and failure messages. Two new regressions exercise both completion orders against the real result receiver and verify node identity, combined state and result counts. Both tests failed before the fix.
  • The ended-run guard test now advances the fake clock before checking that no batch, registration, state, message or output reached the receiver; it retains the synchronous output guard assertion.

Validation: all 122 affected unit tests pass, targeted hygiene/ESLint passes, and the full native client typecheck passes with --singleThreaded.

Full Code OSS UI/performance/memory and browser-engine acceptance from the review remains outstanding. Upstream CI is pending for this new commit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved batching defects can reorder cross-profile updates, leave queued Markdown command allowlists mutable, and cause unnecessary buffer copying and memory retention.

4 open issues
2 resolved since last review

Review effort: Max

@SimonSiefke

Copy link
Copy Markdown
Contributor Author

Added some more Copilot fixes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block approval of the test-update batching change.

No open issues 🎉

4 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The batching implementation can reorder concurrent-run updates, accumulate costly scans of undisposed trackers, and undercount UTF-8 payload sizes.

3 open issues

Review effort: Max

@dmitrivMS Dmitriy Vasyura (dmitrivMS) left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ordering and budgeting issues identified by CCR a new to this PR.
The other issue is partially preexisting, so nice to have.

FWIW, testing in Code OSS showed good results!

Flush on run or controller changes and avoid scanning historical test trackers when publishing pending updates.
@SimonSiefke

Copy link
Copy Markdown
Contributor Author

Fixed potential ordering issue with multiple concurrent test runs and simplified batchedRpc a bit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the ordered test-update batching changes.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The WeakMap-to-Map change adds manual pruning and state synchronization without a clear benefit or explained connection to test-run RPC batching.

No open issues 🎉

Review effort: Max

@connor4312
Connor Peet (connor4312) merged commit 8398a4e into microsoft:main Nov 11, 2026
93 of 95 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.147.0 milestone Nov 11, 2026
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/memory-leak-test-explorer-performance branch November 11, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants