Skip to content

Conversation

@tidely
Copy link

@tidely tidely commented Oct 29, 2025

Calls to std::thread::current() are extremely cheap and already use caching internally. Thread::id() accesses a struct field. This makes it unnecessary to wrap inside of a std::thread_local!.

@Berrysoft
Copy link

It's not cheap. See: rust-lang/libs-team#650

@tidely
Copy link
Author

tidely commented Nov 28, 2025

Ah, there does seem to be an unnecessary Arc clone there. Good catch, thanks. Maybe worth reopening when current_id() stabilizes.

@tidely tidely closed this Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants