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

Check for occupied niches #104862

Closed
wants to merge 1 commit into from
Closed

Conversation

saethlin
Copy link
Member

@saethlin saethlin commented Nov 25, 2022

Implementation of rust-lang/compiler-team#624

Crater run has 62 crates that hit the check, 43 of those are published to crates.io. I see a lot of null function pointers and use of mem::uninitialized where the 0x1-filling collides with an enum niche.

But that is with full niche checks; checking transmute, plus any place where that we Copy, Move, or Inspect. Such checking is definitely too thorough to be on by default because it is 2x compile time overhead.


During implementation, this ran into llvm/llvm-project#68381

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. labels Nov 25, 2022
@rust-log-analyzer

This comment has been minimized.

@jackh726 jackh726 added S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 10, 2023
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@technetos technetos marked this pull request as ready for review April 3, 2023 02:03
@rustbot
Copy link
Collaborator

rustbot commented Apr 3, 2023

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@saethlin saethlin marked this pull request as draft April 3, 2023 02:49
@saethlin
Copy link
Member Author

saethlin commented Apr 3, 2023

This is not done yet. I wish generalized niche checks were as simple as what I whipped up here, and also CI doesn't pass for... reasons.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented May 2, 2023

☔ The latest upstream changes (presumably #111082) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label May 2, 2023
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@saethlin
Copy link
Member Author

To reproduce the crash, compile this:

#[derive(thiserror::Error)]
#[error("...")]
pub enum ErrorEnum {
    Test {
        source: u8, 
    },  
}

With a toolchain built with

[rust]
debug = true
codegen-units = 1

@rust-log-analyzer

This comment has been minimized.

@DianQK
Copy link
Member

DianQK commented Oct 30, 2023

To reproduce the crash, compile this:

#[derive(thiserror::Error)]
#[error("...")]
pub enum ErrorEnum {
    Test {
        source: u8, 
    },  
}

With a toolchain built with

[rust]
debug = true
codegen-units = 1

I can confirm that this is the same issue as #116976. LLVM 17.0.4 should be released soon.

@bors
Copy link
Contributor

bors commented Nov 2, 2023

☔ The latest upstream changes (presumably #117498) made this pull request unmergeable. Please resolve the merge conflicts.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@saethlin
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, 2023
@bors
Copy link
Contributor

bors commented Nov 10, 2023

⌛ Trying commit 5c19cfd with merge eaa4669...

bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 10, 2023
Check for occupied niches

Implementation of rust-lang/compiler-team#624

Crater run has 62 crates that hit the check, 43 of those are published to crates.io. I see a lot of null function pointers and use of `mem::uninitialized` where the 0x1-filling collides with an enum niche.

But that is with full niche checks; checking transmute, plus any place where that we Copy, Move, or Inspect. Such checking is definitely too thorough to be on by default because it is 2x compile time overhead.

---

During implementation, this ran into llvm/llvm-project#68381

r? `@ghost`
@bors
Copy link
Contributor

bors commented Nov 10, 2023

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

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (eaa4669): 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)
1.1% [0.1%, 3.5%] 17
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.6% [-1.2%, -0.2%] 3
All ❌✅ (primary) 1.1% [0.1%, 3.5%] 17

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)
1.8% [0.2%, 7.9%] 17
Regressions ❌
(secondary)
3.9% [2.6%, 5.2%] 3
Improvements ✅
(primary)
-2.1% [-4.6%, -0.7%] 5
Improvements ✅
(secondary)
-2.2% [-2.2%, -2.2%] 1
All ❌✅ (primary) 0.9% [-4.6%, 7.9%] 22

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)
1.6% [0.4%, 3.3%] 8
Regressions ❌
(secondary)
2.0% [2.0%, 2.0%] 1
Improvements ✅
(primary)
-0.4% [-0.4%, -0.4%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.4% [-0.4%, 3.3%] 9

Binary size

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.5% [0.0%, 1.1%] 45
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.2%, -0.0%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.4% [-0.2%, 1.1%] 48

Bootstrap: 674.395s -> 673.749s (-0.10%)
Artifact size: 311.13 MiB -> 311.07 MiB (-0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 11, 2023
@Dylan-DPC
Copy link
Member

@saethlin any updates on this?

@saethlin
Copy link
Member Author

saethlin commented Feb 5, 2024

Yes; I'm working on an alternative implementation. It's almost ready for a draft PR.

@saethlin
Copy link
Member Author

Replaced by #121174

@saethlin saethlin closed this Feb 16, 2024
@saethlin saethlin deleted the mir-niche-checks branch February 16, 2024 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. 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-opsem Relevant to the opsem team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants