-
Notifications
You must be signed in to change notification settings - Fork 36
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
feat: Improve performance of Exchange #104
Conversation
We sacrifice memory usage for performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool 🔥
Co-authored-by: Maciej Zwoliński <mac.zwolinski@gmail.com> Signed-off-by: Yiannis Marangos <psyberbits@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Miri has no issues with it but I'm concerned about the transmute.
In the MaybeUninit docs there is this example (3rd in section)
https://doc.rust-lang.org/std/mem/union.MaybeUninit.html#initialization-invariant
let x: i32 = unsafe { MaybeUninit::uninit().assume_init() }; // undefined behavior! ⚠️
so I think it would also do so for
let x: MaybeUninit<u8> = MaybeUninit::uninit();
let x: u8 = std::mem::transmute(x); // ub
also I found this MaybeUninit::slice_assume_init_mut
which happens to do the same thing and it says that calling is unsafe on uninitialized data
https://doc.rust-lang.org/src/core/mem/maybe_uninit.rs.html#976
Want to open a discussion what do we want to do with it. It seems it's safe by current compiler's behavior and used in some popular crates but causes UB per documentation.
I posted a question about this in the Rust forum (link) and the code is safe as long as I have checked all the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work! 🚀
We sacrifice memory usage for performance.