perf: optimize PartialEq implementation#54
Closed
klkvr wants to merge 1 commit into
Closed
Conversation
DaniPopes
approved these changes
Feb 10, 2026
Merging this PR will improve performance by 29.41%
Performance Changes
Comparing Footnotes
|
Member
|
@klkvr can you show asm diff |
Member
Author
|
@DaniPopes amp got me this --- a/a.s
+++ b/b.s
@@ -4,13 +4,32 @@
.type nibbles_eq,@function
nibbles_eq:
.cfi_startproc
- vmovdqu (%rdi), %ymm0
- vmovq 32(%rdi), %xmm1
- vmovq 32(%rsi), %xmm2
- vpxor %ymm2, %ymm1, %ymm1
- vpxor (%rsi), %ymm0, %ymm0
- vpor %ymm1, %ymm0, %ymm0
- vptest %ymm0, %ymm0
- sete %al
- vzeroupper
+ mov rcx, qword ptr [rdi]
+ cmp rcx, qword ptr [rsi]
+ jne .LBB0_4
+ mov rax, qword ptr [rdi + 32]
+ cmp rax, qword ptr [rsi + 32]
+ jne .LBB0_4
+ mov al, 1
+ cmp rcx, 17
+ jae .LBB0_6
+.LBB0_3:
ret
+.LBB0_6:
+ mov rdx, qword ptr [rdi + 24]
+ cmp rdx, qword ptr [rsi + 24]
+ jne .LBB0_4
+ cmp rcx, 33
+ jb .LBB0_3
+ mov rdx, qword ptr [rdi + 16]
+ cmp rdx, qword ptr [rsi + 16]
+ jne .LBB0_4
+ cmp rcx, 49
+ jb .LBB0_3
+ mov rax, qword ptr [rdi + 8]
+ cmp rax, qword ptr [rsi + 8]
+ sete al
+ ret
+.LBB0_4:
+ xor eax, eax
+ ret |
Member
|
currently it's branchless and doesn't matter how long the value is. with this change it's probably slightly faster for when the workload is only small values, even then i doubt it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Due to most significant limbs being filled first comparison is suboptimal right now for smaller values