Skip to content

Commit c31ec83

Browse files
Sl1mb0jyn514
authored andcommitted
Docs: added section discussing core ideas
1 parent 78afd53 commit c31ec83

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/parallel-rustc.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,22 @@ When a query `foo` is evaluated, the cache table for `foo` is locked.
4848

4949
As of <!-- date: 2021-07 --> July 2021, work on explicitly parallelizing the
5050
compiler has stalled. There is a lot of design and correctness work that needs
51-
to be done.
51+
to be done.
52+
53+
These are the basic ideas in the effort to make `rustc` parallel:
54+
55+
- All data a query provider can access is accessed via the query context, so
56+
the query context can take care of synchronizing access.
57+
- Query results are required to be immutable so they can safely be used by
58+
different threads concurrently.
59+
60+
- There are a lot of loops in the compiler that just iterate over all items in
61+
a crate. These can possibly be parallelized.
62+
- We can use (a custom fork of) [`rayon`] to run tasks in parallel. The custom
63+
fork allows the execution of DAGs of tasks, not just trees.
64+
- There are currently a lot of global data structures that need to be made
65+
thread-safe. A key strategy here has been converting interior-mutable
66+
data-structures (e.g. `Cell`) into their thread-safe siblings (e.g. `Mutex`).
5267

5368
[`rayon`]: https://crates.io/crates/rayon
5469

0 commit comments

Comments
 (0)