lobsters score: 2 · tags: rust
For what it’s worth this 2023 PR is the one that added
#[inline]toDebugbecause it generally resulted in better (!) benchmark numbers. Interestingly, there was an experimental PR that only emitted the attribute on structs with <=5 fields and it resulted in a performance regression compared to always emitting the attribute.
score 1 · canonical
I suspect part of the reason is that many debug impls never get called, and by adding
#[inline]we avoid ever codegen’ing them.
score 1 · canonical
I’d expect
#[inline]onOrdandEq, maybeClone, but having it onDebugis surprising. I put#[cold]on myfn fmtimplementations!
score 2 · canonical
This seems worth a bugreport in the rust-lang/rust repo. We’ve changed the
#[inline]onDebugin the past and we can change it again. It’s just hard to pick a good trade-off between code size, compile time, and run time.
score 1 · canonical
It’s just hard to pick a good trade-off between code size, compile time, and run time.
I wonder what a stable (or semi stable) interface for a higher level hint could be. I’m thinking metadata in Cargo.toml. One thought could be an ability to cap the final binary size and have the compiler try to deopt if that’s hit (for example). But that might be too exact. Too brittle.
Thankfully this specific thing could also be pushed to a crate. So we could have a cold::Debug and a inline::Debug etc. or have it configurable with a container attribute.
score 2 · canonical
Yeah, I’ll definitely raise it this week. Thanks!
(I didn’t raise it originally because, having done other compiler work, I’m very sympathetic to the notion that there’s no perfect default or heuristic Rust can pick here :-))
score 1 · canonical
(I didn’t raise it originally because, having done other compiler work, I’m very sympathetic to the notion that there’s no perfect default or heuristic Rust can pick here :-))
Very true. A single report of “the heuristics are bad here” may not be very actionable. But it’s still valuable to have a place to collect them; if we get multiple such reports that may indicate a need to rebalance things a little.
score 1 · canonical
