← Back to context

Comment by JonChesterfield

2 years ago

Did you want alignment sorting? In general the problem with things like that is the ideal layout is usually architecture and application specific - if my struct has padding in it to push elements onto different cache lines, I don't want the struct reordered.

> Did you want alignment sorting?

Yep. It will probably improve (to be measured) the 80%. Less memory means less bandwidth usage etc.

> if my struct has padding in it to push elements onto different cache lines, I don't want the struct reordered.

I did suggest having a repr for situations like yours. Something like #[repr(yeet)]. Optimizing for false sharing etc. is probably well within 5% of code that exists today, and is usually wrapped up in a library that presents a specific data structure.