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

Make ZST checks in core/alloc more readable #102169

Merged
merged 4 commits into from
Sep 25, 2022

Conversation

scottmcm
Copy link
Member

@scottmcm scottmcm commented Sep 23, 2022

There's a bunch of these checks because of special handing for ZSTs in various unsafe implementations of stuff.

This lets them be T::IS_ZST instead of mem::size_of::<T>() == 0 every time, making them both more readable and more terse.

Not proposed for stabilization. Would be pub(crate) except alloc wants to use it too.

(And while it doesn't matter now, if we ever get something like #85836 making it a const can help codegen be simpler.)

There's a bunch of these checks because of special handing for ZSTs in various unsafe implementations of stuff.

This lets them be `T::IS_ZST` instead of `mem::size_of::<T>() == 0` every time, making them both more readable and more terse.

*Not* proposed for stabilization at this time.  Would be `pub(crate)` except `alloc` wants to use it too.

(And while it doesn't matter now, if we ever get something like 85836 making it a const can help codegen be simpler.)
@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Sep 23, 2022
@rust-highfive
Copy link
Collaborator

r? @thomcc

(rust-highfive has picked a reviewer for you, use r? to override)

@rustbot

This comment was marked as resolved.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 23, 2022
@thomcc
Copy link
Member

thomcc commented Sep 23, 2022

Hm, neat. I know you said it shouldn't impact codegen at all, but I'm a little curious.

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

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

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 23, 2022
@bors
Copy link
Contributor

bors commented Sep 23, 2022

⌛ Trying commit cbbcd9f with merge 62c55795633b779a3a1d8085381e862b9104bf4d...

@scottmcm
Copy link
Member Author

scottmcm commented Sep 23, 2022

I know you said it shouldn't impact codegen at all

All I meant by that was that there's currently no special handling for switchInt on a constant in cg_llvm.

I agree this should have a perf run, but was waiting on the PR build because I'm too good at under-testing locally. Looks like when I fixed some of the warnings(-as-errors) about unused imports I broke the docs 🤦

@bors
Copy link
Contributor

bors commented Sep 23, 2022

💔 Test failed - checks-actions

@bors bors 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 23, 2022
@scottmcm
Copy link
Member Author

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

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

@bors
Copy link
Contributor

bors commented Sep 23, 2022

⌛ Trying commit 96314f9cfb3a489b83e05ce70a48ef045aca6d62 with merge 20e3190ff975b91b5b541a7f5b264084b94ace56...

@bors
Copy link
Contributor

bors commented Sep 23, 2022

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

@rust-timer
Copy link
Collaborator

Queued 20e3190ff975b91b5b541a7f5b264084b94ace56 with parent 77e7e88, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (20e3190ff975b91b5b541a7f5b264084b94ace56): comparison URL.

Overall result: ❌ regressions - 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-review -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.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.3% [0.3%, 0.3%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

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.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-5.0% [-5.0%, -5.0%] 1
All ❌✅ (primary) - - 0

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.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
11.9% [11.9%, 11.9%] 1
Improvements ✅
(primary)
-2.6% [-2.6%, -2.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.6% [-2.6%, -2.6%] 1

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Sep 23, 2022
@scottmcm
Copy link
Member Author

Hmm, that's a weird build failure. RustDoc handled it fine, but now it's a linkchecker error?

Local repro time, I guess -- x.py doc library/std was clean :(

@scottmcm
Copy link
Member Author

Ok, filed #102221 for the weird failure when I tried to use cfg(doc), and fixed it with just using an #[allow].

Should be good to go now 🤞

@rustbot ready

@rust-log-analyzer

This comment has been minimized.

@thomcc
Copy link
Member

thomcc commented Sep 24, 2022

Thank you.

@bors r+

@bors
Copy link
Contributor

bors commented Sep 24, 2022

📌 Commit ed16dbf has been approved by thomcc

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. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 24, 2022
@bors
Copy link
Contributor

bors commented Sep 25, 2022

⌛ Testing commit ed16dbf with merge e58621a...

@bors
Copy link
Contributor

bors commented Sep 25, 2022

☀️ Test successful - checks-actions
Approved by: thomcc
Pushing e58621a to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 25, 2022
@bors bors merged commit e58621a into rust-lang:master Sep 25, 2022
@rustbot rustbot added this to the 1.66.0 milestone Sep 25, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e58621a): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.0% [0.4%, 2.1%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

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.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.2% [2.4%, 4.1%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

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.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
5.2% [3.2%, 7.9%] 4
Improvements ✅
(primary)
-2.3% [-2.7%, -2.1%] 3
Improvements ✅
(secondary)
-2.8% [-2.8%, -2.8%] 1
All ❌✅ (primary) -2.3% [-2.7%, -2.1%] 3

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

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-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