derive_more icon indicating copy to clipboard operation
derive_more copied to clipboard

Use #[inline] attribute on all functions

Open JelteF opened this issue 2 years ago • 3 comments

I noticed this rustc improvement in the "this week in rust" newsletter: https://github.com/rust-lang/rust/pull/117727

Apparently it decreased compile times by ~5%. We should do the same in derive_more. Some derives already do this, but at least Debug doesn't afaict. Probably some others too.

JelteF avatar Nov 17 '23 02:11 JelteF

Added it to the 1.0.0 milestone since it's pretty much zero effort

JelteF avatar Nov 17 '23 02:11 JelteF

I'd just like to mention that we're still not sure why this specific improvement has improved compile times, as the interactions are quite complicated. Adding #[inline] to functions can increase compilation times (and in fact, it's the expected outcome), so it should not be applied without carefully measuring how it affects compilation time (and runtime performance).

Kobzol avatar Nov 17 '23 15:11 Kobzol

It's hard to imagine the attribute regressing runtime performance, but yes it can massively regress compile times. The original case study for that is hashbrown which used to put it everywhere and when the attribute was backed out I think they halved build times or something like that.

saethlin avatar Nov 18 '23 04:11 saethlin

Thanks for the input everyone. I won't add #[inline] to everything then, only to a few obviously useful cases (one of those being Debug since for those we have benchmarks of compile time).

JelteF avatar Jan 22 '24 21:01 JelteF