[6.5.0] Restart at most once when prepopulating repository rule environment #20667
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.
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