Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 795e05c

Browse files
committed
make compiler worker count configurable; increase default
1 parent e595437 commit 795e05c

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

lib/web_ui/dev/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,20 @@ felt build --watch
2323

2424
If you don't want to add `felt` to your path, you can still invoke it using a relative path like `./web_ui/dev/felt <command>`
2525

26-
## Speeding up your builds
26+
## Speeding up your builds and tests
27+
2728
You can speed up your builds by using more CPU cores. Pass `-j` to specify the desired level of parallelism, like so:
29+
2830
```
2931
felt build [-w] -j 100
3032
```
33+
3134
If you are a Google employee, you can use an internal instance of Goma to parallelize your builds. Because Goma compiles code on remote servers, this option is effective even on low-powered laptops.
3235

36+
By default, when compiling Dart code to JavaScript, we use 16 `dart2js` workers.
37+
If you need to increase or reduce the number of workers, set the `BUILD_MAX_WORKERS_PER_TASK`
38+
environment variable to the desired number.
39+
3340
## Running web engine tests
3441
To run all tests on Chrome. This will run both integration tests and the unit tests:
3542

lib/web_ui/dev/test_runner.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,32 @@ class TestCommand extends Command<bool> with ArgUtils {
356356
'--build-filter=${path.relativeToWebUi}.browser_test.dart.js',
357357
],
358358
];
359+
final Stopwatch stopwatch = Stopwatch()..start();
360+
361+
// Increase the number of worker processes.
362+
//
363+
// By default build_runner will limit the number of workers to 4, which
364+
// doesn't take advantage of multiple CPU cores. 16 is picked because
365+
// typically engine contributors will have anywhere from 4 to 56
366+
// hyperthreaded CPU cores, i.e. 8-112 hardware threads, and from 16GB
367+
// to 132GB of RAM, which should be both not too low and not too high.
368+
//
369+
// In a testing on a 32-core 132GB workstation this sped up the build
370+
// from ~4min to ~1.5min.
371+
String maxWorkersPerTask = io.Platform.environment.containsKey('BUILD_MAX_WORKERS_PER_TASK')
372+
? io.Platform.environment['BUILD_MAX_WORKERS_PER_TASK']
373+
: '16';
374+
359375
final int exitCode = await runProcess(
360376
environment.pubExecutable,
361377
arguments,
362378
workingDirectory: environment.webUiRootDir.path,
379+
environment: <String, String>{
380+
'BUILD_MAX_WORKERS_PER_TASK': maxWorkersPerTask,
381+
},
363382
);
383+
stopwatch.stop();
384+
print('The build took ${stopwatch.elapsedMilliseconds ~/ 1000} seconds.');
364385

365386
if (exitCode != 0) {
366387
io.stderr.writeln(

lib/web_ui/dev/utils.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Future<int> runProcess(
4141
List<String> arguments, {
4242
String workingDirectory,
4343
bool mustSucceed: false,
44+
Map<String, String> environment = const <String, String>{},
4445
}) async {
4546
final io.Process process = await io.Process.start(
4647
executable,
@@ -50,6 +51,7 @@ Future<int> runProcess(
5051
// the process is not able to get Dart from path.
5152
runInShell: io.Platform.isWindows,
5253
mode: io.ProcessStartMode.inheritStdio,
54+
environment: environment,
5355
);
5456
final int exitCode = await process.exitCode;
5557
if (mustSucceed && exitCode != 0) {

0 commit comments

Comments
 (0)