Skip to content

Drop AST on a separate thread and prefetch hir_crate #121909

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

Merged
merged 1 commit into from
May 1, 2025

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Mar 2, 2024

This drop AST on a separate thread and prefetches hir_crate.

A spawn function is added to the parallel module which spawn some work on the Rayon thread pool.

@rustbot
Copy link
Collaborator

rustbot commented Mar 2, 2024

r? @cjgillot

rustbot has assigned @cjgillot.
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 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 Mar 2, 2024
Copy link
Contributor

@cjgillot cjgillot left a comment

Choose a reason for hiding this comment

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

Did you measure a perf difference?

@Zoxc
Copy link
Contributor Author

Zoxc commented Mar 3, 2024

Did you measure a perf difference?

I expect it would below my noise threshold. I did verify the behavior with self profiling though.

@cjgillot cjgillot 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 Mar 10, 2024
@bors

This comment was marked as resolved.

@oskgo
Copy link
Contributor

oskgo commented Jul 11, 2024

@Zoxc Any updates on this? Thanks!

@JohnCSimon
Copy link
Member

@Zoxc
Ping from triage: I'm closing this due to inactivity, Please reopen when you are ready to continue with this.
Note: if you are going to continue please open the PR BEFORE you push to it, else you won't be able to reopen - this is a quirk of github.
Thanks for your contribution.

@rustbot label: +S-inactive

@JohnCSimon JohnCSimon closed this Sep 3, 2024
@rustbot rustbot added the S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. label Sep 3, 2024
@Kobzol Kobzol reopened this Apr 2, 2025
@Zoxc
Copy link
Contributor Author

Zoxc commented Apr 2, 2025

r? compiler

@rustbot rustbot assigned petrochenkov and unassigned cjgillot Apr 2, 2025
@Kobzol
Copy link
Contributor

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

bors commented Apr 2, 2025

⌛ Trying commit e727382 with merge 247ff35...

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 2, 2025
Drop AST on a separate thread and prefetch `hir_crate`

This drop AST on a separate thread and prefetches `hir_crate`.

A `spawn` function is added to the `parallel` module which spawn some work on the Rayon thread pool.
@petrochenkov petrochenkov removed the S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. label Apr 2, 2025
@bors
Copy link
Collaborator

bors commented Apr 2, 2025

☀️ Try build successful - checks-actions
Build commit: 247ff35 (247ff35e9d6791d72ca2b1bd38483cd93fbcf19d)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (247ff35): comparison URL.

Overall result: ❌ regressions - 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.2% [0.2%, 0.2%] 2
Regressions ❌
(secondary)
0.3% [0.1%, 0.6%] 25
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [0.2%, 0.2%] 2

Max RSS (memory usage)

Results (primary 0.8%, secondary -2.0%)

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)
3.1% [3.1%, 3.1%] 1
Regressions ❌
(secondary)
2.3% [2.2%, 2.5%] 2
Improvements ✅
(primary)
-1.6% [-1.6%, -1.6%] 1
Improvements ✅
(secondary)
-3.0% [-4.4%, -0.9%] 9
All ❌✅ (primary) 0.8% [-1.6%, 3.1%] 2

Cycles

Results (secondary -2.9%)

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)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.9% [-3.2%, -2.7%] 2
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 776.507s -> 777.766s (0.16%)
Artifact size: 366.05 MiB -> 365.95 MiB (-0.03%)

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

@Zoxc What is the status of this PR? Is it ready for review, or something still needs to be done?

@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 28, 2025
@rustbot
Copy link
Collaborator

rustbot commented Apr 28, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@Zoxc
Copy link
Contributor Author

Zoxc commented Apr 28, 2025

Why merging this if the perf diff is below the threshold?

Because I expect it to improve performance. I can see that AST dropping is offloaded to another thread and threads are no longer blocked on hir_crate with self-profiling. Running the parallel compiler is just too noisy to measure any improvements.

@petrochenkov
Copy link
Contributor

Ok, this is simple enough, and looks reasonable, let's merge.
r=me with the comment explaining the weirdness in hir_crate prefetching.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@Zoxc
Copy link
Contributor Author

Zoxc commented Apr 29, 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 29, 2025
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Apr 30, 2025

📌 Commit ef94033 has been approved by petrochenkov

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 30, 2025
@bors
Copy link
Collaborator

bors commented Apr 30, 2025

⌛ Testing commit ef94033 with merge 0c33fe2...

@bors
Copy link
Collaborator

bors commented May 1, 2025

☀️ Test successful - checks-actions
Approved by: petrochenkov
Pushing 0c33fe2 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 1, 2025
@bors bors merged commit 0c33fe2 into rust-lang:master May 1, 2025
7 checks passed
@rustbot rustbot added this to the 1.88.0 milestone May 1, 2025
Copy link

github-actions bot commented May 1, 2025

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing b45dd71 (parent) -> 0c33fe2 (this PR)

Test differences

No test diffs found

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 0c33fe2c3d3eecadd17a84b110bb067288a64f1c --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-aarch64-apple: 5535.0s -> 4671.7s (-15.6%)
  2. dist-apple-various: 7325.4s -> 6251.0s (-14.7%)
  3. x86_64-gnu-llvm-20-1: 5362.5s -> 6091.3s (13.6%)
  4. x86_64-gnu-tools: 6417.5s -> 5582.3s (-13.0%)
  5. dist-riscv64-linux: 5825.3s -> 5115.1s (-12.2%)
  6. x86_64-apple-2: 5647.7s -> 5112.9s (-9.5%)
  7. x86_64-msvc-ext1: 7770.1s -> 7146.0s (-8.0%)
  8. dist-arm-linux: 4770.1s -> 5128.4s (7.5%)
  9. aarch64-apple: 4272.4s -> 4029.3s (-5.7%)
  10. dist-x86_64-apple: 8622.8s -> 8269.4s (-4.1%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (0c33fe2): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -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
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.9% [-2.9%, -2.9%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.9% [-2.9%, -2.9%] 1

Max RSS (memory usage)

Results (primary 0.1%, secondary -1.6%)

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)
2.6% [0.8%, 4.7%] 4
Regressions ❌
(secondary)
2.0% [2.0%, 2.0%] 2
Improvements ✅
(primary)
-0.8% [-2.8%, -0.4%] 11
Improvements ✅
(secondary)
-4.1% [-4.5%, -3.9%] 3
All ❌✅ (primary) 0.1% [-2.8%, 4.7%] 15

Cycles

Results (primary 0.1%, secondary -2.7%)

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)
0.7% [0.4%, 1.1%] 9
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.0% [-2.8%, -0.4%] 5
Improvements ✅
(secondary)
-2.7% [-3.1%, -2.4%] 5
All ❌✅ (primary) 0.1% [-2.8%, 1.1%] 14

Binary size

Results (primary -1.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)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.1% [-1.1%, -1.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.1% [-1.1%, -1.1%] 1

Bootstrap: 767.216s -> 768.387s (0.15%)
Artifact size: 365.58 MiB -> 365.56 MiB (-0.01%)

@rustbot rustbot removed the perf-regression Performance regression. label May 1, 2025
@Zoxc Zoxc deleted the drop-ast-task branch May 1, 2025 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

10 participants