Skip to content
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

Parallelize some phases of compilation between a crate and its dependency #3431

Closed
brson opened this issue Sep 8, 2012 · 6 comments
Closed
Labels
E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot.

Comments

@brson
Copy link
Contributor

brson commented Sep 8, 2012

With a single driver building multiple crates we can start running more parts of the compilation process in parallel.

The basic idea is to output the metadata about a crate before code generation so that the next compile can proceed based on that metadata.

rustc gets modified in a few ways:

  • Just before trans we serialize the bulk of the metadata and insert a hook to give the multi-crate driver an opportunity to copy it to another task to begin the next compilation phase. There will still be some metadata that needs to be serialized after trans.
  • Insert another hook into crate resulotion for reading the metadata binary. The multi-crate driver will use this to receive the metadata output from previous crates and feed them to the next crates.

The end result is that parsing and analysis will be largely done in parallel with code generation for multi-crate builds.

Beyond that we can also parse all crates in parallel.

This would require that we make sure we are using LLVM in a threadsafe way, unless we can get all the trans passes onto a single thread.

Related to #2237

@catamorphism
Copy link
Contributor

Added far-future milestone

@emberian
Copy link
Member

LLVM is now used threadsafely.

Still relevant, though I'm not sure how you plan to actually link the crate...

@thestinger
Copy link
Contributor

There's a lot of potential for parallel compilation in LLVM itself. The function pass is an embarrassingly parallel task since it runs on each function in isolation.

http://lists.cs.uiuc.edu/pipermail/llvmdev/2013-July/063826.html

I think this would be a huge win for us.

@huonw
Copy link
Member

huonw commented Jan 3, 2014

Triage: no change, and the LLVM parallel function pass patch seems dead: http://llvm-reviews.chandlerc.com/D1152

@kmcallister
Copy link
Contributor

Cargo now provides a multi-crate compilation manager, so the remaining task here is to improve parallelism between rustc processes. Perhaps they need a protocol to talk about which files aren't ready yet, and to notify when they become ready. Cargo would act as a router for this protocol. Alternately it could pass a list of not-ready files and each rustc process would watch them with inotify or similar (avoiding races will be tricky).

The hardest part of this may be the dynamic job management to balance CPU utilization and peak RAM use when many rustc processes are blocking on file updates.

@kmcallister kmcallister changed the title Parallel multi-crate compiler driver Parallelize some phases of compilation between a crate and its dependency Oct 7, 2014
@steveklabnik
Copy link
Member

I'm pulling a massive triage effort to get us ready for 1.0. As part of this, I'm moving stuff that's wishlist-like to the RFCs repo, as that's where major new things should get discussed/prioritized.

This issue has been moved to the RFCs repo: rust-lang/rfcs#610

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot.
Projects
None yet
Development

No branches or pull requests

7 participants