Docs: added section discussing core ideas

This commit is contained in:
Timothy Maloney 2021-09-06 13:42:56 -07:00 committed by Joshua Nelson
parent a22f7be4e7
commit 720084903e
1 changed files with 16 additions and 1 deletions

View File

@ -50,6 +50,21 @@ As of <!-- date: 2021-07 --> July 2021, work on explicitly parallelizing the
compiler has stalled. There is a lot of design and correctness work that needs
to be done.
These are the basic ideas in the effort to make `rustc` parallel:
- All data a query provider can access is accessed via the query context, so
the query context can take care of synchronizing access.
- Query results are required to be immutable so they can safely be used by
different threads concurrently.
- There are a lot of loops in the compiler that just iterate over all items in
a crate. These can possibly be parallelized.
- We can use (a custom fork of) [`rayon`] to run tasks in parallel. The custom
fork allows the execution of DAGs of tasks, not just trees.
- There are currently a lot of global data structures that need to be made
thread-safe. A key strategy here has been converting interior-mutable
data-structures (e.g. `Cell`) into their thread-safe siblings (e.g. `Mutex`).
[`rayon`]: https://crates.io/crates/rayon
As of <!-- date: 2021-02 --> February 2021, much of this effort is on hold due