Skip to content

Commit b297796

Browse files
authored
Set --no-js-strongly-connected-components for DDC compiles by default (#193485)
Context: DDC's old module system was sensitive to load order, so mutual/cyclic imports needed to be combined into a single 'module' (using a strongly-connected-components/SCC algorithm in our various build infrastructure). DDC's new Library Bundle module system doesn't have this restriction, so we can safely disable SCCs. The net result is that every library emits one JS artifact, which helps us avoid problems with overly large connected components causing parse deoptimizations in Chrome/V8. More artifacts are emitted (so perhaps higher compile time), but the overall load time is improved - especially for larger apps. Resolves some of the performance degradations reported in: #192687
1 parent d4c0acd commit b297796

3 files changed

Lines changed: 30 additions & 5 deletions

File tree

‎packages/flutter_tools/lib/src/compile.dart‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ import 'dart/package_map.dart';
2828
/// Opt-in changes to the dart compilers.
2929
const kDartCompilerExperiments = <String>[];
3030

31+
// Flags passed when compiling with DDC.
32+
const kDdcLibraryBundleFlags = <String>[
33+
'--dartdevc-module-format=ddc',
34+
'--dartdevc-canary',
35+
'--no-js-strongly-connected-components',
36+
];
37+
3138
/// The target model describes the set of core libraries that are available within
3239
/// the SDK.
3340
class TargetModel {
@@ -567,9 +574,7 @@ class ResidentCompilerFactory {
567574
fileSystemScheme: 'org-dartlang-app',
568575
extraFrontEndOptions: [
569576
...buildInfo.extraFrontEndOptions,
570-
if (buildInfo.webEnableHotReload)
571-
// These flags are only valid to be passed when compiling with DDC.
572-
...<String>['--dartdevc-canary', '--dartdevc-module-format=ddc'],
577+
if (buildInfo.webEnableHotReload) ...kDdcLibraryBundleFlags,
573578
],
574579
);
575580
} else {

‎packages/flutter_tools/test/general.shard/compile_test.dart‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,4 +349,26 @@ void main() {
349349
// match.
350350
await completer.future.timeout(const Duration(seconds: 5));
351351
});
352+
353+
testWithoutContext('ResidentCompilerFactory configures DDC library bundle flags', () {
354+
final compiler = const ResidentCompilerFactory().create(
355+
targetPlatform: .web_javascript,
356+
buildInfo: const BuildInfo(
357+
BuildMode.debug,
358+
null,
359+
treeShakeIcons: false,
360+
packageConfigPath: '.dart_tool/package_config.json',
361+
webEnableHotReload: true,
362+
),
363+
logger: BufferLogger.test(),
364+
processManager: FakeProcessManager.any(),
365+
artifacts: Artifacts.test(),
366+
platform: FakePlatform(),
367+
fileSystem: MemoryFileSystem.test(),
368+
shutdownHooks: FakeShutdownHooks(),
369+
config: Config.test(),
370+
) as DefaultResidentCompiler;
371+
372+
expect(compiler.extraFrontEndOptions, containsAll(kDdcLibraryBundleFlags));
373+
});
352374
}

‎packages/flutter_tools/test/general.shard/resident_web_runner_test.dart‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ const kStartPausedAndAttachExpectations = <VmServiceExpectation>[
9494
...kAttachIsolateExpectations,
9595
];
9696

97-
const kDdcLibraryBundleFlags = <String>['--dartdevc-module-format=ddc', '--dartdevc-canary'];
98-
9997
void main() {
10098
late FakeDebugConnection debugConnection;
10199
late FakeChromeDevice chromeDevice;

0 commit comments

Comments
 (0)