Hacker News new | past | comments | ask | show | jobs | submit login

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




Swift does layout optimization as well, since it similarly has not pinned down module stability.


Can you point out some layout optimizations that are done? I could not make out much of your link sadly.


Look 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.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: