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

memory access sanity checks: abort instead of panic #73054

Merged
merged 2 commits into from
Jun 19, 2020

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Jun 6, 2020

Suggested by @Mark-Simulacrum, this should help reduce the performance impact of these checks.

@rust-highfive
Copy link
Collaborator

r? @shepmaster

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 6, 2020
@Mark-Simulacrum
Copy link
Member

To be clear, I'm not sure :) I think my measurements were inconclusive. But, in theory, I would expect this to be better able to inline etc.

Ideally we'd run perf.r-l.o against this but to do that we'd need to build and publish a debug assertions compiler to compare against...

@RalfJung
Copy link
Member Author

But, in theory, I would expect this to be better able to inline etc.

Is that enough to land this? I don't think I'll have time to do proper benchmarking any time soon... and this code is UB if we don't abort, so not having perfect panic-based stacktraces seems acceptable.

@RalfJung
Copy link
Member Author

@Mark-Simulacrum

To be clear, I'm not sure :) I think my measurements were inconclusive. But, in theory, I would expect this to be better able to inline etc.

So how do you suggest we proceed? I don't have time to do proper measurements here. Should I close the PR, or should we land this because it'll surely not degrade debug-std performance?

@Mark-Simulacrum
Copy link
Member

I can try to find some time to prepare the try commits for perf.rlo to benchmark (by pushing to this PR), hopefully today.

@shepmaster
Copy link
Member

r? @Mark-Simulacrum

@Mark-Simulacrum
Copy link
Member

@bors try

@bors
Copy link
Contributor

bors commented Jun 16, 2020

⌛ Trying commit 166480e3a0a9a89bacbf30e3abf3ac45cccb1391 with merge d94127aecf2bae628907d43c376b8fe5070431db...

@Mark-Simulacrum
Copy link
Member

And with reverts of the first two commits..

@bors try @rust-timer queue

I think perf will only pick up the first try build to complete (or maybe neither, unsure) but we can check the other one manually anyway.

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Jun 16, 2020

⌛ Trying commit da345f73558c5aa1768bf0b780a5ab3573e97a79 with merge ebc6a503e956df6a5e66b34fd34b251b596d3431...

@bors
Copy link
Contributor

bors commented Jun 16, 2020

☀️ Try build successful - checks-azure
Build commit: ebc6a503e956df6a5e66b34fd34b251b596d3431 (ebc6a503e956df6a5e66b34fd34b251b596d3431)

@rust-timer
Copy link
Collaborator

Queued ebc6a503e956df6a5e66b34fd34b251b596d3431 with parent f315c35, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (ebc6a503e956df6a5e66b34fd34b251b596d3431): comparison url.

@Mark-Simulacrum
Copy link
Member

@rust-timer build d94127aecf2bae628907d43c376b8fe5070431db

@rust-timer
Copy link
Collaborator

Queued d94127aecf2bae628907d43c376b8fe5070431db with parent f315c35, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (d94127aecf2bae628907d43c376b8fe5070431db): comparison url.

@Mark-Simulacrum
Copy link
Member

Okay so now both of those are done, the right thing to look at is this comparison: https://perf.rust-lang.org/compare.html?start=ebc6a503e956df6a5e66b34fd34b251b596d3431&end=d94127aecf2bae628907d43c376b8fe5070431db, which compares "debug asserts w/o this PR" and "debug asserts w/ this PR" -- it looks like it's a pretty nice win, 3-10% pretty much across the board. It's also notable that debug assertions are really expensive today regardless, 10-30% regressions on many benchmarks.

We probably don't want to apply this pattern exactly across the board -- abort() is after all harder to debug -- but I wonder if we can invent some "low-cost" debug_assert, e.g., one that emulates panic=abort or so (so we still get a backtrace potentially and such, but we still avoid the unwind).

I imagine you probably don't have the bandwidth to explore doing so? Maybe we should re-run benchmarks on a PR that changes debug_assert! to literally abort() if the condition fails to get a sense of how much performance that can win back.

cc @nnethercote as well

@RalfJung
Copy link
Member Author

I imagine you probably don't have the bandwidth to explore doing so?

I'm afraid I do not. I also have no idea how you did the benchmarking here.^^ But it seems like the PR is a clear win, and only some very low-level methods are changed to not have backtraces any more, so seems like a good sign to me independent of the other changes you suggested.

@Mark-Simulacrum
Copy link
Member

Okay I'll remove the benchmarking commits on this PR and approve it, I agree it's a sufficient win just by itself.

The way to do benchmarks like this is to get a build from just debug asserts being enabled and another build (critically with same parent on master) with debug asserts plus this PR's changes, then you compare the two try commits directly in perf.rlo.

@RalfJung
Copy link
Member Author

Oh and you adjusted CI config to get debug assertions in try builds, I see.

@Mark-Simulacrum
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jun 16, 2020

📌 Commit 81c7ebd has been approved by Mark-Simulacrum

@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 Jun 16, 2020
@Mark-Simulacrum
Copy link
Member

(Should be fine to rollup, as there's no expected impact on non-debug-assert builds).

bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 19, 2020
Rollup of 10 pull requests

Successful merges:

 - rust-lang#72280 (Fix up autoderef when reborrowing)
 - rust-lang#72785 (linker: MSVC supports linking static libraries as a whole archive)
 - rust-lang#73011 (first stage of implementing LLVM code coverage)
 - rust-lang#73044 (compiletest: Add directives to detect sanitizer support)
 - rust-lang#73054 (memory access sanity checks: abort instead of panic)
 - rust-lang#73136 (Change how compiler-builtins gets many CGUs)
 - rust-lang#73280 (Add E0763)
 - rust-lang#73317 (bootstrap: read config from $RUST_BOOTSTRAP_CONFIG)
 - rust-lang#73350 (bootstrap/install.rs: support a nonexistent `prefix` in `x.py install`)
 - rust-lang#73352 (Speed up bootstrap a little.)

Failed merges:

r? @ghost
@bors bors merged commit 125c196 into rust-lang:master Jun 19, 2020
@RalfJung RalfJung deleted the dont-panic branch June 20, 2020 10:07
@cuviper cuviper added this to the 1.46 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants