Skip to content

A large number of test output events cause hangs in the VS Code UI #266048

@DanTup

Description

@DanTup

I had an issue reported against the Dart extension at Dart-Code/Dart-Code#5690 that the built-in terminal was very slow during test runs. It seemed to be related to a large amount of logging output from the test.

In an attempt to reproduce this, I created a simple test that just sends a lot of output events:

import 'package:test/test.dart';

void main() {
  test('calculate', () async {
    for (var i = 0; i < 10000; i++) {
      print('Iteration $i');
      await Future.delayed(const Duration(microseconds: 750));
    }
  });
}

When I run this, VS Code completely hangs for long periods during the run and takes a long time to "catch up" with the output.

Profiling the extension host didn't reveal anything, but profiling the VS Code UI does show a lot of scripting. I'm not familiar with this code, but I think the call tree suggests that the output events are triggering decoration updates and perhaps that's quite expensive:

Image

Perhaps any updates triggered by output should be batched/debounced, since a lot of output is not uncommon when logging/debugging things.

Here is the exported CPU profile: vs_code_slow_test_profile.zip

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable bugfreeze-slow-crash-leakVS Code crashing, performance, freeze and memory leak issuestestingBuilt-in testing support

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions