-
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
Optimise repository rule generation with re-entrancy #16162
Comments
I briefly started working on this once using the relatively new env.getState. It essentially comes down to adding some form of continuation support to the Starlark interpreter. Unfortunately, the "Starlark stack" is a mix of custom data structures and the actual Java stack - since Java doesn't have continuations, one would have to maintain additional data structures that record the state of the Java stack for all operations that aren't safe to redo (e.g. that modify local variables). Since the Starlark interpreter is so important for Bazel's performance, I think the main challenge would be implementing all of this while not regressing performance for the case of non-reentrant evaluation (see #15594 for a much smaller PR that already raised valid performance concerns). I fear that this might not be possible, which would then make a reentrant fork of the Starlark interpreter necessary that would only be used to evaluate repository rules. That said, if anybody wants to work on this, let me know. But it's possible that an actual compiled representation for Starlark would make this effort a lot simpler. |
As @fmeum noted, this is actually not very easy to achieve at all, not without changes to the Starlark interpreter that allows us to store (and restart from) a call stack and a program counter. Either that, or something like |
This is a dupe of #10515, which is actively being worked on. |
Closing in favor of #10515. |
Description of the feature request:
Instead of restarting repository rule fetching when a new dependency is discovered, pause execution and resume once it is available.
Subject to how this is achieved, it should provide;
What underlying problem are you trying to solve with this feature?
Repository rules taking a long time to complete due to late dependency references triggering restarts. Starlark implementations can be optimised by touching dependencies early on, but in practice this is easily overlooked as;
Further, refactoring to address the performance penalty of restarts is itself a major time sink.
Which operating system are you running Bazel on?
macOS 12.5.1
What is the output of
bazel info release
?release 5.1.1- (@Non-Git)
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.With Nix, via https://github.com/NixOS/nixpkgs/archive/13e0d337037b3f59eccbbdf3bc1fe7b1e55c93fd.tar.gz
What's the output of
git remote get-url origin; git rev-parse master; git rev-parse HEAD
?Have you found anything relevant by searching the web?
npm_install
runs three times on a clean build bazel-contrib/rules_nodejs#2620Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: