未验证 提交 70352550 编写于 作者: Y Yegor 提交者: GitHub

make compiler worker count configurable (#17616)

* make compiler worker count configurable
上级 68bf1376
## What's `felt`? ## What's `felt`?
`felt` stands for "Flutter Engine Local Tester". It's a cli tool that aims to make development in the Flutter web engine more productive and pleasant. `felt` stands for "Flutter Engine Local Tester". It's a cli tool that aims to make development in the Flutter web engine more productive and pleasant.
## What can `felt` do? ## What can `felt` do?
`felt` supports multiple commands as follows: `felt` supports multiple commands as follows:
1. **`felt check-licenses`**: Checks that all Dart and JS source code files contain the correct license headers. 1. **`felt check-licenses`**: Checks that all Dart and JS source code files contain the correct license headers.
...@@ -11,26 +13,40 @@ ...@@ -11,26 +13,40 @@
You could also run `felt help` or `felt help <command>` to get more information about the available commands and arguments. You could also run `felt help` or `felt help <command>` to get more information about the available commands and arguments.
## How can I use `felt`? ## How can I use `felt`?
Once you have your local copy of the engine [setup](https://github.com/flutter/flutter/wiki/Setting-up-the-Engine-development-environment), it's recommended that you add `/path/to/engine/src/flutter/lib/web_ui/dev` to your `PATH`. Once you have your local copy of the engine [setup](https://github.com/flutter/flutter/wiki/Setting-up-the-Engine-development-environment), it's recommended that you add `/path/to/engine/src/flutter/lib/web_ui/dev` to your `PATH`.
Then you would be able to use the `felt` tool from anywhere: Then you would be able to use the `felt` tool from anywhere:
``` ```
felt check-licenses felt check-licenses
``` ```
or: or:
``` ```
felt build --watch felt build --watch
``` ```
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>` 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>`
## Speeding up your builds ## Speeding up your builds and tests
You can speed up your builds by using more CPU cores. Pass `-j` to specify the desired level of parallelism, like so:
You can speed up `ninja` and `dart2js` by adding parallelism and taking advantage of more cores.
To speed up ninja pass `-j` to specify the desired level of parallelism, like so:
``` ```
felt build [-w] -j 100 felt build [-w] -j 100
``` ```
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. 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.
By default, when compiling Dart code to JavaScript, we use 4 `dart2js` workers.
If you need to increase or reduce the number of workers, set the `BUILD_MAX_WORKERS_PER_TASK`
environment variable to the desired number.
## Running web engine tests ## Running web engine tests
To run all tests on Chrome. This will run both integration tests and the unit tests: To run all tests on Chrome. This will run both integration tests and the unit tests:
``` ```
...@@ -86,6 +102,7 @@ felt test test/golden_tests/engine/canvas_golden_test.dart ...@@ -86,6 +102,7 @@ felt test test/golden_tests/engine/canvas_golden_test.dart
``` ```
To debug a test on Chrome: To debug a test on Chrome:
``` ```
felt test --debug test/golden_tests/engine/canvas_golden_test.dart felt test --debug test/golden_tests/engine/canvas_golden_test.dart
``` ```
...@@ -110,7 +127,9 @@ To make sure you are running the `felt` tool with your changes included, you wou ...@@ -110,7 +127,9 @@ To make sure you are running the `felt` tool with your changes included, you wou
``` ```
FELT_USE_SNAPSHOT=false felt <command> FELT_USE_SNAPSHOT=false felt <command>
``` ```
or or
``` ```
FELT_USE_SNAPSHOT=0 felt <command> FELT_USE_SNAPSHOT=0 felt <command>
``` ```
......
...@@ -392,11 +392,25 @@ class TestCommand extends Command<bool> with ArgUtils { ...@@ -392,11 +392,25 @@ class TestCommand extends Command<bool> with ArgUtils {
'--build-filter=${path.relativeToWebUi}.browser_test.dart.js', '--build-filter=${path.relativeToWebUi}.browser_test.dart.js',
], ],
]; ];
final Stopwatch stopwatch = Stopwatch()..start();
final int exitCode = await runProcess( final int exitCode = await runProcess(
environment.pubExecutable, environment.pubExecutable,
arguments, arguments,
workingDirectory: environment.webUiRootDir.path, workingDirectory: environment.webUiRootDir.path,
environment: <String, String>{
// This determines the number of concurrent dart2js processes.
//
// By default build_runner uses 4 workers.
//
// In a testing on a 32-core 132GB workstation increasing this number to
// 32 sped up the build from ~4min to ~1.5min.
if (io.Platform.environment.containsKey('BUILD_MAX_WORKERS_PER_TASK'))
'BUILD_MAX_WORKERS_PER_TASK': io.Platform.environment['BUILD_MAX_WORKERS_PER_TASK'],
},
); );
stopwatch.stop();
print('The build took ${stopwatch.elapsedMilliseconds ~/ 1000} seconds.');
if (exitCode != 0) { if (exitCode != 0) {
throw ToolException( throw ToolException(
......
...@@ -41,6 +41,7 @@ Future<int> runProcess( ...@@ -41,6 +41,7 @@ Future<int> runProcess(
List<String> arguments, { List<String> arguments, {
String workingDirectory, String workingDirectory,
bool mustSucceed: false, bool mustSucceed: false,
Map<String, String> environment = const <String, String>{},
}) async { }) async {
final io.Process process = await io.Process.start( final io.Process process = await io.Process.start(
executable, executable,
...@@ -50,6 +51,7 @@ Future<int> runProcess( ...@@ -50,6 +51,7 @@ Future<int> runProcess(
// the process is not able to get Dart from path. // the process is not able to get Dart from path.
runInShell: io.Platform.isWindows, runInShell: io.Platform.isWindows,
mode: io.ProcessStartMode.inheritStdio, mode: io.ProcessStartMode.inheritStdio,
environment: environment,
); );
final int exitCode = await process.exitCode; final int exitCode = await process.exitCode;
if (mustSucceed && exitCode != 0) { if (mustSucceed && exitCode != 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册