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

use #[inline(always)] instead of #[inline] #186

Open
donghun-furiosa opened this issue May 2, 2023 · 3 comments
Open

use #[inline(always)] instead of #[inline] #186

donghun-furiosa opened this issue May 2, 2023 · 3 comments

Comments

@donghun-furiosa
Copy link

there are multiple locations where #[inline] is used in bytemuck and i doubt performance benefit of using #[inline(always)] may not be meaningful in many cases but for some latency sensitive cases, using #[inline(always)] may come in handy.

I've ran benchmarks on my project for cast and cast_ref and had about 30% latency benefit when using #[inline(always)]. If needed, I'll reproduce the benchmark code!

@Lokathor
Copy link
Owner

Lokathor commented May 2, 2023

I would be interested in such benchmarks, and I'm sure others would as well.

For functions as small as the bytemuck ones, normal inline should be enough in an optimized build.

@donghun-furiosa
Copy link
Author

@Lokathor Sure, Sure! I'll clean up the benchmark code and add the link here.

In the meantime, when you mean "optimized build", are you also setting lto and codegen_units or does that simply mean setting "opt-level "?

@Lokathor
Copy link
Owner

Lokathor commented May 2, 2023

Without looking into it deeply i would have expected opt-level of 3 (the default for the Release profile) to be sufficient.

However I'm happy to have clear examples of cases where it doesn't happen. Primary because that can probably be shown to a rustc dev and they might be able to fix the compiler itself to help not only bytemuck but possibly similar examples of missed small inlines in other crates.

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