Skip to content
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

move all mono-time checks into their own folder, and their own query #132843

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Nov 10, 2024

The mono item collector currently also drives two mono-time checks: the lint for "large moves", and the check whether function calls are done with all the required target features.

Instead of doing this "inside" the collector, this PR refactors things so that we have a new rustc_monomorphize::mono_checks module providing a per-instance query that does these checks. We already have a per-instance query for the ABI checks, so this should be "free" for incremental builds. Non-incremental builds might do a bit more work now since we now have two separate MIR visits (in the collector and the mono-time checks) -- but one of them is cached in case the MIR doesn't change, which is nice.

This slightly changes behavior of the large-move check since the "move_size_spans" deduplication logic now only works per-instance, not globally across the entire collector.

Cc @saethlin since you're also doing some work related to queries and caching and monomorphization, though I don't know if there's any interaction here.

@rustbot
Copy link
Collaborator

rustbot commented Nov 10, 2024

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 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 Nov 10, 2024
@RalfJung
Copy link
Member Author

@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 Nov 10, 2024
@bors
Copy link
Contributor

bors commented Nov 10, 2024

⌛ Trying commit 23054c5 with merge 0c32858...

bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 10, 2024
move all mono-time checks into their own folder, and their own query

The mono item collector currently also drives two mono-time checks: the lint for "large moves", and the check whether function calls are done with all the required target features.

Instead of doing this "inside" the collector, this PR refactors things so that we have a new `rustc_monomorphize::mono_checks` module providing a per-instance query that does these checks. We already have a per-instance query for the ABI checks, so this should be "free" for incremental builds. Non-incremental builds might do a bit more work now since we now have two separate MIR visits (in the collector and the mono-time checks) -- but one of them is cached in case the MIR doesn't change so that seems nice?

This slightly changes behavior of the large-move check since the "move_size_spans" deduplication logic now only works per-instance, not globally across the entire collector.

We could save some work by sharing the visitor between the ABI checks and the move checks, but let's see perf before doing that work.

Cc `@saethlin` since you're also doing some work related to queries and caching and monomorphization, though I don't know if there's any interaction here.
@bors
Copy link
Contributor

bors commented Nov 10, 2024

☀️ Try build successful - checks-actions
Build commit: 0c32858 (0c32858adbe120178078d89250910d237329c4e9)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (0c32858): comparison URL.

Overall result: ✅ improvements - no action needed

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.

@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
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.2% [-0.2%, -0.2%] 3
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 1
All ❌✅ (primary) -0.2% [-0.2%, -0.2%] 3

Max RSS (memory usage)

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

Cycles

Results (secondary 2.4%)

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)
3.6% [3.3%, 4.2%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.2% [-2.2%, -2.2%] 1
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 785.39s -> 786.581s (0.15%)
Artifact size: 335.26 MiB -> 335.38 MiB (0.04%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 10, 2024
@RalfJung
Copy link
Member Author

That's not quite as much as I was hoping for given #132467, but even a neutral result is good news IMO since this cleans up the code. :)

@RalfJung
Copy link
Member Author

@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 Nov 10, 2024
@bors
Copy link
Contributor

bors commented Nov 10, 2024

⌛ Trying commit f25b73b with merge 562f46b...

bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 10, 2024
move all mono-time checks into their own folder, and their own query

The mono item collector currently also drives two mono-time checks: the lint for "large moves", and the check whether function calls are done with all the required target features.

Instead of doing this "inside" the collector, this PR refactors things so that we have a new `rustc_monomorphize::mono_checks` module providing a per-instance query that does these checks. We already have a per-instance query for the ABI checks, so this should be "free" for incremental builds. Non-incremental builds might do a bit more work now since we now have two separate MIR visits (in the collector and the mono-time checks) -- but one of them is cached in case the MIR doesn't change, which is nice.

This slightly changes behavior of the large-move check since the "move_size_spans" deduplication logic now only works per-instance, not globally across the entire collector.

Cc `@saethlin` since you're also doing some work related to queries and caching and monomorphization, though I don't know if there's any interaction here.
@bors
Copy link
Contributor

bors commented Nov 10, 2024

☀️ Try build successful - checks-actions
Build commit: 562f46b (562f46ba55d4c1d3684c439eb0f048429f26b6be)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (562f46b): 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
Regressions ❌
(secondary)
5.8% [5.8%, 5.8%] 1
Improvements ✅
(primary)
-0.2% [-0.2%, -0.2%] 1
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 1
All ❌✅ (primary) -0.2% [-0.2%, -0.2%] 1

Max RSS (memory usage)

Results (primary -2.3%, secondary 1.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)
- - 0
Regressions ❌
(secondary)
4.0% [3.0%, 5.1%] 2
Improvements ✅
(primary)
-2.3% [-2.3%, -2.3%] 1
Improvements ✅
(secondary)
-4.3% [-4.3%, -4.3%] 1
All ❌✅ (primary) -2.3% [-2.3%, -2.3%] 1

Cycles

Results (secondary 2.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)
- - 0
Regressions ❌
(secondary)
2.3% [2.1%, 2.6%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 787.115s -> 786.126s (-0.13%)
Artifact size: 335.35 MiB -> 335.43 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 Nov 10, 2024
@RalfJung
Copy link
Member Author

RalfJung commented Nov 10, 2024

That actually makes things worse? What the heck? I thought doing fewer monomorphize calls and fewer mono_reachable traversals should help...

Ah well, I'll un-do the 2nd commit then.

@saethlin
Copy link
Member

I don't think there is a significant difference between the two perf reports. The first one reports -0.21% on 3 primary benchmarks, and in the second, those results drop to -0.19%. Those are all incr-unchanged too.

The Detailed Results for the single regression point to time in LLVM and the linker as the cause, which doesn't make any sense. I'd bet that benchmark is just unstable.

@RalfJung
Copy link
Member Author

RalfJung commented Nov 10, 2024

Yeah, but my expectation was that this would help.

Though, thinking about it more... it can only help when the query gets executed. The affected primary benchmarks are all incr-unchanged, so the query doesn't even get executed. The commit should have helped with full or incr-full builds, but I guess there the entire query is not a measurable part of the overall runtime.

Keeping the visiting logic in the separate checks seems slightly cleaner to me (and avoids the visiting_function_call ugly hack), so with performance being equal, I prefer the first variant -- the one that is now in the PR. I can restore the other one though if you / the reviewer prefers that.

}

fn build_skip_move_check_fns(tcx: TyCtxt<'_>) -> Vec<DefId> {
pub(crate) fn skip_move_check_fns(tcx: TyCtxt<'_>, _: ()) -> FxIndexSet<DefId> {
Copy link
Contributor

Choose a reason for hiding this comment

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

existing issue: but i feel like this should just be a diagnostics/rustc attribute on these methods 😅 having a builtin list here is quite meh

@lcnr
Copy link
Contributor

lcnr commented Nov 11, 2024

@bors r+ rollup=never

@bors
Copy link
Contributor

bors commented Nov 11, 2024

📌 Commit 23054c5 has been approved by lcnr

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 Nov 11, 2024
@bors
Copy link
Contributor

bors commented Nov 12, 2024

⌛ Testing commit 23054c5 with merge 583b25d...

@bors
Copy link
Contributor

bors commented Nov 12, 2024

☀️ Test successful - checks-actions
Approved by: lcnr
Pushing 583b25d to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 12, 2024
@bors bors merged commit 583b25d into rust-lang:master Nov 12, 2024
13 checks passed
@rustbot rustbot added this to the 1.84.0 milestone Nov 12, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (583b25d): 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)
-0.2% [-0.2%, -0.2%] 4
Improvements ✅
(secondary)
-0.4% [-0.4%, -0.4%] 1
All ❌✅ (primary) -0.2% [-0.2%, -0.2%] 4

Max RSS (memory usage)

Results (primary 0.1%, secondary -4.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)
3.3% [3.3%, 3.3%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.5% [-1.8%, -1.2%] 2
Improvements ✅
(secondary)
-4.1% [-4.1%, -4.1%] 1
All ❌✅ (primary) 0.1% [-1.8%, 3.3%] 3

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: 784.209s -> 787.726s (0.45%)
Artifact size: 335.24 MiB -> 335.35 MiB (0.03%)

@rustbot rustbot removed the perf-regression Performance regression. label Nov 12, 2024
@RalfJung RalfJung deleted the mono-time-checks branch November 12, 2024 19:06
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.

6 participants