Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.5.0] Restart at most once when prepopulating repository rule environment #20667

Merged
merged 3 commits into from
Jan 9, 2024

Conversation

bazel-io
Copy link
Member

When a repository rule is fetch attributes are iterated over in enforceLabelAttributes to prepopulate the environment, restarting the fetch each time a new dependency is discovered.

This is faster than calling repository_ctx.path(...) early in the repository rule implementation function but still has considerable overhead.

This PR defers throwing NeedsSkyframeRestartException till after every attribute has been processed, greatly reducing the number of restarts and iterations.

In an internal project these optimisations are particularly noticeable.
Before: 2min 8s, 2min 7s
After: 1min 35s, 1min 27s

Closes #20434.

Commit e8ac96a

PiperOrigin-RevId: 588090528
Change-Id: I7917b137d6e60b6d6a73189cf396418a85b3ec28

When a repository rule is fetch attributes are iterated over in `enforceLabelAttributes` to prepopulate the environment, restarting the fetch each time a new dependency is discovered.

This is faster than calling `repository_ctx.path(...)` early in the repository rule implementation function but still has considerable overhead.

This PR defers throwing `NeedsSkyframeRestartException` till after every attribute has been processed, greatly reducing the number of restarts and iterations.

In an internal project these optimisations are particularly noticeable.
Before: 2min 8s, 2min 7s
After: 1min 35s, 1min 27s

Closes bazelbuild#20434.

PiperOrigin-RevId: 588090528
Change-Id: I7917b137d6e60b6d6a73189cf396418a85b3ec28
@bazel-io bazel-io added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. awaiting-review PR is awaiting review from an assigned reviewer labels Dec 23, 2023
@bazel-io bazel-io requested a review from a team as a code owner December 23, 2023 07:35
@iancha1992 iancha1992 added this pull request to the merge queue Jan 9, 2024
Merged via the queue into bazelbuild:release-6.5.0 with commit efbff0a Jan 9, 2024
28 checks passed
iancha1992 pushed a commit that referenced this pull request Jan 23, 2024
Baseline:  50b61e3

Release Notes:

+ Fix tree file materialized as symlink to another file when building without the bytes. (#20409)
+ Don't pass --add-opens= to javac (#20472)
+ Flip --incompatible_visibility_private_attributes_at_definition (#20520)
+ Fix extraction of tar archives containing sparse files. (#20531)
+ RemoteSpawnRunner: record inbetween phases in timing profile (#20550)
+ Add profiling to `remoteActionBuildingSemaphore.acquire()` (#20549)
+ The label API shakeup & docs cleanup (#20590)
+ Disable rewriter test (#20758)
+ Disable PyTest.testSmoke on macOS (#20729)
+ Upgrade abseil-cpp to fix build on macos_arm64 (#20785)
+ Ignore read-only errors when updating the `mtime` of the `install_base` (#20568)
+ Restart at most once when prepopulating repository rule environment (#20667)
+ Fix bootstrapped Bazel binary (#20804)
+ Add flag `experimental_throttle_remote_action_building` (#20861)
+ Fix versioned shared libraries for macOS toolchain (#20847)
+ Proto toolchainisation cherrypicks (#20925)

Acknowledgements:

This release contains contributions from many people at Google, as well as bazel.build machine account, Brentley Jones, Fabian Meumertzheim, Jordan Mele, Mai Hussien, oquenchil, Rahul Butani, Son Luong Ngoc, Xùdōng Yáng.
copybara-service bot pushed a commit that referenced this pull request Jan 23, 2024
Baseline:  50b61e3

Release Notes:

+ Fix tree file materialized as symlink to another file when building without the bytes. (#20409)
+ Don't pass --add-opens= to javac (#20472)
+ Flip --incompatible_visibility_private_attributes_at_definition (#20520)
+ Fix extraction of tar archives containing sparse files. (#20531)
+ RemoteSpawnRunner: record inbetween phases in timing profile (#20550)
+ Add profiling to `remoteActionBuildingSemaphore.acquire()` (#20549)
+ The label API shakeup & docs cleanup (#20590)
+ Disable rewriter test (#20758)
+ Disable PyTest.testSmoke on macOS (#20729)
+ Upgrade abseil-cpp to fix build on macos_arm64 (#20785)
+ Ignore read-only errors when updating the `mtime` of the `install_base` (#20568)
+ Restart at most once when prepopulating repository rule environment (#20667)
+ Fix bootstrapped Bazel binary (#20804)
+ Add flag `experimental_throttle_remote_action_building` (#20861)
+ Fix versioned shared libraries for macOS toolchain (#20847)
+ Proto toolchainisation cherrypicks (#20925)

Acknowledgements:

This release contains contributions from many people at Google, as well as bazel.build machine account, Brentley Jones, Fabian Meumertzheim, Jordan Mele, Mai Hussien, oquenchil, Rahul Butani, Son Luong Ngoc, Xùdōng Yáng.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review PR is awaiting review from an assigned reviewer team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants