-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Inline len and is_empty in collections #56403
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
I believe historically this has not been necessary, because generic methods were effectively automatically inline. However, this seems to no longer be entirely true nowadays, e.g. they made a large difference in #54668. It would be great if someone could clarify what exactly the impact of |
cc @anp |
It used to be the case that generic functions/methods would be However, nowadays, it is common to see cases where the instantiation in the dependency is called instead (and thus is not inlineable, unless LTO is enabled). |
@ljedrz with that in mind, are you seeing improvements in codegen with this patch? |
@nagisa I'd be happy to check if you could suggest how I could do it or point me to some past PR that relied on it so I can follow its instructions. |
I simply had a test case that used said functions and looked at |
Ah, ok; I can do that but it will take some time until I can do some test builds; if the queue is clear, a perf run might be faster (and we would probably want one afterwards). |
Ok, so I did some comparisons on a small test case and it appears that there is no difference in codegen; I'm pretty sure my test code does not get optimized away:
I compiled with Nevertheless, the inlined |
@bors try Lets run that perf run |
Inline len and is_empty in collections Is there any reason not to? All of these are trivial and heavily utilized.
☀️ Test successful - status-travis |
@rust-timer build bfa68b9 |
Success: Queued bfa68b9 with parent d311571, comparison URL. |
Finished benchmarking try commit bfa68b9 |
The results look pretty neutral; maaaybe fractional improvements for some cases, but it might just be noise. |
There is a bit of red on max-rss and faults, especially for deep-vector. |
@memoryruins: these are within usual noise range; those benchmarks have high variance; that being said, I'm ok with closing the PR due to (most probably) no change. |
I'm going to close this as there's no impact performance wise. |
Is there any reason not to? All of these are trivial and heavily utilized.