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

Update #[inline] documentation #84

Closed
ppershing opened this issue Jun 11, 2024 · 3 comments
Closed

Update #[inline] documentation #84

ppershing opened this issue Jun 11, 2024 · 3 comments

Comments

@ppershing
Copy link

As of rust-lang/rust#116505 the cross-crate inlining can happen even without explicit #[inline] attribute in simple-enough cases. I suggest we update the wording in the inline section to account for this

@nnethercote
Copy link
Owner

Here is the existing description:

  • None. The compiler will decide itself if the function should be inlined. This will depend on factors such as the optimization level and the size of the function. Non-generic functions will never be inlined across crate boundaries unless link-time optimization is used; generic functions might be.
  • #[inline]. This suggests that the function should be inlined, including across crate boundaries.
  • #[inline(always)]. This strongly suggests that the function should be inlined, including across crate boundaries.
  • #[inline(never)]. This strongly suggests that the function should not be inlined.

Here is a draft rewrite:

  • None. The compiler will decide itself if the function should be inlined. This will depend on factors such as the optimization level, the size of the function, whether the function is generic, and if the inlining is across a crate boundary.
  • #[inline]. This suggests that the function should be inlined.
  • #[inline(always)]. This strongly suggests that the function should be inlined.
  • #[inline(never)]. This strongly suggests that the function should not be inlined.

What do you think?

@ppershing
Copy link
Author

Your suggestion is certainly fine. Even better - but I am not sure how much details perf-book wants to maintain - would be to clarify pre/post rust 1.75 state (especially given that this is a recent change and some fols might still be on older versions of rust).

@nnethercote
Copy link
Owner

I chose to slightly reduce the level of detail so that it's correct for both pre- and post-1.75. Thanks again.

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

2 participants