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

RFC: inlining #897

Closed
jamesray1 opened this issue Jan 29, 2019 · 4 comments
Closed

RFC: inlining #897

jamesray1 opened this issue Jan 29, 2019 · 4 comments

Comments

@jamesray1
Copy link
Contributor

jamesray1 commented Jan 29, 2019

This library has lots of inline attributes on functions. It seems like the pattern is that they are added when a function is only a few lines. However, from https://internals.rust-lang.org/t/when-should-i-use-inline/598/8 it seems like it is better to not use it in a library, let the compiler decide, and let library users use link-time optimisation if they want to have a super-fast binary. Any thoughts?

@tomaka
Copy link
Member

tomaka commented Feb 6, 2019

I didn't comment on this earlier because the answer is that I don't know.

As far as I know, putting #[inline] makes it possible to inline function calls across crates by embedding the source code of the inlined function within the .rlib.

The counter-argument is that link-time optimisation does the same anyway, except at a different step of the compilation, and that therefore we don't need to inline across crates.

@jamesray1
Copy link
Contributor Author

Closing as it seems we agree that inlining isn't needed.

@tomaka
Copy link
Member

tomaka commented Feb 6, 2019

Well, I don't know if what I said it's true.
The only real answer would be to experiment with/without #[inline] and see the consequence on the bytecode.

@jamesray1 jamesray1 reopened this Feb 7, 2019
@romanb
Copy link
Contributor

romanb commented Oct 6, 2020

I think we do have a rough consensus by now that explicit #[inline] should be the exception in cases where benchmarking confirmed a bottleneck or hot code path that should be optimised through inlining across crates even in cases without link-time optimisation.

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

No branches or pull requests

3 participants