DDC / DDK Closures contain a massive amount of state which severely impacts debugging

This issue was brought to my attention through dart-lang/webdev#800

Reproduction steps:

  1. Build and serve the following application with DDC, e.g. webdev serve.
import 'dart:async';

Future<int> recurse(int count) async {
  if (count == 0) {
    return count;
  }
  return recurse(count - 1);
}

void main() async {
  await recurse(100);
}
  1. Using Chrome DevTools set a breakpoint on the line that contains return count;.

  2. Once the breakpoint is hit, try to step over. Notice that stepping takes several seconds when it should be nearly instant.

Root cause:

The issue is caused by the captured Closure context for a runBody call inside the Dart SDK. These contexts contain tons and tons of constant symbols, for example:

Screenshot from 2019-10-30 17-28-33

When debugging, this information is serialized and sent to the Chrome debugger (or package:dwds). This causes significant slow downs. We should be able to collect these top level symbols into a single map which resolve this issue.

Author: Fantashit

1 thought on “DDC / DDK Closures contain a massive amount of state which severely impacts debugging

Comments are closed.