Skip to content

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Apr 13, 2025

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 #139636 and #139756.

@rustbot
Copy link
Collaborator

rustbot commented Apr 13, 2025

r? @lcnr

rustbot has assigned @lcnr.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 13, 2025
@Zoxc
Copy link
Contributor Author

Zoxc commented Apr 13, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 13, 2025
@bors
Copy link
Collaborator

bors commented Apr 13, 2025

⌛ Trying commit 8167fdb with merge 5545f9c456a47860eda2f034f2d7636b31cff81c...

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 13, 2025
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.
@Zoxc
Copy link
Contributor Author

Zoxc commented Apr 13, 2025

Local results, 1 thread, including #139756, excluding #139636:

BenchmarkBeforeAfterBeforeAfterBeforeAfter
TimeTime%Physical MemoryPhysical Memory%Committed MemoryCommitted Memory%
🟣 clap:check:unchanged0.3046s0.3076s 0.98%96.94 MiB98.15 MiB💔 1.24%168.25 MiB169.79 MiB 0.92%
🟣 hyper:check:unchanged0.1211s0.1221s 0.84%61.84 MiB62.02 MiB 0.29%125.11 MiB125.54 MiB 0.35%
🟣 regex:check:unchanged0.2250s0.2271s 0.92%78.13 MiB78.98 MiB💔 1.08%145.56 MiB146.65 MiB 0.75%
🟣 syn:check:unchanged0.4928s0.4971s 0.88%118.76 MiB120.38 MiB💔 1.36%193.57 MiB195.51 MiB💔 1.00%
Total1.1436s1.1540s 0.91%355.67 MiB359.52 MiB💔 1.08%632.49 MiB637.50 MiB 0.79%
Summary1.0000s1.0090s 0.90%1 byte1.01 bytes 0.99%1 byte1.01 bytes 0.75%

Local results, 7 threads, including #139756, excluding #139636:

BenchmarkBeforeAfterBeforeAfterBeforeAfter
TimeTime%Physical MemoryPhysical Memory%Committed MemoryCommitted Memory%
🟣 clap:check:unchanged0.3710s0.3140s💚 -15.37%133.25 MiB134.96 MiB💔 1.29%235.08 MiB237.04 MiB 0.83%
🟣 hyper:check:unchanged0.1466s0.1303s💚 -11.11%85.72 MiB86.31 MiB 0.69%191.98 MiB192.88 MiB 0.47%
🟣 regex:check:unchanged0.2831s0.2353s💚 -16.86%113.02 MiB114.25 MiB💔 1.09%212.53 MiB214.18 MiB 0.78%
🟣 syn:check:unchanged0.5756s0.5078s💚 -11.78%157.85 MiB160.31 MiB💔 1.56%260.80 MiB263.61 MiB💔 1.08%
Total1.3763s1.1875s💚 -13.72%489.84 MiB495.83 MiB💔 1.22%900.39 MiB907.70 MiB 0.81%
Summary1.0000s0.8622s💚 -13.78%1 byte1.01 bytes💔 1.16%1 byte1.01 bytes 0.79%

@bors
Copy link
Collaborator

bors commented Apr 13, 2025

☀️ Try build successful - checks-actions
Build commit: 5545f9c (5545f9c456a47860eda2f034f2d7636b31cff81c)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5545f9c): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking 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 @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

This 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.

mean range count
Regressions ❌
(primary)
0.3% [0.2%, 0.5%] 16
Regressions ❌
(secondary)
0.5% [0.4%, 0.8%] 11
Improvements ✅
(primary)
-0.6% [-0.9%, -0.4%] 103
Improvements ✅
(secondary)
-0.6% [-1.0%, -0.3%] 24
All ❌✅ (primary) -0.4% [-0.9%, 0.5%] 119

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.

mean range count
Regressions ❌
(primary)
1.8% [1.1%, 3.0%] 35
Regressions ❌
(secondary)
3.8% [2.2%, 9.2%] 7
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.3% [-5.1%, -2.3%] 7
All ❌✅ (primary) 1.8% [1.1%, 3.0%] 35

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 779.607s -> 782.154s (0.33%)
Artifact size: 365.51 MiB -> 365.50 MiB (-0.00%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Apr 13, 2025
@lcnr
Copy link
Contributor

lcnr commented Apr 14, 2025

r? compiler

@rustbot rustbot assigned Nadrieril and unassigned lcnr Apr 14, 2025
@Zoxc Zoxc force-pushed the thread-local-graph branch from 8167fdb to 7d236d0 Compare April 15, 2025 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) perf-regression Performance regression. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants