-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
debug-assert ptr sanity in ptr::write #69509
Conversation
As @eddyb suggested I tried
If I read this correctly, then the codegen test expected With the fix I just pushed, this locally passes both on 64bit and 32bit (Linux each time; the wasm32 target doesn't work as I am missing |
Maybe we should ignore that distinction in the test? Seems really weird though. |
Yeah, I think that's what I am doing in the last commit I pushed here.
I can't see a |
You're hardcoding the (weird) |
Oh I see. Well let's see what others think before I do further edits here.
Ah, that's how this works. :D |
Apropos of nothing, I just realized I want a way in I don't even want debug assertions (IMO rustc itself should never use them, just in case they affect soundness, but that's orthogonal), it's just that debug logging is gated on it. |
Would be interesting to see this confirmed. There aren't that many, really, and I feel like LLVM ought to be able to optimize most of them away -- but maybe it is not as good at that as it could be.
We use them in the Miri engine for some checks that have non-trivial cost, so we don't want to slow down release builds with those sanity checks. |
Not if e.g. functions operating on raw pointers aren't inlined into functions that operate on references, or if said inlining happens to lose some information. For the record the worst I've seen so far is a slowdown of 2.4x for one crate, between nightly and a local build (using the times in the
Hopefully they're really hard to trigger by screwing up elsewhere, especially from other parts of the compiler. However, if you do get the chance to measure any of them, and it happens to be not that impactful perf-wise, please change it to a regular |
Ouch. Well if you think these raw-ptr related debug assertions have significant impact on this (would be good to get that explicitly tested), I'm okay removing them. I figured they would be a nice safety net but it might just be too expensive. If you give me a benchmark, I might find some time to test this. |
I'd prefer to keep them but for me to be able to turn But due to the variation in slowdown between different crates being compiled I'm starting to suspect |
Just found a non-project-specific crate in those builds: |
r? @eddyb on this one I think |
693b4d3
to
6cc3d7a
Compare
7f53150
to
9d43ebf
Compare
I did these adjustments. I hope the test looks good now. :) |
9d43ebf
to
b324136
Compare
src/test/ui/issues/issue-40883.rs
Outdated
// give space for 2 copies of `Big` + 256 "misc" bytes. | ||
if stack_usage > mem::size_of::<Big>() * 2 + 256 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this constant be binary searched so it's less than double the previous value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought powers of two were nice, but sure. ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
208 is the smallest value that works for me.
But I am a bit worried it might be larger for other platforms / architectures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't support a target with larger sizes/alignments than x64 I don't think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh nevermind, they could less efficient in their stack usage even if the types aren't larger.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's what I meant.
Pinging @nagisa @nikic @hanna-kruppe again, any reason we'd end up with a I thought the EDIT: we can merge this PR without solving that but I'm curious why it might even happen. |
No plausible reason for that comes to mind. It's not just very weird in itself, it's also very spooky that the changes in this PR have such an effect. |
I don't have the bandwidth for it currently, but it would be great if someone could:
|
5e09c13
to
5fbd0cb
Compare
@bors p=3 |
⌛ Testing commit c95f08a with merge 7202bc73630dad1231bfee91ad11aaec8f537ef5... |
💔 Test failed - checks-azure |
Looks spurious to me @bors retry |
⌛ Testing commit c95f08a with merge fc65ff9d482d99e59c4274c00865bbe924fbfa04... |
💔 Test failed - checks-azure |
@bors retry |
⌛ Testing commit c95f08a with merge ba06223814d736f19b8a4853d708eebb6a67feb0... |
@bors retry yielding |
⌛ Testing commit c95f08a with merge dd53a2af944fe834c7c8b15b3cebaa513fc47af6... |
@bors retry yield rollup |
☀️ Test successful - checks-azure |
This is a re-submission of the parts that we removed from #69208 due to "interesting" test failures.
Fixes #53871
r? @Mark-Simulacrum @eddyb