feat: integrate bazel resource_sets into the build actions#1465
Open
feat: integrate bazel resource_sets into the build actions#1465
Conversation
Collaborator
Author
|
Note: depends on #1464, which should be merged first. |
This is an attempt to make parallelization of builds safer by telling bazel what resources an action will consume. By default, Bazel allocates 1 CPU and 250M of RAM, and this makes the current methods of parallelization (i.e. --action_env=CMAKE_BUILD_PARALLEL_LEVEL=16) pretty unpleasant, since bazel won't know and will happily schedule 160 cores worth of actions on a 10-core machine. I have added resource_size declarations to several of the base requirement tools (make|cmake|ninja|pkgconfig)_tool, which drastically speeds up the CI environment and build iteration speed. This also adds a wrapper binary for ninja, because ninja doesn't support environment variables. It's c++ instead of bash or python because it needs to be invoked after changing the working directory, and the shim scripts that are used to launch bash or python on windows rely on runfiles, which don't work if you change the wd.
c5c833d to
c2737dc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
This is an attempt to make parallelization of builds safer by telling bazel what resources an action will consume. By default, Bazel allocates 1 CPU and 250M of RAM, and this makes the current methods of parallelization (i.e.
--action_env=CMAKE_BUILD_PARALLEL_LEVEL=16) pretty unpleasant, since bazel won't know and will happily schedule 160 cores worth of actions on a 10-core machine. Although it doesn't solve the whole parallelization problem (see #329) it helps a lot; it reduces the length of our internal build by 30% (by allowing us to fine-tune threads on a per-action basis).core design
resource_sizeattribute, which can be set to a logical size similar to bazel's other sizing parameters (default,tiny,small,medium,large,enormous).bazel run @rules_foreign_cc//foreign_cc/settingswill list all the settings in.bazelrcformat, along with their default values.CMAKE_BUILD_PARALLEL_LEVEL,GNUMAKEFLAGS,MESON_NUM_PROCESSES,NINJA_JOBS. All vars are passed to all build systems, since they can delegate to each other (for example, cmake calling ninja or make).resource_size="default"(the default) does the same thing as what rfcc/bazel does today (no resource_set, no env var overrides)action_env(e.g.--action_env=CMAKE_BUILD_PARALLEL_LEVEL=4) or similar:@rules_foreign_cc//foreign_cc/settings:size_default) will override the action_env vars.other notes
(make|cmake|ninja|pkgconfig)_tool, which drastically speeds up the CI environment and build iteration speed. (This knocks at least 10 minutes off thecmake_toolbuild time).NINJA_JOBSis implemented. It's c++ instead of bash or python because it needs to be invoked after changing the working directory, and the shim scripts that are used to launch bash or python on windows rely on runfiles, which don't work if you change the wd the way rfcc must.--local_resourcesto determine the limit; see that for defaultsCMAKE_BUILD_PARALLEL_LEVEL=12. This is probably implementable as a setting if someone feels so inclined.