Skip to content

incompatible_list_based_execution_strategy_selection: List-based explicit spawn strategy selection.Β #7480

@philwo

Description

@philwo

For more detailed description visit our blog post: https://blog.bazel.build/2019/06/19/list-strategy.html

πŸ™…β€β™‚οΈ Current situation:

  • The user can set the execution strategy in general and for individual action mnemonics using the flags --spawn_strategy=, --strategy=Mnemonic= and --strategy_regexp=Regex=. The flags take a single strategy name as value. Example: --spawn_strategy=linux-sandbox.
  • Bazel has a hardcoded and undocumented list of mnemonics that are known to work well with certain strategies and uses these unless the user overrides them individually using --strategy=Mnemonic= flags. Example: Bazel will use some kind of sandboxing by default if its available on your system, otherwise non-sandboxed execution (e.g. on Windows). However, it will run Javac actions via the persistent worker strategy.
  • Each strategy has custom code to deal with the situation that it can't execute a given action - for example, the remote strategy silently falls back to sandboxed execution if an action can't run remotely. The sandbox strategy silently falls back to non-sandboxed local execution if an action doesn't support sandboxing. There's no good way to configure this behavior.

πŸ†• The option --incompatible_list_based_execution_strategy_selection:

  • Allows the user to pass comma-separated lists of strategies to the above mentioned flags: --spawn_strategy=remote,worker,linux-sandbox.
  • Each strategy now knows whether it can execute a given action. For any action that it wants to execute, Bazel just picks the first strategy from the given list that claims to be able to execute the action. If no strategy remains, the execution will fail.
  • This means you can now have your build fail if any non-sandboxable or non-remotable action sneaks in! More reproducibility and safety for your builds! πŸŽ‰
  • The strategies no longer do their own custom fallback, simplifying the code and unifying the behavior.

πŸ’‘ Some ideas how to use this:

  • Don't set any flags and Bazel will try to do the best automatically: Use remote execution if it's available, otherwise persistent workers, otherwise sandboxed execution, otherwise non-sandboxed execution.
  • I want the best sandboxed build on my Linux machine and no automatic fallback to symlink-only sandboxing, non-sandboxed execution and no persistent workers: --spawn_strategy=linux-sandbox.
  • I want persistent workers for actions that support it, but otherwise only sandboxed execution: --spawn_strategy=worker,sandboxed.

🚧 Migration needed:

  • If you currently use the strategy selection flags, you'll want to revisit the values you set them to.
  • If you currently patch your Bazel version to remove fallback to non-sandboxed execution, this should no longer be necessary then (:wave: @AustinSchuh).
  • If you currently use remote execution with --strategy=remote and/or --spawn_strategy=remote and have actions that might not be executed remotely, consider removing those strategy flags completely, in this case bazel will pickup the first available strategy from the default list, which is remote,worker,sandboxed,local. Alternatively, add a strategy to fallback to if remote is not possible for an action, for example --spawn_strategy=remote,sandboxed will fallback to a sandboxed execution if remote is not possible.
  • If you are using --config=remote you might need to change your .bazelrc file, where all the remote configs are located, including strategy flags.

Metadata

Metadata

Assignees

Labels

incompatible-changeIncompatible/breaking changeteam-Remote-ExecIssues and PRs for the Execution (Remote) team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions