Skip to content
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

Optimize transmute #31

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Optimize transmute #31

wants to merge 1 commit into from

Conversation

turalcar
Copy link

Don't use boxes: Not only this avoids allocation but also makes no_std implementation possible.
I didn't bother to rewrite the comment (it's not like I entirely understand how it works anyway). but there are 2 main issues to consider:

  1. Alignment: union Blank has both the max size and max alignment of its arguments
  2. Niches: for some implementation-defined reason this combination of Options and Result works. We likely use the fact that union have no niches.

Together with removing black_box and inline(never) this achieves performance identical with std on my ARMv8.

Don't use boxes: Not only this avoids allocation but also makes no_std
implementation possible.
I didn't bother to rewrite the comment (it's not like I entirely
understand how it works anyway). but there are 2 main issues to
consider:
1) Alignment: union Blank has both the max size and max alignment of its
   arguments
2) Niches: for some implementation-defined reason this combination of
   Options and Result works. We likely use the fact that union have no
   niches.

Together with removing black_box and inline(never) this achieves
performance identical with std on my ARMv8.
Copy link

@CyanChanges CyanChanges left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants