Rust: Tracking issue for stabilizing "pipelined compilation"

Created on 21 May 2019  路  12Comments  路  Source: rust-lang/rust

This issue is intended to be an overall tracking issue for stabilizing the recently implemented feature of "pipelined compilation". This tracking issue spans both Cargo and rustc, as support currently lives in both. It also builds on top of a number of other tracking issues, since they're unstable features used to implement pipelined compilation!

For a bit of background, pipelined compilation has an initial set of notes about its implementation and initially had these tracking issues:

Currently today everything is implemented and available in nightly rustc. There is a thread on internals which is tasked with gaining user experience about pipelining and see the performance impact. A collation of these measurements is quite promising and I feel personally is convincing enough to push on stabilizing all the sub-features!

Known blockers for stabilization:

  • [ ] [-Z emit-artifact-notifications](https://github.com/rust-lang/rust/issues/60419) - this is how Cargo learns the moment metadata is ready.
  • [ ] [--json-rendered](https://github.com/rust-lang/rust/issues/60987) - this is how Cargo continues to provide pretty error messages.
  • [ ] There is no way to combine --message-format=short in Cargo with pipelining. The compiler currently has --error-format=json|short|human, but for this feature in Cargo we'll need something like --error-format=short-json or something like that. Basically some way to request that the rendered field in the JSON diagnostic is a "short message", not the long one.
  • [x] Cargo pipelining is known to break with sccache, this should be investigated and fixed one way or another. (fixed in https://github.com/mozilla/sccache/pull/441)
  • [x] Pipelining fails with the RLS due to multiple --error-format flags (fixed in https://github.com/rust-lang/rust/pull/62176)

Possible future work:

  • Should we game out what a "fully pipelined" story might look like? What if rustc blocked waiting for Cargo to tell it to proceed into the linking phase?
B-unstable C-tracking-issue I-compiletime T-compiler

Most helpful comment

All 12 comments

Reading the various issues and PRs, I got the impression that metadata is generated at earliest post static analysis, is that correct?

Yes: metadata is now generated right at the start of code generation, immediately after all the checking (typeck, borrowck, etc.) finish. This is the best place for the initial pipelining implementation.

One might argue that metadata generation should be moved earlier. That would help with successful builds, but slow down builds that trigger compile errors. Given that a lot of Rust compiler invocations end in compile errors during the normal development cycle, slowing down such invocations would be bad.

Another possibility is to generate metadata in parallel with checking. That might give the best of both worlds. But that's a bigger change.

One might argue that metadata generation should be moved earlier.

No no... ;) At the start of code-gen sounds good to me and we should be cautious with moving it too much earlier as that can mess with language design.

There is no way to combine --message-format=short in Cargo with pipelining

This is trivial to implement with --json-rendered. I can mentor this in https://github.com/rust-lang/rust/issues/60987

It might be useful to have multiple rendered forms in the json output.

I've proposed stabilization of --json-rendered as well as -Z emit-artifact-notifications which, if stabilized, can allow Cargo to switch over to using these by default and stabilizing pipelined compilation.

I'd like to make sure there's a stable way to make sure that --emit metadata on its own produces metadata suitable as an input to a next build stage. I'm fine with the plain cargo check metadata being incomplete if that allows it to be emitted a little faster, but I'd like to have the option of two-invocation pipelining without paying the cost of --emit metadata,link.

Context:

  • Invoking rustc twice is going to be easier to implement in Buck than full pipelining initially
  • Full pipelining is the goal, but Buck is not currently set up for it (I believe Bazel is in a similar position)
  • The extra CPU overhead of two rustc invocations is fine if it helps shorten the build critical path
  • But the cost of two complete builds is too much

(cc @bolinfest)

I agree that it should be the case, but that seems like a separable stabilization issue from this which is enabling Cargo's internal pipelined compilation.

@alexcrichton IIUC it seems that pipelining always emits --error-format which currently seems to break the RLS due to error: Option 'error-format' given more than once (https://github.com/rust-lang/rls/issues/1484).

The immediate fix is to filter the injected --error-format flag ourselves and continue with our --error-format=json flag (will that break the pipelining?). However, I imagine it'd be better to allow multiple occurrences of these with the later ones taking precedence not to reimplement command arguments parsing and filtering in rustc wrappers. Does that sound like a good idea?

@Xanewok that sounds reasonable to me yeah with the last option taking precedence!

The NOTES.md link in the description is dead.

Was this page helpful?
0 / 5 - 0 ratings