Skip to content

Test Run completion takes very long on many tests (after RunHandler is completed) #238241

Closed

Description

Type: Performance Issue

Description
I am the author of mocha-vscode and noticed quite significant performance issue when executing a huge number of tests. First I suspected a problem in my extension but realized that my code had already completed and vscode was still performing updates in the UI.

I am executing ~5k tests and Mocha completes within 1-2secs and within my extension the whole RunHandler is completed. But VSCode still takes a significant amount of time to update all status information for the tests and show the log outputs of the extension.

Here a video showing the UI stall and long test execution (despite the RunHandler completed)

vscode-slow.mp4

It look to the user as if the test execution is ongoing and users get this experience:

  • They might think the test execution is to blame and attempt cancelling it. But cancelling does nothing in this case.
  • The UI is still partly responsive so they might want to check logs which are also frozen.
  • They still get test updates, just very slow and they have to wait quite some time for it to finish.

All the calls made to the TestRun to update status information are internally queued and then executed on the UI thread causing delays. If there is anything I could do from my extension I'm happy to change.

**Steps to reproduce: **
Follow the readme in https://github.com/Danielku15/vscode-test-explorer-performance

VS Code version: Code 1.96.3 (91fbddd, 2025-01-09T18:14:09.060Z)
OS version: Windows_NT x64 10.0.26100
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i7-10700K CPU @ 3.80GHz (16 x 3792)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 63.92GB (40.60GB free)
Process Argv --crash-reporter-id 4382a838-d161-4bfb-8e70-abd05b5ada08
Screen Reader no
VM 0%
Extensions (22)
Extension Author (truncated) Version
ng-template Ang 19.0.4
vscode-eslint dba 3.0.10
vscode-ast ddo 0.0.3
vscode-html-css ecm 2.0.12
prettier-vscode esb 11.0.0
vscode-github-actions git 0.27.0
vscode-peacock joh 4.2.2
csharp ms- 2.61.28
vscode-dotnet-runtime ms- 2.2.5
remote-containers ms- 0.394.0
remote-wsl ms- 0.88.5
cmake-tools ms- 1.19.52
cpptools ms- 1.22.11
cpptools-extension-pack ms- 1.3.0
extension-test-runner ms- 0.0.12
hexeditor ms- 1.11.1
test-adapter-converter ms- 0.2.1
vetur oct 0.37.3
markdown-preview-enhanced shd 0.8.15
cmake twx 0.0.17
vscode-mdx uni 1.8.13
vscode-mdx-preview xyc 0.3.3

(1 theme extensions excluded)

A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythonnoceb:30805159
pythonmypyd1:30879173
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
dvdeprecation:31068756
dwnewjupyter:31046869
nativerepl2:31139839
pythonrstrctxt:31112756
nativeloc1:31192215
cf971741:31144450
iacca1:31171482
notype1cf:31157160
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530
6074i472:31201624
dwoutputs:31217127

Activity

  1. vs-code-engineering commented on Jan 19, 2025

    @vs-code-engineering
    Contributor

    Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.96.4. Please try upgrading to the latest version and checking whether this issue remains.

    Happy Coding!

  2. Danielku15 commented on Jan 19, 2025

    @Danielku15
    Author

    The problem also exists in the latest version.

    Version: 1.96.4 (user setup)
    Commit: cd4ee3b1c348a13bafd8f9ad8060705f6d4b9cba
    Date: 2025-01-16T00:16:19.038Z
    Electron: 32.2.6
    ElectronBuildId: 10629634
    Chromium: 128.0.6613.186
    Node.js: 20.18.1
    V8: 12.8.374.38-electron.0
    OS: Windows_NT x64 10.0.26100
    
  3. tuxStarElan commented on Nov 7, 2025

    @tuxStarElan

    I have the same problem when writing a custom test adapter.

    One of the RunProfiles does not perform any actual tests, but reads the results of a nightly test run and is finished in about 2 seconds. But the user interface slows down after about 2000 of 10000 test cases and is finished after about 2 minutes.

    I was able to trace the problem to the use of ‘TestRun.enqueued’ followed by ‘TestRun.passed’ or ‘TestRun.failed’, as would be the case with normal test runs. In my use case, I was able to work around the problem by skipping the call to ‘TestRun.enqueued’ for this specific RunProfile.

    Perhaps this can help you find the cause of the problem.

    Kind regards,
    m.schoenherr

  4. added
    bug
    testing
    on Dec 8, 2025
  5. tuxStarElan commented on Feb 5, 2026

    @tuxStarElan

    Any updates on this issue?
    This problem is still quite frustrating because, during normal test runs with a large number of tests, it becomes very confusing. After hitting the cancel button, the system remains busy for up to 2 minutes updating the test case results.

  6. tuxStarElan commented on Feb 9, 2026

    @tuxStarElan

    Further observations:
    I managed to solve the problem by reporting any changes of the test run results only every 1 second. At this point i report the currently running tests as started, and all finished tests so far. Additionally i skip the duration field if the duration is less than a given threshhold (200ms for me), and append testoutput only for failed tests. As far as i could observe the main culprit is the frequent update of the testtree state. So reducing the number of run.started calls and reducing the need of duration calculation for fast tests solved the problem.

  7. Indy-rbo commented on Nov 3, 2026

    @Indy-rbo

    We’re still encountering this with VS Code 1.144.1 and vscode-jest 6.4.4, running approximately 8,500 tests with coverage disabled.

    The first run after reloading the window takes ~20 seconds. Subsequent runs take ~60 seconds, including ~30 seconds of UI unresponsiveness. Clearing test results doesn’t help, but reloading the window restores initial performance. Freeze traces point to test-state updates triggering repeated tree rendering and setupManagedHover calls. We also observed substantial event-listener accumulation, which may contribute to the slowdown.

    Is there any update on this issue, or a recommended mitigation for extension authors? Happy to provide sanitized logs or help validate a potential fix.

  8. added
    unreleased
    on Nov 4, 2026
  9. added this to the 1.146.0 milestone on Nov 4, 2026
  10. vs-code-engineering commented on Nov 4, 2026

    @vs-code-engineering
    Contributor

    Sharing media and context from merged PR #345896 for verification:

    Details

    Large test runs send many state and duration changes for the same visible rows. Each change creates another managed hover and rebuilds the row's actions. The repeated listener and action work delays the renderer after Mocha has finished.

    Change

    Keep one hover per row template and update its contents. Batch row renders within an event-loop turn, cancel pending renders when a row is removed, and dispose both row and template resources.

    Before

    Much of the renderer CPU time is spent on event listener work from repeatedly creating row hovers and rebuilding actions.

    Before

    After

    79.1% less renderer CPU time for 500 Mocha tests.

    After

    Test Video

    Test.webm

    Additional Details

    Running 5000 Mocha Tests in VSCode

    Metric Before (ms) After (ms) Change
    Renderer CPU 949,320 15,780 -98.3%
    Extension-host CPU 7,900 3,840 -51.4%
    Run to rendered output 897,007 13,668 -98.5%
    Full e2e wall time 915,180 32,505 -96.4%
    Standalone Mocha CLI wall time 547 547 -

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

    Source PR: #345896

  11. added
    insiders-released
    and removed
    unreleased
    on Nov 4, 2026
  12. added
    verified
    author-verification-requested
    on Nov 9, 2026
  13. rwoll commented on Nov 9, 2026

    @rwoll
    Member

    Daniel Kuschny (@Danielku15) - we merged in some changes that should improve this. Please let us know if it's working better for you now in Insiders version of VS Code. Cheers!

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

Metadata

Metadata

Labels

author-verification-requestedbuginsiders-releasedperftestingverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions