-
Notifications
You must be signed in to change notification settings - Fork 116
Make zerocopy optional #253
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
base: master
Are you sure you want to change the base?
Conversation
It is likely very few of the I also submitted PR #256 to show that some conversions can now be done without transmutes at all. |
@mitsuhiko Any chance you would be interested in submitting a PR or two that removes the unused code you noticed? |
I replaced PR #255 with PR #257. In conjunction with PR #256, this leaves:
I believe you could manually rewrite the uses of |
@@ -7,13 +20,13 @@ macro_rules! convert { | |||
impl Convert<$b> for $a { | |||
#[inline(always)] | |||
fn convert(self) -> $b { | |||
zerocopy::transmute!(self) | |||
unsafe { safer_transmute!(self) } |
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.
This still suffers from the fact that the unsafe
is hidden in a macro, and also there is no SAFETY comment. I think those were the two problems that the PR that added zerocopy was trying to address.
If it is important to use transmute
for performance or other reasons, then it would be better to just manually copy/paste the necessary implementations so that all the unsafe
are moved out of the macro.
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.
Agreed. This would need to be addressed. I just saw that you pushed PRs up that I think in general are a good thing to land if possible. So maybe that should take priority.
I general though I think all of this is stalled for the moment until a maintainer shows up. I'm not sure who has permissions to merge or approve things here.
If the transmutes can be avoided or tamed with no overhead I am all for that, but I don't want to add a feature flag for it. |
Some PRs that greatly reduce the number of uses of |
Feel free to disregard this. I was wondering if there is a way to make
zerocopy
optional. It's actually not all that hard, since most ofConvert
is actually not used. However you end up with a fair bit if not nice looking code which I think is inappropriate compared to what zerocopy achieves.However that got me thinking that it might be interesting to make zerocopy a CI only thing, or something a user can opt-into. Since all the transmutes are internal, it's shielded from the public API anyways. For as long as the code passes zerocopy checks, the transmutes are fine and zerocopy is not needed for distribution.
Reason for why I want to avoid zerocopy for now: zerocopy is work in progress and I currently end up with more than one zerocopy version in my dependency, in part because ahash has not moved up yet (#246). To avoid some extra churn I was thinking it might be interesting to see if it can be made optional.
Refs #180