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
Micro-optimize push() and insert(). #315
Conversation
r? @mbrubeck |
This helps with some micro-benchmarks in Firefox where we end up pushing thousands of elements to a SmallVec. See https://treeherder.mozilla.org/perfherder/comparesubtest?originalProject=try&newProject=try&newRevision=78b672e152c65fbacd3f0bccc4bd069b177addd6&originalSignature=4765498&newSignature=4765498&framework=1&application=firefox&originalRevision=6f0164143af00325c9f15e7c6387d8f9c7993daf&page=1&showOnlyConfident=1
ca52f03
to
6b4e119
Compare
Fixed MSRV, I think. |
https://bugzilla.mozilla.org/show_bug.cgi?id=1853969 is the regression this addresses. |
// so that the optimizer removes duplicated calls to it | ||
// from callers like insert() | ||
// prefer triple_mut() even if triple() would work so that the optimizer removes duplicated | ||
// calls to it from callers. |
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.
So then, does this comment make sense anymore?
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.
Potentially? In code like:
vec.try_reserve(1)?;
vec.push(...);
It might still be useful / let the compiler optimize more.
Merged to the |
This helps with some micro-benchmarks in Firefox where we end up pushing thousands of elements to a SmallVec.
See https://treeherder.mozilla.org/perfherder/comparesubtest?originalProject=try&newProject=try&newRevision=78b672e152c65fbacd3f0bccc4bd069b177addd6&originalSignature=4765498&newSignature=4765498&framework=1&application=firefox&originalRevision=6f0164143af00325c9f15e7c6387d8f9c7993daf&page=1&showOnlyConfident=1