Comment by fl0ki

2 years ago

> Also, why aren't we size-sorting fields already?

We are for struct/enum fields. https://camlorn.net/posts/April%202017/rust-struct-field-reo...

There's even an unstable flag to help catch incorrect assumptions about struct layout. https://github.com/rust-lang/compiler-team/issues/457

Oh wow, awesome! I was somewhat considering this being my first contribution - glad someone already tackled it!

  • If I can suggest, the next big breakthrough in this space would be generalizing niche filling optimization. Every thread about this seems to fizzle out, to the point that I couldn't even find which one is the latest any more.

    Today most data-carrying enums decay into the lowest common denominator of a 1-byte discriminant padded by 7 more bytes before any variant's data payload can begin. This really adds up when enums are nested, not just blowing out the calling register set but also making each data structure a swiss cheese of padding bytes.

    Even a few more improvements in that space would have enormous impact, compounding with other optimizations like better calling conventions.