From a1257de60500fb9032178687c92611689045e18d Mon Sep 17 00:00:00 2001 From: Zachary Anderson Date: Fri, 10 May 2024 15:43:23 -0700 Subject: [PATCH] Simplify GN pools, use in more places (flutter/engine#52721) This PR changes from using a different GN pool for each non-compiler tool, to using one GN pool for everything. Additionally, since we are no longer linking remotely in any configuration, this PR uses the pool for linking. ObjC and impellerc tasks also do not (yet) run on RBE, so they are also now governed by the pool. Needs https://github.com/flutter/buildroot/pull/856 --- DEPS | 2 +- engine/src/flutter/build/dart/BUILD.gn | 11 ----------- engine/src/flutter/build/dart/rules.gni | 8 ++++---- engine/src/flutter/docs/rbe/rbe.md | 13 +++++++++++-- engine/src/flutter/impeller/tools/BUILD.gn | 19 ------------------- .../src/flutter/impeller/tools/impeller.gni | 1 + engine/src/flutter/impeller/tools/malioc.gni | 2 +- engine/src/flutter/lib/snapshot/BUILD.gn | 2 +- engine/src/flutter/testing/testing.gni | 2 +- engine/src/flutter/tools/gn | 3 +-- engine/src/flutter/web_sdk/BUILD.gn | 8 ++++---- engine/src/flutter/web_sdk/web_sdk.gni | 2 +- 12 files changed, 26 insertions(+), 47 deletions(-) delete mode 100644 engine/src/flutter/impeller/tools/BUILD.gn diff --git a/DEPS b/DEPS index 4c7985aaf4..5d52cb19b7 100644 --- a/DEPS +++ b/DEPS @@ -277,7 +277,7 @@ allowed_hosts = [ ] deps = { - 'src': 'https://github.com/flutter/buildroot.git' + '@' + '70a42312a688890eb1435a8c2760f6cbde324531', + 'src': 'https://github.com/flutter/buildroot.git' + '@' + '7840a4af027fc21161d4ae14a3d4d9c9bab049a2', 'src/flutter/third_party/depot_tools': Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + '580b4ff3f5cd0dcaa2eacda28cefe0f45320e8f7', diff --git a/engine/src/flutter/build/dart/BUILD.gn b/engine/src/flutter/build/dart/BUILD.gn index 4c4d57d069..b9f9d0e883 100644 --- a/engine/src/flutter/build/dart/BUILD.gn +++ b/engine/src/flutter/build/dart/BUILD.gn @@ -7,17 +7,6 @@ import("//flutter/common/config.gni") import("$dart_src/build/dart/copy_tree.gni") -declare_args() { - # Maximum number of Dart processes to run in parallel. - # - # To avoid out-of-memory errors we explicitly reduce the number of jobs. - concurrent_dart_jobs = 1 -} - -pool("dart_pool") { - depth = concurrent_dart_jobs -} - if (build_engine_artifacts) { if (flutter_prebuilt_dart_sdk) { copy_trees("_copy_trees") { diff --git a/engine/src/flutter/build/dart/rules.gni b/engine/src/flutter/build/dart/rules.gni index c8242de63a..6770a8411d 100644 --- a/engine/src/flutter/build/dart/rules.gni +++ b/engine/src/flutter/build/dart/rules.gni @@ -84,7 +84,7 @@ template("flutter_frontend_server") { ], [ "pool" ]) deps = common_deps - pool = "//flutter/build/dart:dart_pool" + pool = "//build/toolchain:toolchain_pool" script = "//build/gn_run_binary.py" inputs = [ invoker.main_dart ] outputs = [ invoker.kernel_output ] @@ -110,7 +110,7 @@ template("flutter_frontend_server") { ], [ "pool" ]) deps = common_deps - pool = "//flutter/build/dart:dart_pool" + pool = "//build/toolchain:toolchain_pool" script = "$dart_src/pkg/frontend_server/bin/frontend_server_starter.dart" inputs = [ invoker.main_dart ] outputs = [ invoker.kernel_output ] @@ -359,7 +359,7 @@ template("application_snapshot") { inputs = extra_inputs outputs = [ output ] depfile = depfile - pool = "//flutter/build/dart:dart_pool" + pool = "//build/toolchain:toolchain_pool" ext = "" if (is_win) { @@ -380,7 +380,7 @@ template("application_snapshot") { "visibility", ]) script = main_dart - pool = "//flutter/build/dart:dart_pool" + pool = "//build/toolchain:toolchain_pool" deps = extra_deps inputs = extra_inputs outputs = [ output ] diff --git a/engine/src/flutter/docs/rbe/rbe.md b/engine/src/flutter/docs/rbe/rbe.md index 8ad8161e21..54ff23c6d2 100644 --- a/engine/src/flutter/docs/rbe/rbe.md +++ b/engine/src/flutter/docs/rbe/rbe.md @@ -151,14 +151,23 @@ RBE builds can be slow for a few different reasons. The most common reason is likely to be that the remote caches are cold. When the caches are warm, a compile step consists only of downloading the compiled TU from the cache. When the caches are cold, the remote workers must run the compilation commands, -which takes more time. +which takes more time. If the worker pool is overloaded, compile commands may +run locally instead, which will also be slower. RBE builds can also be slow if your network connection is bandwidth constrained. Anecdotally, even with a warm cache, I have noticed slow builds from home due to RBE saturating my low-tier Comcast Business connection. +For Googlers on a corp macOS device, both RBE and non-RBE builds can be slow +due to various background and monitoring processes running. See +[here](https://buganizer.corp.google.com/issues/324404733#comment16) for how +to disable some of them. You should also disable Spotlight scanning of the +engine source directory as described +[here](go/building-chrome-mac#add-the-source-directory-to-the-spotlight-privacy-list). + When RBE builds are slow, non-RBE builds may be faster, especially incremental -builds. +builds. You can disable remote builds without invalidating your existing build +by setting the environment variable `RBE_exec_strategy=local`. ### Proxy status and debug logs diff --git a/engine/src/flutter/impeller/tools/BUILD.gn b/engine/src/flutter/impeller/tools/BUILD.gn deleted file mode 100644 index ae1bf97824..0000000000 --- a/engine/src/flutter/impeller/tools/BUILD.gn +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2013 The Flutter Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import("//build/compiled_action.gni") -import("//flutter/common/config.gni") -import("//flutter/impeller/tools/malioc.gni") -import("//flutter/testing/testing.gni") - -declare_args() { - # Maximum number of malioc processes to run in parallel. - # - # To avoid out-of-memory errors we explicitly reduce the number of jobs. - impeller_concurrent_malioc_jobs = 1 -} - -pool("malioc_pool") { - depth = impeller_concurrent_malioc_jobs -} diff --git a/engine/src/flutter/impeller/tools/impeller.gni b/engine/src/flutter/impeller/tools/impeller.gni index 55453fe574..e07fa42286 100644 --- a/engine/src/flutter/impeller/tools/impeller.gni +++ b/engine/src/flutter/impeller/tools/impeller.gni @@ -339,6 +339,7 @@ template("impellerc") { ]) _impellerc(target_name) { + pool = "//build/toolchain:toolchain_pool" shader_bundle = defined(invoker.shader_bundle) # When single_invocation is true, impellerc will be invoked exactly once. When it's diff --git a/engine/src/flutter/impeller/tools/malioc.gni b/engine/src/flutter/impeller/tools/malioc.gni index bc9d7d4686..356fcdcbae 100644 --- a/engine/src/flutter/impeller/tools/malioc.gni +++ b/engine/src/flutter/impeller/tools/malioc.gni @@ -71,7 +71,7 @@ template("malioc_analyze_shaders") { ]) script = "//build/gn_run_malioc.py" - pool = "//flutter/impeller/tools:malioc_pool" + pool = "//build/toolchain:toolchain_pool" # Nest all malioc output under its own subdirectory of root_gen_dir # so that it's easier to diff it against the state before any changes. diff --git a/engine/src/flutter/lib/snapshot/BUILD.gn b/engine/src/flutter/lib/snapshot/BUILD.gn index 270dc680f6..99a431769e 100644 --- a/engine/src/flutter/lib/snapshot/BUILD.gn +++ b/engine/src/flutter/lib/snapshot/BUILD.gn @@ -232,7 +232,7 @@ compile_platform("strong_platform") { "$root_out_dir/flutter_patched_sdk/vm_outline_strong.dill", ] - pool = "//flutter/build/dart:dart_pool" + pool = "//build/toolchain:toolchain_pool" is_runtime_mode_release = flutter_runtime_mode == "release" || flutter_runtime_mode == "jit_release" diff --git a/engine/src/flutter/testing/testing.gni b/engine/src/flutter/testing/testing.gni index 66ac11cffd..6d37b9e2f0 100644 --- a/engine/src/flutter/testing/testing.gni +++ b/engine/src/flutter/testing/testing.gni @@ -108,7 +108,7 @@ template("dart_snapshot_aot") { tool = "$dart_src/runtime/bin:gen_snapshot" - pool = "//flutter/build/dart:dart_pool" + pool = "//build/toolchain:toolchain_pool" inputs = [ invoker.dart_kernel ] diff --git a/engine/src/flutter/tools/gn b/engine/src/flutter/tools/gn index d570a012f3..99bb954651 100755 --- a/engine/src/flutter/tools/gn +++ b/engine/src/flutter/tools/gn @@ -532,7 +532,7 @@ def to_gn_args(args): else: gn_args['dart_runtime_mode'] = runtime_mode - gn_args['concurrent_dart_jobs'] = get_concurrent_jobs('1GB', '1GB') + gn_args['concurrent_toolchain_jobs'] = get_concurrent_jobs('1GB', '100MB') # Hardcoding this avoids invoking a relatively expensive python script from # GN, but removes the ability to use git-worktrees in the Dart checkout from @@ -723,7 +723,6 @@ def to_gn_args(args): malioc_path = os.environ.get('MALIOC_PATH') if malioc_path: gn_args['impeller_malioc_path'] = malioc_path - gn_args['impeller_concurrent_malioc_jobs'] = get_concurrent_jobs('1GB', '100MB') if args.use_glfw_swiftshader: if get_host_os() == 'mac': diff --git a/engine/src/flutter/web_sdk/BUILD.gn b/engine/src/flutter/web_sdk/BUILD.gn index da541632d1..95e6bcd16b 100644 --- a/engine/src/flutter/web_sdk/BUILD.gn +++ b/engine/src/flutter/web_sdk/BUILD.gn @@ -119,7 +119,7 @@ template("_dartdevc") { inputs = invoker.inputs outputs = invoker.outputs - pool = "//flutter/build/dart:dart_pool" + pool = "//build/toolchain:toolchain_pool" ext = "" if (is_win) { @@ -146,7 +146,7 @@ template("_dartdevc") { script = "$dart_src/pkg/dev_compiler/bin/dartdevc.dart" - pool = "//flutter/build/dart:dart_pool" + pool = "//build/toolchain:toolchain_pool" } } } @@ -169,7 +169,7 @@ template("_kernel_worker") { inputs = invoker.inputs outputs = invoker.outputs - pool = "//flutter/build/dart:dart_pool" + pool = "//build/toolchain:toolchain_pool" ext = "" if (is_win) { @@ -197,7 +197,7 @@ template("_kernel_worker") { script = "$dart_src/utils/bazel/kernel_worker.dart" - pool = "//flutter/build/dart:dart_pool" + pool = "//build/toolchain:toolchain_pool" } } } diff --git a/engine/src/flutter/web_sdk/web_sdk.gni b/engine/src/flutter/web_sdk/web_sdk.gni index 2cbf17b07f..b4d55fdc4f 100644 --- a/engine/src/flutter/web_sdk/web_sdk.gni +++ b/engine/src/flutter/web_sdk/web_sdk.gni @@ -20,7 +20,7 @@ template("sdk_rewriter") { prebuilt_dart_action(target_name) { packages = dart_sdk_package_config - pool = "//flutter/build/dart:dart_pool" + pool = "//build/toolchain:toolchain_pool" script = "//flutter/web_sdk/sdk_rewriter.dart"