JelteF/derive_more

Use #[inline] attribute on Debug

JelteF opened this issue · 4 comments

JelteF commented

I noticed this rustc improvement in the "this week in rust" newsletter: rust-lang/rust#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 commented

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

Kobzol commented

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).

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.

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).