Skip to content

Conversation

joboet
Copy link
Member

@joboet joboet commented Oct 23, 2025

When accessing a TLS variable, the comparison that checks whether the variable is initialised can be inlined to the call site. The comparison that checks whether the variable has been destroyed is however performed in the #[cold] accessor function. Since all call-sites need to check whether the returned pointer is null, this split prevents these two checks from being merged into one. Thus moving the liveliness check into the inlineable accessor may yield more optimal codegen. This is especially true in the case where the variable does not need destruction and thus no null pointer will ever be returned, as the null-pointer check can now be optimised out.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 23, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 23, 2025

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@joboet
Copy link
Member Author

joboet commented Oct 23, 2025

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Oct 23, 2025
std: move check for destroyed TLS variable
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 23, 2025
@rust-log-analyzer
Copy link
Collaborator

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
finished building tool typos
error: `Uninitalized` should be `Uninitialized`
   ╭▸ library/std/src/sys/thread_local/native/lazy.rs:67:40
   │
67 │     /// * The state of `self` must be `Uninitalized`.
   ╰╴                                       ━━━━━━━━━━━━
rerun tidy with `--extra-checks=spellcheck --bless` to fix typos
tidy [extra_checks]: checks with external tool 'typos' failed
tidy [extra_checks]: FAIL
tidy: The following check failed: extra_checks
Command `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools-bin/rust-tidy /checkout /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo /checkout/obj/build 4 /node/bin/npm --extra-checks=py,cpp,js,spellcheck` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:1549:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:1280:29

Command has failed. Rerun with -v to see more details.
Bootstrap failed while executing `test src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck`
Build completed unsuccessfully in 0:02:33
  local time: Thu Oct 23 15:55:15 UTC 2025
  network time: Thu, 23 Oct 2025 15:55:15 GMT
##[error]Process completed with exit code 1.

@rust-bors
Copy link

rust-bors bot commented Oct 23, 2025

☀️ Try build successful (CI)
Build commit: db38fd3 (db38fd3601bd22cc534c47281f839697adae4273, parent: 11d2046fe9962720558cb15f72541f7fd170dec9)

@rust-timer
Copy link
Collaborator

Queued db38fd3 with parent 11d2046, future comparison URL.
There is currently 1 preceding artifact in the queue.
It will probably take at least ~2.0 hours until the benchmark run finishes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-perf Status: Waiting on a perf run to be completed. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants