Skip to content

Allow out of order dep graph node encoding #139756

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Apr 13, 2025

This allows out of order dep graph node encoding by also encoding the index instead of using the file node order as the index.

MemEncoder is also brought back to life and used for encoding.

Both of these are done to enable thread-local encoding of dep graph nodes.

This is based on #139636.

@rustbot
Copy link
Collaborator

rustbot commented Apr 13, 2025

r? @davidtwco

rustbot has assigned @davidtwco.
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 Zoxc force-pushed the out-of-order-dep-graph branch from 4365461 to c31c18a Compare April 13, 2025 17:54
@rust-log-analyzer

This comment has been minimized.

@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 added a commit to rust-lang-ci/rust that referenced this pull request Apr 13, 2025
Allow out of order dep graph node encoding

This allows out of order dep graph node encoding by also encoding the index instead of using the file node order as the index.

`MemEncoder` is also brought back to life and used for encoding.

Both of these are done to enable thread-local encoding of dep graph nodes.

This is based on rust-lang#139636.
@bors
Copy link
Collaborator

bors commented Apr 13, 2025

⌛ Trying commit 3269f5a with merge f1a6b16...

@Zoxc
Copy link
Contributor Author

Zoxc commented Apr 13, 2025

Local results, excluding #139636:

BenchmarkBeforeAfterBeforeAfterBeforeAfter
TimeTime%Physical MemoryPhysical Memory%Committed MemoryCommitted Memory%
🟣 clap:check:unchanged0.3029s0.3049s 0.66%96.91 MiB98.21 MiB💔 1.34%168.23 MiB169.72 MiB 0.88%
🟣 hyper:check:unchanged0.1204s0.1214s 0.86%61.82 MiB62.16 MiB 0.55%125.12 MiB125.55 MiB 0.34%
🟣 regex:check:unchanged0.2250s0.2263s 0.58%78.21 MiB79.14 MiB💔 1.19%145.66 MiB146.64 MiB 0.68%
🟣 syn:check:unchanged0.4940s0.4974s 0.69%118.79 MiB120.64 MiB💔 1.55%193.58 MiB195.58 MiB💔 1.03%
Total1.1424s1.1501s 0.68%355.74 MiB360.16 MiB💔 1.24%632.59 MiB637.48 MiB 0.77%
Summary1.0000s1.0070s 0.70%1 byte1.01 bytes💔 1.16%1 byte1.01 bytes 0.73%

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.
@bors
Copy link
Collaborator

bors commented Apr 13, 2025

☀️ Try build successful - checks-actions
Build commit: f1a6b16 (f1a6b1636dabcb29e33a88e8b3a9b2817d78286d)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f1a6b16): comparison URL.

Overall result: ❌✅ regressions and improvements - BENCHMARK(S) FAILED

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

❗ ❗ ❗ ❗ ❗
Warning ⚠️: The following benchmark(s) failed to build:

  • rustc

❗ ❗ ❗ ❗ ❗

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.4%] 12
Regressions ❌
(secondary)
0.4% [0.3%, 0.5%] 9
Improvements ✅
(primary)
-0.8% [-1.4%, -0.4%] 109
Improvements ✅
(secondary)
-0.9% [-1.6%, -0.3%] 32
All ❌✅ (primary) -0.7% [-1.4%, 0.4%] 121

Max RSS (memory usage)

Results (primary 1.8%, secondary -0.1%)

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.1%] 37
Regressions ❌
(secondary)
4.1% [2.4%, 9.9%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.2% [-4.9%, -1.8%] 8
All ❌✅ (primary) 1.8% [1.1%, 3.1%] 37

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: missing data
Artifact size: 365.51 MiB -> 365.49 MiB (-0.01%)

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

Kobzol commented Apr 14, 2025

The bootstrap error looks spurious.

@Kobzol
Copy link
Contributor

Kobzol commented Apr 14, 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 14, 2025
@bors
Copy link
Collaborator

bors commented Apr 14, 2025

⌛ Trying commit 3269f5a with merge 07e2c12...

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 14, 2025
Allow out of order dep graph node encoding

This allows out of order dep graph node encoding by also encoding the index instead of using the file node order as the index.

`MemEncoder` is also brought back to life and used for encoding.

Both of these are done to enable thread-local encoding of dep graph nodes.

This is based on rust-lang#139636.
@bors
Copy link
Collaborator

bors commented Apr 14, 2025

☀️ Try build successful - checks-actions
Build commit: 07e2c12 (07e2c121709ab80ce224c9a471997212c3e9a98d)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (07e2c12): 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%] 14
Regressions ❌
(secondary)
0.5% [0.3%, 1.3%] 11
Improvements ✅
(primary)
-0.7% [-1.3%, -0.4%] 108
Improvements ✅
(secondary)
-0.9% [-1.5%, -0.6%] 23
All ❌✅ (primary) -0.6% [-1.3%, 0.5%] 122

Max RSS (memory usage)

Results (primary 1.7%, secondary -0.2%)

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.7% [1.2%, 2.6%] 39
Regressions ❌
(secondary)
3.8% [1.8%, 9.8%] 5
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.0% [-4.9%, -1.7%] 7
All ❌✅ (primary) 1.7% [1.2%, 2.6%] 39

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.942s -> 780.359s (0.05%)
Artifact size: 365.12 MiB -> 365.08 MiB (-0.01%)

@oli-obk
Copy link
Contributor

oli-obk commented Apr 16, 2025

@bors r+

@bors
Copy link
Collaborator

bors commented Apr 16, 2025

📌 Commit 8fc610e has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 16, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 16, 2025
Allow out of order dep graph node encoding

This allows out of order dep graph node encoding by also encoding the index instead of using the file node order as the index.

`MemEncoder` is also brought back to life and used for encoding.

Both of these are done to enable thread-local encoding of dep graph nodes.

This is based on rust-lang#139636.
@bors
Copy link
Collaborator

bors commented Apr 16, 2025

⌛ Testing commit 8fc610e with merge 2714e13...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Apr 16, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 16, 2025
@Zoxc Zoxc force-pushed the out-of-order-dep-graph branch 2 times, most recently from 6c0e3f0 to fa5c5e0 Compare April 22, 2025 02:25
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 22, 2025
@rust-log-analyzer

This comment has been minimized.

@Zoxc Zoxc force-pushed the out-of-order-dep-graph branch from 381b5b4 to 68513cb Compare April 22, 2025 14:57
@Zoxc
Copy link
Contributor Author

Zoxc commented Apr 24, 2025

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 24, 2025
Comment on lines 34 to 35
pub fn write_with<const N: usize>(&mut self, visitor: impl FnOnce(&mut [u8; N]) -> usize) {
pub fn write_with<const N: usize>(
&mut self,
visitor: impl FnOnce(&mut [MaybeUninit<u8>; N]) -> usize,
) {
self.data.reserve(N);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think we should just not do this commit and instead use resize here on the Vec and use last_chunk to safely take out the array. I do not think this will have a performance impact in practice and it avoids the added maybeuninit complexity and the unsafe code

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 24, 2025
@Zoxc Zoxc force-pushed the out-of-order-dep-graph branch from 68513cb to c8e7c62 Compare April 25, 2025 06:56
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-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

9 participants