-
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
Optimize LazyCell
size
#109483
Optimize LazyCell
size
#109483
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
|
||
/// # Safety | ||
/// May only be called when the state is `Uninit`. | ||
#[cold] |
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 am not entirely sure if a #[cold]
marker is correct here. This function is virtually guaranteed to be called (just... once).
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.
Since OnceCell
marks the closure as #[cold]
, I didn't want to change it just yet. But you are probably right that it is unnecessary here.
r=me with some added comments. |
@Mark-Simulacrum I added the comments, hopefully it is clearer now. There is also a (micro-) optimization in |
This comment has been minimized.
This comment has been minimized.
4f7042c
to
c6e4be8
Compare
091d761
to
aa15467
Compare
☔ The latest upstream changes (presumably #105587) made this pull request unmergeable. Please resolve the merge conflicts. |
aa15467
to
af080bf
Compare
Rebased to include the new feature name ( |
@bors r=Mark-Simulacrum |
☀️ Test successful - checks-actions |
1 similar comment
☀️ Test successful - checks-actions |
Finished benchmarking commit (0599b6b): 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)ResultsThis 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. |
LazyCell
can only store either the initializing function or the data it produces, so it does not need to reserve the space for both. Similar to #107329, but uses anenum
instead of aunion
.