-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Restructure std::rt #89011
Restructure std::rt #89011
Conversation
Previously the thread name would first be heap allocated and then re-allocated to add a nul terminator. Now it will be heap allocated only once with nul terminator added form the start.
The RefCell is now borrowed exactly once. In addition a code sequence that contains an unwrap that is guaranteed to never panic at runtime is replaced with get_or_insert_with, which makes the intended behavior clearer and will not emit code to panic even without optimizations.
This makes accesses to it cheaper
This replaces a couple of panic locations with hard aborts. The panics can't be catched by the user anyway in these locations.
This is a bit faster
r? @dtolnay (rust-highfive has picked a reviewer for you, use r? to override) |
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 5e7f641 with merge 15b3d2ed0e2de00152c24e976f78374d1c1beb14... |
This comment has been minimized.
This comment has been minimized.
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 37608c7 with merge e84914f65292e8404d89a72f04f1bb753f39a77f... |
☀️ Try build successful - checks-actions |
Queued e84914f65292e8404d89a72f04f1bb753f39a77f with parent 2b5ddf3, future comparison URL. |
Finished benchmarking commit (e84914f65292e8404d89a72f04f1bb753f39a77f): comparison url. Summary: This change led to moderate relevant improvements 🎉 in compiler performance.
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. @bors rollup=never |
Binary sizes for
When stripping binaries, but not doing LTO, this increases binary size by up to 72 bytes, but in all other cases this reduces binary size by up to 12kb without stripping or 4kb with stripping. |
Diff with |
I think in that case only the size of libstd.so would change and not the actual executable. |
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.
This PR is labelled T-libs-api but it's not immediately clear to me why. Is there an externally observable API tradeoff that we'll need to reach a consensus on? Otherwise this seems like T-libs's business.
(Haven't gotten a chance to review yet.)
I meant libs-impl, not libs-api. My bad. |
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.
Looks good. :) Thank you for nicely splitting the commits.
@bors r+ |
📌 Commit 37608c7 has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (1149193): comparison url. Summary: This benchmark run did not return any relevant changes. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
Restructure std::rt (part 2) A couple more cleanups on top of rust-lang#89011 Blocked on rust-lang#89011
These changes should reduce binary size slightly while at the same slightly improving performance of startup, thread spawning and
std::thread::current()
. I haven't verified if the compiler is able to optimize some of these cases already, but at least for some others the compiler is unable to do these optimizations as they slightly change behavior in cases where program startup would crash anyway by omitting a backtrace and panic location.I can remove 6f6bb16 if preferred.