-
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
Simplify key-based thread locals #122494
Simplify key-based thread locals #122494
Conversation
3150859
to
5fd4a84
Compare
// If the variable was recursively initialized, drop the old value. | ||
// SAFETY: We cannot be inside a `LocalKey::with` scope, as the | ||
// initializer has already returned and the next scope only starts | ||
// after we return the pointer. Therefore, there can be no references | ||
// to the old value. | ||
drop(unsafe { Box::from_raw(old) }); |
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 think it'd be good to swap this around (such that it behaves like OnceCell) in a future PR. (That PR will need an FCP and perhaps a crater run though.)
This looks great. @bors r+ |
Simplify key-based thread locals This PR simplifies key-based thread-locals by: * unifying the macro expansion of `const` and non-`const` initializers * reducing the amount of code in the expansion * simply reallocating on recursive initialization instead of going through `LazyKeyInner` * replacing `catch_unwind` with the shared `abort_on_dtor_unwind` It does not change the initialization behaviour described in rust-lang#110897.
…llaumeGomez Rollup of 8 pull requests Successful merges: - rust-lang#122494 (Simplify key-based thread locals) - rust-lang#122644 (pattern analysis: add a custom test harness) - rust-lang#122723 (Use same file permissions for ar_archive_writer as the LLVM archive writer) - rust-lang#122729 (Relax SeqCst ordering in standard library.) - rust-lang#122740 (use more accurate terminology) - rust-lang#122764 (coverage: Remove incorrect assertions from counter allocation) - rust-lang#122765 (Add `usize::MAX` arg tests for Vec) - rust-lang#122776 (Rename `hir::Let` into `hir::LetExpr`) r? `@ghost` `@rustbot` modify labels: rollup
I think this is the PR which failed in #122778. |
@bors r- |
The failing UI tests only check internal perma-unstable implementations, so I think they are fine to remove. @rustbot ready |
☔ The latest upstream changes (presumably #123339) made this pull request unmergeable. Please resolve the merge conflicts. |
r? libs |
@bors r+ |
☔ The latest upstream changes (presumably #116123) made this pull request unmergeable. Please resolve the merge conflicts. |
Rebased to resolve the conflict with the native TLS rewrite. I've also added a second commit that makes the |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (9e297bf): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)Results (primary -2.2%, secondary -5.1%)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.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 673.59s -> 674.001s (0.06%) |
This PR simplifies key-based thread-locals by:
const
and non-const
initializersLazyKeyInner
catch_unwind
with the sharedabort_on_dtor_unwind
It does not change the initialization behaviour described in #110897.