Parallel codegen (#1206)
* Described underlying data structures in parallel code generation and crates they are used in * Added links * replace crate information with description of types
This commit is contained in:
parent
9198465b6c
commit
8c39edb660
|
|
@ -10,15 +10,24 @@ These next few sections describe where and how parallelism is currently used,
|
|||
and the current status of making parallel compilation the default in `rustc`.
|
||||
|
||||
The underlying thread-safe data-structures used in the parallel compiler
|
||||
can be found in `rustc_data_structures/sync.rs`. Some of these data structures
|
||||
use the `parking_lot` API.
|
||||
can be found in the `rustc_data_structures::sync` module. Some of these data structures
|
||||
use the `parking_lot` crate as well.
|
||||
|
||||
## Codegen
|
||||
|
||||
There are two underlying thread safe data structures used in code generation:
|
||||
|
||||
- `Lrc`
|
||||
- Which is an [`Arc`][Arc] if `parallel_compiler` is true, and a [`Rc`][Rc]
|
||||
if it is not.
|
||||
- `MetadataRef` -> [`OwningRef<Box<dyn Erased + Send + Sync>, [u8]>`][OwningRef]
|
||||
- This data structure is specific to `rustc`.
|
||||
|
||||
During [monomorphization][monomorphization] the compiler splits up all the code to
|
||||
be generated into smaller chunks called _codegen units_. These are then generated by
|
||||
independent instances of LLVM running in parallel. At the end, the linker
|
||||
is run to combine all the codegen units together into one binary.
|
||||
is run to combine all the codegen units together into one binary. This process
|
||||
occurs in the `rustc_codegen_ssa::base` module.
|
||||
|
||||
## Query System
|
||||
|
||||
|
|
@ -92,3 +101,6 @@ are a bit out of date):
|
|||
[tracking]: https://github.com/rust-lang/rust/issues/48685
|
||||
[monomorphization]:https://rustc-dev-guide.rust-lang.org/backend/monomorph.html
|
||||
[parallel-rustdoc]:https://github.com/rust-lang/rust/issues/82741
|
||||
[Arc]:https://doc.rust-lang.org/std/sync/struct.Arc.html
|
||||
[Rc]:https://doc.rust-lang.org/std/rc/struct.Rc.html
|
||||
[OwningRef]:https://doc.rust-lang.org/nightly/nightly-rustc/rustc_data_structures/owning_ref/index.html
|
||||
|
|
|
|||
Loading…
Reference in New Issue