Rust 1.78: Performance Impact of the 128-Bit Memory Alignment Fix
codspeed.io
codspeed.io
Obviously something must have obscured it until now. Anyone knows why?
Edit: So it was an LLVM issue. Even weirder. https://reviews.llvm.org/D86310
Edit2: Ok, it's obvious: if you "fix" something like this you can break a lot of code that relies on specific struct alignment. Ouch.
https://blog.rust-lang.org/2024/03/30/i128-layout-update.htm...
Note also that this involves LLVM, so clang < 18 had the same u128 behavior as Rust < 1.77/1.78.
> Clang uses the correct alignment only because of a workaround, where the alignment is manually set to 16 bytes before handing the type to LLVM.
Maybe it took long to notice because it was assumed to be working in LLVM since clang worked?
#[derive(TypeLayout, Copy, Clone)]
#[repr(C)]
struct EnforcedAlignment {
_offset: [u8; GAP - 8],
data: AlignedU128,
}
pub fn main() {
println!("{}", StockAlignment::type_layout());
}
Excellent blogpost showing their product, by the way!