11# Parallel Compilation
22
3- As of <!-- date: 2021-09 --> September 2021 , The only stage of the compiler
3+ As of <!-- date: 2022-05 --> May 2022 , The only stage of the compiler
44that is already parallel is codegen. The nightly compiler implements query evaluation,
5- but there is still a lot of work to be done. The lack of parallelism at other stages
6- also represents an opportunity for improving compiler performance. One can try out the current
5+ but there is still a lot of work to be done. The lack of parallelism at other stages
6+ also represents an opportunity for improving compiler performance. One can try out the current
77parallel compiler work by enabling it in the ` config.toml ` .
88
9- These next few sections describe where and how parallelism is currently used,
9+ These next few sections describe where and how parallelism is currently used,
1010and the current status of making parallel compilation the default in ` rustc ` .
1111
12- The underlying thread-safe data-structures used in the parallel compiler
12+ The underlying thread-safe data-structures used in the parallel compiler
1313can be found in the ` rustc_data_structures::sync ` module. Some of these data structures
1414use the ` parking_lot ` crate as well.
1515
@@ -23,9 +23,9 @@ There are two underlying thread safe data structures used in code generation:
2323- ` MetadataRef ` -> [ ` OwningRef<Box<dyn Erased + Send + Sync>, [u8]> ` ] [ OwningRef ]
2424 - This data structure is specific to ` rustc ` .
2525
26- During [ monomorphization] [ monomorphization ] the compiler splits up all the code to
27- be generated into smaller chunks called _ codegen units_ . These are then generated by
28- independent instances of LLVM running in parallel. At the end, the linker
26+ During [ monomorphization] [ monomorphization ] the compiler splits up all the code to
27+ be generated into smaller chunks called _ codegen units_ . These are then generated by
28+ independent instances of LLVM running in parallel. At the end, the linker
2929is run to combine all the codegen units together into one binary. This process
3030occurs in the ` rustc_codegen_ssa::base ` module.
3131
@@ -49,20 +49,20 @@ When a query `foo` is evaluated, the cache table for `foo` is locked.
4949- If there * is* another query invocation for the same key in progress, we
5050 release the lock, and just block the thread until the other invocation has
5151 computed the result we are waiting for. This cannot deadlock because, as
52- mentioned before, query invocations form a DAG. Some thread will always make
52+ mentioned before, query invocations form a DAG. Some threads will always make
5353 progress.
5454
5555## Rustdoc
5656
57- As of <!-- date: 2021-09 --> September 2021 , there are still a number of steps
57+ As of <!-- date: 2022-05 --> May 2022 , there are still a number of steps
5858to complete before rustdoc rendering can be made parallel. More details on
5959this issue can be found [ here] [ parallel-rustdoc ] .
6060
6161## Current Status
6262
63- As of <!-- date: 2021-07 --> July 2021 , work on explicitly parallelizing the
63+ As of <!-- date: 2022-05 --> May 2022 , work on explicitly parallelizing the
6464compiler has stalled. There is a lot of design and correctness work that needs
65- to be done.
65+ to be done.
6666
6767These are the basic ideas in the effort to make ` rustc ` parallel:
6868
@@ -76,7 +76,7 @@ These are the basic ideas in the effort to make `rustc` parallel:
7676
7777[ `rayon` ] : https://crates.io/crates/rayon
7878
79- As of <!-- date: 2021-02 --> February 2021 , much of this effort is on hold due
79+ As of <!-- date: 2022-05 --> May 2022 , much of this effort is on hold due
8080to lack of manpower. We have a working prototype with promising performance
8181gains in many cases. However, there are two blockers:
8282
0 commit comments