Rust's derive often implies inline

(yossarian.net)

31 points | by woodruffw 3 days ago

1 comments

  • Sharlin 23 minutes ago
    I’m fairly convinced that Debug should never be inlined. Display probably neither, the fmt machinery is heavy enough that not inlining is probably not a bottleneck even in serialization-heavy workloads. I’ve had to #[inline(never)] some of my own Debug/Display impls, shrinking the binary by tens of kilobytes (out of a few hundred, so relatively a significant reduction).
    • aw1621107 0 minutes ago
      For what it's worth, according to the PR that added the annotation [0] did so because it generally resulted in decreases in compile times and binary sizes on benchmarks. Furthermore, an additional experiment that avoided emitting the inline attribute on structs with >5 fields resulted in benchmark regressions compared to always emitting the attribute [1].

      That being said, one of the Rust devs indicated in the corresponding lobste.rs discussion [2] that they're open to revisiting/rebalancing things if they get enough bug reports indicating something is up, so it might not hurt to tag onto the bug report the author will (hopefully) eventually submit.

      [0]: https://github.com/rust-lang/rust/pull/117727

      [1]: https://github.com/rust-lang/rust/pull/118031

      [2]: https://lobste.rs/s/dldhpw/rust_s_derive_often_implies_inlin...