-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Restart at most once when prepopulating repository rule environment #20434
Restart at most once when prepopulating repository rule environment #20434
Conversation
This also allows downloads of The ideal solution would probably be to turn CC @Wyverald |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, thank you!
@bazel-io flag |
@bazel-io fork 7.1.0 |
To confirm, this is not a fix for a regression (at least not a recent one since Bazel 6.4.0 also benefits).
Would be more efficient and likely require less code. I think it would make sense to batch that work with resolving Looking at I see that this has been tagged for Bazel 7.1. Any chance this can be included in the next v6 release? |
We don't have 6.5 release planned. By our release policy, we'll no longer backport features to the previous LTS when a new one is out, only critical bug fixes. We might reconsider if there are actually enough interests for a new 6.5 release if that helps with the migration to 7. |
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
@meteorcloudy, since 6.5 has been decided to happen, is this PR something that you would be willing to include in the release? Having these performance improvements could be helpful in the context of rules authors needing to support non-latest bazel version and it may allow to not worry about the restarts as much. |
@bazel-io fork 6.5.0 |
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
…onment (#20667) 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 Co-authored-by: Jordan Mele <mele@canva.com> Co-authored-by: Xùdōng Yáng <wyverald@gmail.com>
…onment (#20643) 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 Co-authored-by: Jordan Mele <mele@canva.com> Co-authored-by: Xùdōng Yáng <wyverald@gmail.com>
The changes in this PR have been included in Bazel 6.5.0 RC1. Please test out the release candidate and report any issues as soon as possible. If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=last_rc. |
Tested 6.5.0rc1 locally (macOS) and on CI (Linux), no issues. Change is working as advertised too. Local test case finished about a minute faster. |
The changes in this PR have been included in Bazel 7.1.0 RC1. Please test out the release candidate and report any issues as soon as possible. If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=last_rc. |
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