Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Remove most #[inline] annotations #210

Merged
merged 1 commit into from
Jul 11, 2019

Conversation

alexcrichton
Copy link
Member

These annotations fall into a few categories

  • Some simply aren't needed since functions will always be in the same
    CGU anyway and are already candidates for inlining.
  • Many are on massive functions which shouldn't be inlined across crates
    due to code size concerns.
  • Others aren't necessary since calls to this crate are rarely inlined
    anyway (since it's lowered through LLVM).

If this crate is called directly and inlining is needed then LTO can
always be turned on, otherwise this will benefit downstream consumers by
avoiding re-codegen'ing so many functions.

These annotations fall into a few categories

* Some simply aren't needed since functions will always be in the same
  CGU anyway and are already candidates for inlining.
* Many are on massive functions which shouldn't be inlined across crates
  due to code size concerns.
* Others aren't necessary since calls to this crate are rarely inlined
  anyway (since it's lowered through LLVM).

If this crate is called directly and inlining is needed then LTO can
always be turned on, otherwise this will benefit downstream consumers by
avoiding re-codegen'ing so many functions.
@gnzlbg
Copy link
Contributor

gnzlbg commented Jul 10, 2019

LGTM. These are only compiled once in compiler-builtins, where the symbols for these are generated. I don't know how much does #[inline] affect the ability of LLVM to do LTO.

Fixing the current benchmarks to always use the same value (42.0 for all inputs), most benchmarks don't change that much. There are some that get much slower, and some that get a bit faster. See https://gist.github.com/gnzlbg/b282db61d37e305b7ca153d41f179f7c (new is this PR, old is master).

I'd rather add inline when it's needed, than everywhere, but the current benchmarks are kind of useless for that, so one should probably need to fix that first.


EDIT: the largest improvement is 2ns/iter, and the largest regression is 95ns/iter.

@gnzlbg
Copy link
Contributor

gnzlbg commented Jul 10, 2019

Thinking about this some more, I think I would prefer for the remaining no_panic checks to be added before landing this.

@alexcrichton
Copy link
Member Author

A regression of 95ns/iter isn't really what's happening though:

 sqrt       0            95                     95     inf%   x 0.00 
 sqrtf      0            26                     26     inf%   x 0.00 

that basically means it was constant-folded before so we weren't actually benchmarking anything.

I'm going to go ahead and merge this since the tests are green, and we can continue to add no_panic annotations, or abandon no_panic entirely if it's not really measuring the thing we want.

@alexcrichton alexcrichton merged commit 8a0a110 into rust-lang:master Jul 11, 2019
@alexcrichton alexcrichton deleted the less-inline branch July 11, 2019 14:29
tgross35 pushed a commit that referenced this pull request Apr 18, 2025
Remove most `#[inline]` annotations
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants