-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Use thread local dep graph encoding #139758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Use thread local dep graph encoding This adds thread local encoding of dep graph nodes. Each thread has a `MemEncoder` that gets flushed to the global `FileEncoder` when it exceeds 64 kB. Each thread also has a local cache of dep indices. This means there can now be empty gaps in `SerializedDepGraph`. Indices are marked green and also allocated by the new atomic operation `DepNodeColorMap::try_mark_green` as the encoder lock is removed. This is based on rust-lang#139636 and rust-lang#139756.
Local results, 1 thread, including #139756, excluding #139636:
Local results, 7 threads, including #139756, excluding #139636:
|
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (5545f9c): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary 1.8%, secondary 0.3%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 779.607s -> 782.154s (0.33%) |
r? compiler |
8167fdb
to
7d236d0
Compare
I'd probably disregard the instruction improvements here and in #139756 as they don't translate into wall time improvements nor are they expected. Maybe I think the trade off towards the parallel compiler is reasonable here as incremental builds tends to have more free cores. Do note the 8.6% regression in dep graph size due to the added indices too. #139756 is split out mostly to get a separate perf run and doesn't make sense without also merging this PR. r? @oli-obk |
☔ The latest upstream changes (presumably #139938) made this pull request unmergeable. Please resolve the merge conflicts. |
@@ -76,6 +80,9 @@ const DEP_NODE_PAD: usize = DEP_NODE_SIZE - 1; | |||
const DEP_NODE_WIDTH_BITS: usize = DEP_NODE_SIZE / 2; | |||
|
|||
/// Data for use when recompiling the **current crate**. | |||
/// | |||
/// There may be unused indices with DEP_KIND_NULL in this graph due to batch allocation of | |||
/// indices to threads. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this batch allocation really necessary? Could we have a single atomic counter to assign the index and avoid the complexity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need at least 1 thread local allocation to avoid races when marking nodes green. A single counter would probably result in some congestion as promoting nodes is fairly hot too.
7d236d0
to
c1067ba
Compare
This adds thread local encoding of dep graph nodes. Each thread has a
MemEncoder
that gets flushed to the globalFileEncoder
when it exceeds 64 kB. Each thread also has a local cache of dep indices. This means there can now be empty gaps inSerializedDepGraph
.Indices are marked green and also allocated by the new atomic operation
DepNodeColorMap::try_mark_green
as the encoder lock is removed.This is based on #139756.