-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add #[track_caller] to track callers when initializing poisoned Once #94236
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @yaahc (or someone else) soon. Please see the contribution instructions for more information. |
Hey, thank you for taking on this issue :D. Let's start with a perf test. @bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit f4576017596cf669578e6075b186727feaca9d22 with merge d383a74d639169718e7de27d4754aebb019b5d4a... |
☀️ Try build successful - checks-actions |
Queued d383a74d639169718e7de27d4754aebb019b5d4a with parent 68369a0, future comparison URL. |
Finished benchmarking commit (d383a74d639169718e7de27d4754aebb019b5d4a): comparison url. Summary: This benchmark run shows 4 relevant regressions 😿 to instruction counts.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. 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 led to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never |
@yaahc
Which is better? |
I wasn't sure at first since I'm not super familiar with the rustc-perf test suite so I asked some other team members on the zulip and it seems that the regressions on the For next steps, Can you add a UI test to make sure we've added |
@rustbot label: +perf-regression-triaged Yeah, |
OK, thanks. |
It's worth noting that perf is probably a pretty bad way to measure the effects of a patch like this. The compiler doesn't use std::sync::Once pretty much at all, so this is really at best measuring the extra codegen time if any of our benchmarks in the compiler suite are using it. Constructing proper benchmarks for something like Once is probably pretty difficult, so in the absence of them I would likely not block on perf concerns. We definitely do want a test, though: I suspect the current impl is actually broken; it looks like the track_caller is not put on the |
Oh, I'm sure you're right. |
f457601
to
5ae214a
Compare
Just checked your force push diff, I think you'll want to keep the #[track_caller] annotation on both the inner and outer functions to get the location to propagate all the way in from user code. |
Thanks for checking. |
I have started writing tests, but am a little stuck. src/test/ui/issues/issue-87707.rs // test for #87707
// edition:2018
use std::sync::Once;
use std::panic;
fn main() {
let o = Once::new();
let _ = panic::catch_unwind(|| {
o.call_once(|| panic!("Here Once instance is poisoned."));
});
o.call_once(|| {});
} That is, I am having trouble getting the standard error output to do what I expect. $ ./x.py test src/test/ui/issues/issue-87707.rs --bless --stage 1
~~~snip~~~
running 1 test
F
failures:
---- [ui] ui/issues/issue-87707.rs stdout ----
error: ui test compiled successfully!
status: exit status: 0
command: "/Users/reez12g/development/rust/build/aarch64-apple-darwin/stage1/bin/rustc" "/Users/reez12g/development/rust/src/test/ui/issues/issue-87707.rs" "-Zthreads=1" "--target=aarch64-apple-darwin" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/Users/reez12g/development/rust/build/aarch64-apple-darwin/test/ui/issues/issue-87707" "-A" "unused" "-Crpath" "-O" "-Cdebuginfo=0" "-Lnative=/Users/reez12g/development/rust/build/aarch64-apple-darwin/native/rust-test-helpers" "--edition=2018" "-L" "/Users/reez12g/development/rust/build/aarch64-apple-darwin/test/ui/issues/issue-87707/auxiliary"
stdout:
------------------------------------------
------------------------------------------
stderr:
------------------------------------------
------------------------------------------
failures:
[ui] ui/issues/issue-87707.rs
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 12657 filtered out; finished in 1.42s
Some tests failed in compiletest suite=ui mode=ui host=aarch64-apple-darwin target=aarch64-apple-darwin
Build completed unsuccessfully in 0:00:08
Could you please tell me what I am doing wrong? |
I think its best to ask in the issue but its also okay to ask in both places to try to get a response sooner. My only concern is that I don't want the discussion to get lost because it's split across platforms. To answer your question though, I'm happy to help debug the issue. Can you go ahead and push your copy of your test so I can take a look at it? |
I will do so next time. d71a4ab16496db4c4c8e3093299e261be8ac0ec9 |
This comment has been minimized.
This comment has been minimized.
awesome ty, taking a look right now. |
Looks like you were just missing some header commands1 to tell the testsuite to check the output of the test. I went ahead and pushed the fix since I'd already done it locally when testing. Once that passes CI I'll go ahead and approve the PR. Thank you for the help! ^_^ Footnotes |
@bors r+ |
📌 Commit 9aaf9f172a28ccf479e9fbe36a45a1360d44f882 has been approved by |
9aaf9f1
to
bca67fe
Compare
Squashed commits down into one. I suspect the header commands may not be enough if the RUST_BACKTRACE env is set, though -- that will fail the llvm-12 builder in CI if so. @bors r=yaahc rollup=iffy |
📌 Commit bca67fe has been approved by |
…aahc Add #[track_caller] to track callers when initializing poisoned Once This PR is for this Issue. rust-lang#87707 With this fix, we expect to be able to track the caller when poisoned Once is initialized.
Thanks for the review & the help! |
This PR is for this Issue.
#87707
With this fix, we expect to be able to track the caller when poisoned Once is initialized.