Skip to content
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

Add #[inline] attribute to all fns which return SmallVec #206

Merged
merged 1 commit into from Apr 5, 2020
Merged

Add #[inline] attribute to all fns which return SmallVec #206

merged 1 commit into from Apr 5, 2020

Conversation

hiddenhare
Copy link
Contributor

@hiddenhare hiddenhare commented Apr 4, 2020

When rustc fails to inline a SmallVec constructor, it can carry a significant performance cost: for example, if SmallVec::<[i64; 128]>::from_iter(...) fails to inline, it will perform an unnecessary 1kb memcpy.

I've recently been bitten by this when using SmallVec in a context where rustc seemed to be reluctant to perform inlining (a large fn with nested closures). Switching from SmallVec::from_iter to SmallVec::new and push, with a buffer size of 256 bytes, saved over 20ns per call. For larger buffers, from_iter carried a proportionally higher cost, even when the actual capacity in use didn't change.

@mbrubeck
Copy link
Contributor

mbrubeck commented Apr 5, 2020

@bors-servo r+

Thank you!

@bors-servo
Copy link
Contributor

bors-servo commented Apr 5, 2020

📌 Commit f5f6d89 has been approved by mbrubeck

@bors-servo
Copy link
Contributor

bors-servo commented Apr 5, 2020

Testing commit f5f6d89 with merge faca460...

@bors-servo
Copy link
Contributor

bors-servo commented Apr 5, 2020

☀️ Test successful - checks-travis
Approved by: mbrubeck
Pushing faca460 to master...

@bors-servo bors-servo merged commit faca460 into servo:master Apr 5, 2020
2 checks passed
mbrubeck added a commit to mbrubeck/rust-smallvec that referenced this issue Apr 6, 2020
* Add a new unstable `const_generics` feature (servo#204).
* Improve inlining of constructor functions (servo#206).
* Add a `slice.to_smallvec()` convenience method (servo#203).
* Documentation and testing improvements.
@mbrubeck mbrubeck mentioned this pull request Apr 6, 2020
bors-servo added a commit that referenced this issue Apr 8, 2020
Version 1.3.0

* Add a new unstable `const_generics` feature (#204).
* Improve inlining of constructor functions (#206).
* Add a `slice.to_smallvec()` convenience method (#203).
* Documentation and testing improvements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants