-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeId should be (u64, u64) instead of u128 to save space #115620
Comments
Note that |
I might be wrong here, but let x = 1u128;
{
let y = x;
println!("{}", y);
}
println!("{}", x); seems to work, so I believe |
@Cactus-man |
If that's the case, how about |
That would make hashing and probably equality slower. |
on 32 bit system would not be slower |
Rollup merge of rust-lang#121358 - GnomedDev:lower-align-typeid, r=Mark-Simulacrum Reduce alignment of TypeId to u64 alignment Closes rust-lang#115620
On Apple Silicon (unlike x86_64)
u128
is 16-bytes aligned. So it takes extra space with little or no benefit. I looked at generated code, it is the same:https://rust.godbolt.org/z/3sE7sMsjj
(Note just using
repr(packed(8))
won't work because it will passTypeId
by reference not by value)Additionally the issue with current
TypeId
is that is has different alignment on different platforms. Rust does not provide guarantees about the alignment, but if this was the same everywhere, it'd make life easier. (Practically we encountered this issue when our CI worked fine on Apple x86_64 macs, but the program didn't work on Apple Silicon.)rustc 1.74.0-nightly (a991861 2023-09-05)
macOS, Apple Silicon
The text was updated successfully, but these errors were encountered: