-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
buffer: optimize byteLength for short strings #54345
Conversation
55227cf
to
6506c2a
Compare
@lemire couldn't utf8_length_from_latin1 do this? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #54345 +/- ##
==========================================
- Coverage 87.09% 87.09% -0.01%
==========================================
Files 647 648 +1
Lines 181816 182234 +418
Branches 34884 34964 +80
==========================================
+ Hits 158360 158717 +357
- Misses 16764 16791 +27
- Partials 6692 6726 +34
|
Fair question. Please see simdutf/simdutf#499 |
Long term, it could pay to make simdutf faster in these cases, because we have the runtime dispatching in place. But this PR, as is, should be fine. |
6506c2a
to
a608ae1
Compare
a608ae1
to
110e88b
Compare
110e88b
to
b97e1f1
Compare
b97e1f1
to
0fedfdb
Compare
0fedfdb
to
1d66f25
Compare
1d66f25
to
6e3ab46
Compare
a9325a3
to
dc6d0a4
Compare
for (; i + 32 <= length; i += 32) { | ||
uint64_t v; | ||
memcpy(&v, input + i, 8); | ||
answer += pop(v); | ||
memcpy(&v, input + i + 8, 8); | ||
answer += pop(v); | ||
memcpy(&v, input + i + 16, 8); | ||
answer += pop(v); | ||
memcpy(&v, input + i + 24, 8); | ||
answer += pop(v); | ||
} |
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.
Is this really improving the performance? I am surprised that unrolling the loop is beneficial compared to just the lines right afterwards. I would expect the compiler to optimize things like that.
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.
I just took from simdutf @lemire wdyt?
dc6d0a4
to
e204e9e
Compare
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.
lgtm
Landed in 75d25bc |
PR-URL: #54345 Reviewed-By: Daniel Lemire <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
PR-URL: #54345 Reviewed-By: Daniel Lemire <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
M2