Skip to content

break rustc_expand-rustc_middle dependency - #161263

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
mejrs:expand
Sep 5, 2026
Merged

break rustc_expand-rustc_middle dependency#161263
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
mejrs:expand

Conversation

@mejrs

@mejrs mejrs commented Aug 17, 2026

Copy link
Copy Markdown
Member

View all comments

Back in #145354 (cc @Kobzol), support for caching derive macros was added. With this, rustc_expand was made to depend on rustc_middle.

This PR breaks that dependency so that rustc_expand and rustc_builtin_macros can compile in parallel with rustc_middle.

The timing graph goes from this:
image

to this:
image

Note that the interval where we're exclusively compiling rustc_middle has become much shorter.
Full graphs here:
cargo-timing-main.html
cargo-timing-expand2.html

It's somewhat hard to benchmark reliably but a full bootstrap is about 5-10 seconds faster overall, on a machine with an Amd Ryzen 5900x 12-core processor.

@rustbot

rustbot commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

Some changes occurred in src/tools/cargo

cc @weihanglo

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Aug 17, 2026
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 17, 2026
@rustbot

rustbot commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

r? @JonathanBrouwer

rustbot has assigned @JonathanBrouwer.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 15 candidates

@rustbot

This comment has been minimized.

@mejrs

mejrs commented Aug 17, 2026

Copy link
Copy Markdown
Member Author

Shouldn't show up in single job benchmarks, but still:

I'll also do another benchmark later where the derive expander is always called through the atomic ref (with enable called depending on whether derive macros are cached or not)

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 17, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 17, 2026
break rustc_expand-rustc_middle dependency
@rust-bors

rust-bors Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: e3517d8 (e3517d88b373f392501ed15f89f9f57cd5370ddf)
Base parent: e702eca (e702ecae8a3e3756e8a499f8592be1e3efac0e8f)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (e3517d8): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

Results (secondary 2.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.4% [2.4%, 2.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

This perf run didn't have relevant results for this metric.

Binary size

Results (primary 0.1%, secondary 0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.1%] 72
Regressions ❌
(secondary)
0.1% [0.0%, 0.1%] 114
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [0.0%, 0.1%] 72

Bootstrap: 457.751s -> 466.084s (1.82%)
Artifact size: 398.90 MiB -> 398.92 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 18, 2026
@mejrs

mejrs commented Aug 18, 2026

Copy link
Copy Markdown
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 18, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 18, 2026
break rustc_expand-rustc_middle dependency
@rust-bors

rust-bors Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 8fa19ca (8fa19caf36a75113f80ef0db3ec480a54b3d7329)
Base parent: cda599c (cda599c55f56d6cc234352f267102c293e55f3d0)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (8fa19ca): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

Results (secondary -1.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.7% [-1.7%, -1.7%] 1
All ❌✅ (primary) - - 0

Cycles

Results (primary 2.0%, secondary 0.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.0% [2.0%, 2.0%] 1
Regressions ❌
(secondary)
3.4% [3.4%, 3.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.8% [-1.8%, -1.8%] 1
All ❌✅ (primary) 2.0% [2.0%, 2.0%] 1

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 455.4s -> 455.94s (0.12%)
Artifact size: 398.90 MiB -> 398.97 MiB (0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 18, 2026
Comment thread compiler/rustc_interface/src/callbacks.rs Outdated
@JonathanBrouwer

Copy link
Copy Markdown
Member

A best case scenario

./x check compiler/rustc_expand

Goes from 15.35s -> 11.44s for me, very cool.
With a 9950X processor.

@JonathanBrouwer

Copy link
Copy Markdown
Member

Making sure removing the last commit did not affect perf
@bors try @rust-timer queue

@petrochenkov petrochenkov 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 Sep 4, 2026
@rustbot

rustbot commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@mejrs

mejrs commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

@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 Sep 4, 2026
Comment thread compiler/rustc_expand/src/proc_macro.rs Outdated
@petrochenkov

Copy link
Copy Markdown
Contributor

r=me with a closure #161263 (comment), unless there's a reason not to use it.
@rustbot author

@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 Sep 4, 2026
@mejrs

mejrs commented Sep 5, 2026

Copy link
Copy Markdown
Member Author

Changed to use a closure.

@bors r=petrochenkov

@rust-bors

rust-bors Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📌 Commit de40569 has been approved by petrochenkov

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 5, 2026
Zalathar added a commit to Zalathar/rust that referenced this pull request Sep 5, 2026
break rustc_expand-rustc_middle dependency

Back in rust-lang#145354 (cc @Kobzol), support for caching derive macros was added. With this, rustc_expand was made to depend on rustc_middle.

This PR breaks that dependency so that rustc_expand and rustc_builtin_macros can compile in parallel with rustc_middle.

The timing graph goes from this:
<img width="451" height="438" alt="image" src="https://github.com/user-attachments/assets/2d48b0d4-443c-4ec8-b4f0-a6412e86a62f" />

to this:
<img width="456" height="309" alt="image" src="https://github.com/user-attachments/assets/66519857-fa65-4794-ad66-aa565170e196" />

Note that the interval where we're exclusively compiling rustc_middle has become much shorter.
Full graphs here:
[cargo-timing-main.html](https://github.com/user-attachments/files/31157361/cargo-timing-main.html)
[cargo-timing-expand2.html](https://github.com/user-attachments/files/31157373/cargo-timing-expand2.html)

It's somewhat hard to benchmark reliably but a full bootstrap is about 5-10 seconds faster overall, on a machine with an Amd Ryzen 5900x 12-core processor.
@JonathanBrouwer

JonathanBrouwer commented Sep 5, 2026

Copy link
Copy Markdown
Member

@bors r=petrochenkov,JonathanBrouwer
(including myself as I also did review for this and stand behind the changes)

@rust-bors

rust-bors Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📌 Commit de40569 has been approved by petrochenkov,JonathanBrouwer

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 10. This pull request will be tested once the tree is reopened.

Reason for tree closure: Linux x64 EC2 instances are not starting

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 5, 2026
…hanBrouwer

break rustc_expand-rustc_middle dependency

Back in rust-lang#145354 (cc @Kobzol), support for caching derive macros was added. With this, rustc_expand was made to depend on rustc_middle.

This PR breaks that dependency so that rustc_expand and rustc_builtin_macros can compile in parallel with rustc_middle.

The timing graph goes from this:
<img width="451" height="438" alt="image" src="https://github.com/user-attachments/assets/2d48b0d4-443c-4ec8-b4f0-a6412e86a62f" />

to this:
<img width="456" height="309" alt="image" src="https://github.com/user-attachments/assets/66519857-fa65-4794-ad66-aa565170e196" />

Note that the interval where we're exclusively compiling rustc_middle has become much shorter.
Full graphs here:
[cargo-timing-main.html](https://github.com/user-attachments/files/31157361/cargo-timing-main.html)
[cargo-timing-expand2.html](https://github.com/user-attachments/files/31157373/cargo-timing-expand2.html)

It's somewhat hard to benchmark reliably but a full bootstrap is about 5-10 seconds faster overall, on a machine with an Amd Ryzen 5900x 12-core processor.
rust-bors Bot pushed a commit that referenced this pull request Sep 5, 2026
Rollup of 14 pull requests

Successful merges:

 - #162324 (miri subtree update)
 - #162170 (bootstrap: use target's LLVM libdir when cross-compiling)
 - #158312 (Adds support for AArch64 SVE to inline assembly)
 - #159792 (A more readable debug map for IndexMaps)
 - #160745 (make closures act like MaybeDangling)
 - #161263 (break rustc_expand-rustc_middle dependency)
 - #161895 (std::sys::pal::sgx: fix mismatched alloc/free alignment)
 - #161940 (Promote `wasm32-wasip3` to a tier 2 target)
 - #161397 (coverage: Tidy tests and add some new ones)
 - #161616 (Report precondition violation for `<usize as SliceIndex>::get_unchecked` in const-eval)
 - #162248 (Add regression test for unsized const parameter default ICE)
 - #162250 (Fix hashing of span end columns in incremental compilation)
 - #162265 (cargotest: add lockfiles)
 - #162318 (bootstrap: Fix broken path for `./x doc compiler/rustc --open`)
@rust-bors
rust-bors Bot merged commit b7cb7e0 into rust-lang:main Sep 5, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Sep 5, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 5, 2026
Rollup merge of #161263 - mejrs:expand, r=petrochenkov,JonathanBrouwer

break rustc_expand-rustc_middle dependency

Back in #145354 (cc @Kobzol), support for caching derive macros was added. With this, rustc_expand was made to depend on rustc_middle.

This PR breaks that dependency so that rustc_expand and rustc_builtin_macros can compile in parallel with rustc_middle.

The timing graph goes from this:
<img width="451" height="438" alt="image" src="https://github.com/user-attachments/assets/2d48b0d4-443c-4ec8-b4f0-a6412e86a62f" />

to this:
<img width="456" height="309" alt="image" src="https://github.com/user-attachments/assets/66519857-fa65-4794-ad66-aa565170e196" />

Note that the interval where we're exclusively compiling rustc_middle has become much shorter.
Full graphs here:
[cargo-timing-main.html](https://github.com/user-attachments/files/31157361/cargo-timing-main.html)
[cargo-timing-expand2.html](https://github.com/user-attachments/files/31157373/cargo-timing-expand2.html)

It's somewhat hard to benchmark reliably but a full bootstrap is about 5-10 seconds faster overall, on a machine with an Amd Ryzen 5900x 12-core processor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) 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.

7 participants