-
Couldn't load subscription status.
- Fork 78
Optimize ord implementation and signed zero canonicalization #144
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
Conversation
|
For example, example::old_leq:
vucomiss xmm1, xmm0
jae .LBB0_1
mov al, 1
vucomiss xmm0, xmm1
jae .LBB0_5
mov al, -1
vucomiss xmm0, xmm0
jp .LBB0_4
.LBB0_5:
inc al
cmp al, 2
setb al
ret
.LBB0_1:
xor eax, eax
vucomiss xmm0, xmm1
sbb eax, eax
inc al
cmp al, 2
setb al
ret
.LBB0_4:
vucomiss xmm1, xmm1
setnp al
inc al
cmp al, 2
setb al
retto this: example::new_leq:
vcmpleps xmm0, xmm0, xmm1
vxorps xmm2, xmm2, xmm2
vcmpunordps xmm1, xmm1, xmm2
vorps xmm0, xmm1, xmm0
vmovd eax, xmm0
and al, 1
ret |
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.
Thank you!
|
@mbrubeck To also give some concrete numbers, on my Apple M1 machine sorting a shuffled Vec of 1 million |
[](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [ordered-float](https://togithub.com/reem/rust-ordered-float) | workspace.dependencies | patch | `2.10.0` -> `2.10.1` | --- ### Release Notes <details> <summary>reem/rust-ordered-float (ordered-float)</summary> ### [`v2.10.1`](https://togithub.com/reem/rust-ordered-float/releases/tag/v2.10.1) [Compare Source](https://togithub.com/reem/rust-ordered-float/compare/v2.10.0...v2.10.1) #### What's Changed - Refactor Hash implementation by [@​jogru0](https://togithub.com/jogru0) in [https://github.com/reem/rust-ordered-float/pull/129](https://togithub.com/reem/rust-ordered-float/pull/129) - Optimize Ord implementation by [@​orlp](https://togithub.com/orlp) in [https://github.com/reem/rust-ordered-float/pull/144](https://togithub.com/reem/rust-ordered-float/pull/144) **Full Changelog**: reem/rust-ordered-float@v2.10.0...v2.10.1 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 3pm on Wednesday" in timezone America/New_York, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- Release Notes: - N/A <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4yMC4xIiwidXBkYXRlZEluVmVyIjoiMzguMjAuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
These micro-optimizations significantly reduce the number of instructions comparisons take, and often makes them branchless as well. Similarly we use a trick to canonicalize signed zero to positive zero in a single instruction without branches for faster hashing.