Skip to content

Experiment: spaceship in MIR #108800

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

Closed
wants to merge 1 commit into from

Conversation

scottmcm
Copy link
Member

@scottmcm scottmcm commented Mar 6, 2023

As mentioned in #108788 (comment), Ord::cmp on primitives generates a large amount of MIR, preventing (or at least discouraging) it from mir-inlining.

Let's see whether making it a MIR primitive helps stuff -- derived (Partial)Ord in particular, if we're lucky.

r? @ghost

@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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Mar 6, 2023
@scottmcm scottmcm force-pushed the three-way-compare branch from 99c956d to 01d0e9e Compare March 6, 2023 04:55
As mentioned in <rust-lang#108788 (comment)>, `Ord::cmp` on primitives generates a large amount of MIR, preventing (or at least discouraging) it from mir-inlining.

Let's see whether making it a MIR primitive helps stuff -- derived `(Partial)Ord` in particular, if we're lucky.
@scottmcm scottmcm force-pushed the three-way-compare branch from 01d0e9e to d6fa338 Compare March 6, 2023 05:15
@scottmcm
Copy link
Member Author

scottmcm commented Mar 6, 2023

@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 Mar 6, 2023
@bors
Copy link
Collaborator

bors commented Mar 6, 2023

⌛ Trying commit d6fa338 with merge afab298db3408356c94adab4dfc262c869673b6d...

@bors
Copy link
Collaborator

bors commented Mar 6, 2023

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

@rust-timer

This comment has been minimized.

}
#[cfg(not(bootstrap))]
{
crate::intrinsics::three_way_compare(*self, *other)
Copy link
Contributor

Choose a reason for hiding this comment

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

a question for my own understanding: is there a reason why it's better (or has to be) for this to be in a single instance of the fn cmp rather than either #[cfg(bootstrap)] fn cmp(...) or on the impl?

Copy link
Member Author

Choose a reason for hiding this comment

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

I just put it here because it's the least copy-pasting. Doing it at other levels would work too, but would mean duplicating the #[inline] or stability attributes, which leaves more opportunities for me to get it wrong.

Copy link
Member

Choose a reason for hiding this comment

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

You don't have the duplicate the signature and the #[inline] attribute. But it doesn't make that much of a difference (also hopefully we'll get rid of these cfg(bootstrap) inside the standard library soon anyways🤞)

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (afab298db3408356c94adab4dfc262c869673b6d): comparison URL.

Overall result: ❌✅ regressions and improvements - 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.

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 a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.4% [0.3%, 0.5%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.0% [-1.1%, -0.9%] 2
Improvements ✅
(secondary)
-2.2% [-2.6%, -2.0%] 7
All ❌✅ (primary) -0.3% [-1.1%, 0.5%] 4

Max RSS (memory usage)

Results

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.2% [2.1%, 4.3%] 2
Regressions ❌
(secondary)
3.7% [3.7%, 3.7%] 1
Improvements ✅
(primary)
-0.1% [-0.1%, -0.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.1% [-0.1%, 4.3%] 3

Cycles

Results

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.5% [-2.5%, -2.5%] 1
All ❌✅ (primary) - - 0

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Mar 6, 2023
@Dylan-DPC
Copy link
Member

Closing this as it was an experiment

@Dylan-DPC Dylan-DPC closed this Aug 7, 2023
@Dylan-DPC Dylan-DPC added S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library 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