-
Notifications
You must be signed in to change notification settings - Fork 434
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
Consider integrating compilation pipelining #228
Comments
The underlying notes are most relevant for reimplementing this: I skimmed it briefly and it mostly made sense, but one snippet caught me off guard
Contrary to the "pro":
I suspect that it might be more difficult from Bazel's perspective to initiate subsequent compilation steps based on messages on stdout. |
It looks like the implementation of compilation pipelining here works by having rustc inform the caller (via stdout) when artifacts are generated during execution. Cargo seems to have been updated to use that additional information to dispatch subsequent invocations to Do you know of any similar prior art where Bazel needed to work with tools which run for long durations and incrementally produce artifacts? More detail: Based on the document, the two kinds of artifacts being produced are
(1) is required in order to initiate subsequent compilation steps and produce dependent rlibs, while (2) is required for final linking. The optimization at play takes advantage of the fact that (1) is generally much faster to produce than (2), and (2) is only required at the very end (IIUC). |
The two rustc invocation approach already mostly works, but currently There's some conversation around that @ https://rust-lang.zulipchat.com/#narrow/stream/195180-t-compiler.2Fwg-pipelining and rust-lang/rust#58465 (comment) |
Persistent Workers appears to be the Bazel feature closest to having multiple outputs from an action, but it's not a clean mapping and would probably be somewhat hacky to implement as it stands. |
I wonder if #1207 is related to the request here. |
@UebelAndre That's a strange (but interesting0 way to deal with this. Ideally I found that rather than using I have successfully implemented pipelining in Buck v2 using this technique, and it works pretty well - it can unlock quite a lot of build-time concurrency, and it can take good advantage of pervasive caching. I believe Bazel has similar constraints to Buck, so I think it can use the same mechanism. The main downside is the need to rely on the unstable |
Thanks @jsgf, that's super useful to know. We will definitely try both approaches and let you know what we found. If I had to guess I'd say that performance-wise both are equivalent, so the only real difference is that abort-after-metadata-is-produced approach is "stable" today. If that is the case, let's try to stabilize |
It also depends on macro expansion being deterministic. There are several proc macros which are not deterministic. For example they depend on hashmap iteration order or intentionally generate random numbers.
I think we should rather have a |
Yeah, I'm fine with that so long as, you know, it actually works. Right now I'll agree that
That's already a given, independent of pipelining. The Buck and Bazel caching machinery assumes that Rust builds are deterministic (builds in general, but Rust actually checks its the case and fails if it isn't). Non-deterministic proc-macros are not all that common, but very painful when they turn up. Hash-order is a common example. Less common but harder to fix is "go off to some other data source and generate code from it" (eg, SQL schema). "Compile-time randomness" super annoying but we changed that to be deterministic ("random" number is a function of source file+line). |
This is now implemented, right? |
We dont have to do this right away, but as https://internals.rust-lang.org/t/evaluating-pipelined-rustc-compilation/10199 comes to fruit, we could plug this into bazel pretty easily.
The text was updated successfully, but these errors were encountered: