1
1
# Parallel Compilation
2
2
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
4
4
that 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
7
7
parallel compiler work by enabling it in the ` config.toml ` .
8
8
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,
10
10
and the current status of making parallel compilation the default in ` rustc ` .
11
11
12
- The underlying thread-safe data-structures used in the parallel compiler
12
+ The underlying thread-safe data-structures used in the parallel compiler
13
13
can be found in the ` rustc_data_structures::sync ` module. Some of these data structures
14
14
use the ` parking_lot ` crate as well.
15
15
@@ -23,9 +23,9 @@ There are two underlying thread safe data structures used in code generation:
23
23
- ` MetadataRef ` -> [ ` OwningRef<Box<dyn Erased + Send + Sync>, [u8]> ` ] [ OwningRef ]
24
24
- This data structure is specific to ` rustc ` .
25
25
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
29
29
is run to combine all the codegen units together into one binary. This process
30
30
occurs in the ` rustc_codegen_ssa::base ` module.
31
31
@@ -49,20 +49,20 @@ When a query `foo` is evaluated, the cache table for `foo` is locked.
49
49
- If there * is* another query invocation for the same key in progress, we
50
50
release the lock, and just block the thread until the other invocation has
51
51
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
53
53
progress.
54
54
55
55
## Rustdoc
56
56
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
58
58
to complete before rustdoc rendering can be made parallel. More details on
59
59
this issue can be found [ here] [ parallel-rustdoc ] .
60
60
61
61
## Current Status
62
62
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
64
64
compiler has stalled. There is a lot of design and correctness work that needs
65
- to be done.
65
+ to be done.
66
66
67
67
These are the basic ideas in the effort to make ` rustc ` parallel:
68
68
@@ -76,7 +76,7 @@ These are the basic ideas in the effort to make `rustc` parallel:
76
76
77
77
[ `rayon` ] : https://crates.io/crates/rayon
78
78
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
80
80
to lack of manpower. We have a working prototype with promising performance
81
81
gains in many cases. However, there are two blockers:
82
82
0 commit comments