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

std: Attempt again to inline thread-local-init across crates #84876

Merged

Conversation

alexcrichton
Copy link
Member

Issue #25088 has been part of thread_local! for quite some time now.
Historical attempts have been made to add #[inline] to __getit
in #43931, #50252, and #59720, but these attempts ended up not landing
at the time due to segfaults on Windows.

In the interim though with const-initialized thread locals AFAIK this
is the only remaining bug which is why you might want to use
#[thread_local] over thread_local!. As a result I figured it was
time to resubmit this and see how it fares on CI and if I can help
debugging any issues that crop up.

Closes #25088

@rust-highfive
Copy link
Collaborator

r? @dtolnay

(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 May 3, 2021
@Mark-Simulacrum
Copy link
Member

@bors r+ rollup=never -- it may make sense I guess regardless to cfg_attr these inlines to work on e.g. unix or platforms where they're "known good" even if this doesn't end up landing.

@bors
Copy link
Contributor

bors commented May 3, 2021

📌 Commit 75311b41b4e822ca715155861cb7afa8ecb6f618 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 May 3, 2021
@bors
Copy link
Contributor

bors commented May 3, 2021

⌛ Testing commit 75311b41b4e822ca715155861cb7afa8ecb6f618 with merge d83e8b8afad8a3c3b98038e5664add57726fc2ec...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented May 3, 2021

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 3, 2021
@alexcrichton
Copy link
Member Author

Hm ok that got suspiciously far compiling rustc in stage1. It's faulting on MSVC, though, like before. I would personally like to spend some time investigating this. I still feel the same that this shouldn't be landed with #[cfg_attr] only because no one's willing to investigate the Windows story.

@Mark-Simulacrum
Copy link
Member

Sounds good to me. It may be worth switching to cfg_attr and running a perf build, just so we can get some sense of how the performance improvement looks - if it ends up being a regression, for example, we might need some alternative approach.

@alexcrichton
Copy link
Member Author

Nah that's a good idea! I was surprised rereading the results of #59720 of how things regressed slightly. If that's still the case then I would imagine that, at least for the compiler itself, this would need to be coupled with #84833 to show better results.

In any case, mind kicking off the perf build?

@Mark-Simulacrum
Copy link
Member

@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 May 3, 2021
@bors
Copy link
Contributor

bors commented May 3, 2021

⌛ Trying commit f6afc646da3992bb7182b15b5d41d93ae1a1bd62 with merge 628cb1d71c8850f01c33ec3ec594fde62784a7e2...

@Mark-Simulacrum
Copy link
Member

Happy to run it with a cherry pick of the const init PR as well

@bors
Copy link
Contributor

bors commented May 4, 2021

☀️ Try build successful - checks-actions
Build commit: 628cb1d71c8850f01c33ec3ec594fde62784a7e2 (628cb1d71c8850f01c33ec3ec594fde62784a7e2)

@rust-timer
Copy link
Collaborator

Queued 628cb1d71c8850f01c33ec3ec594fde62784a7e2 with parent 716394d, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (628cb1d71c8850f01c33ec3ec594fde62784a7e2): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 4, 2021
@joshtriplett
Copy link
Member

Looks like a net win.

@alexcrichton
Copy link
Member Author

I'm making some progress investigating this crash on Windows. It'll take some more time. I have no idea how thread locals work on Windows so I'm throwing a lot of stuff at the wall right now.

@bors
Copy link
Contributor

bors commented May 18, 2021

⌛ Testing commit 0e3f77947de5a81d6e787dee2658721e69d63875 with merge 6dd6a850b05bb650bbcc0539a3551edae014a9a0...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented May 18, 2021

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 18, 2021
Issue rust-lang#25088 has been part of `thread_local!` for quite some time now.
Historical attempts have been made to add `#[inline]` to `__getit`
in rust-lang#43931, rust-lang#50252, and rust-lang#59720, but these attempts ended up not landing
at the time due to segfaults on Windows.

In the interim though with `const`-initialized thread locals AFAIK this
is the only remaining bug which is why you might want to use
`#[thread_local]` over `thread_local!`. As a result I figured it was
time to resubmit this and see how it fares on CI and if I can help
debugging any issues that crop up.

Closes rust-lang#25088
@alexcrichton alexcrichton force-pushed the inline-thread-locals-cross-crate branch from 0e3f779 to 641d3b0 Compare May 18, 2021 18:22
@alexcrichton
Copy link
Member Author

@bors: r=Mark-Simulacrum

@bors
Copy link
Contributor

bors commented May 18, 2021

📌 Commit 641d3b0 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 May 18, 2021
@bors
Copy link
Contributor

bors commented May 18, 2021

⌛ Testing commit 641d3b0 with merge 583eb5d0735d15042e52530947033ff8b39cf99d...

@bors
Copy link
Contributor

bors commented May 19, 2021

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 19, 2021
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@alexcrichton
Copy link
Member Author

@bors: retry

Hm looks like things were just cancelled, I couldn't find any actual failures, so gonna retry.

@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 May 19, 2021
@bors
Copy link
Contributor

bors commented May 19, 2021

⌛ Testing commit 641d3b0 with merge 3bcaeb0...

@bors
Copy link
Contributor

bors commented May 19, 2021

☀️ Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing 3bcaeb0 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 19, 2021
@bors bors merged commit 3bcaeb0 into rust-lang:master May 19, 2021
@rustbot rustbot added this to the 1.54.0 milestone May 19, 2021
@@ -0,0 +1,50 @@
// compile-flags: -O
// aux-build:thread_local_aux.rs
// ignore-windows FIXME(#84933)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have been ignore-msvc because now we enable it for windows-gnu without testing.

@alexcrichton alexcrichton deleted the inline-thread-locals-cross-crate branch May 20, 2021 19:42
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. O-windows Operating system: Windows 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.

Access to thread locals isn't inlined across crates