2 ms·
Rust does quite some optimization on layouts[0], it can do so since its internal ABI, including struct layouts, is unspecified and thus they can change it while
by the8472 8y ago
Rust does quite some optimization on layouts[0], it can do so since its internal ABI, including struct layouts, is unspecified and thus they can change it while still having C ABI for interop. They're also keeping the options open for PGO-based layouts.
Of course those are still compile-time decisions, so compressed pointers are out since they only work if you restrict yourself to ~32GB, depending on alignments.
[0] https://github.com/rust-lang/rust/pull/45225 https://github.com/rust-lang/rust/pull/45225
- saagarjha 8y agoSwift does layout optimization as well, since it similarly has not pinned down module stability.
- fulafel 8y agoCan you point out some layout optimizations that are done? I could not make out much of your link sadly.
- the8472 8y agoLook at the "Size optimizations implemented so far" section. It's mostly about packing enum discriminators into unused bits and bytes. Beyond that rust has always done field reordering to minimize wastage from alignment gaps. Other optimizations are still being planned.