src: use simdutf for two-byte string utf8 conversion in utf8 value#62248
Open
mertcanaltin wants to merge 1 commit intonodejs:mainfrom
Open
src: use simdutf for two-byte string utf8 conversion in utf8 value#62248mertcanaltin wants to merge 1 commit intonodejs:mainfrom
mertcanaltin wants to merge 1 commit intonodejs:mainfrom
Conversation
Collaborator
|
Review requested:
|
f6d6f82 to
d459594
Compare
Codecov Reportβ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #62248 +/- ##
=======================================
Coverage 89.67% 89.68%
=======================================
Files 676 676
Lines 206469 206507 +38
Branches 39537 39538 +1
=======================================
+ Hits 185157 185199 +42
+ Misses 13448 13447 -1
+ Partials 7864 7861 -3
π New features to boost your workflow:
|
lemire
reviewed
Mar 14, 2026
src/util.cc
Outdated
| size_t length = string->WriteUtf8V2( | ||
| isolate, target->out(), storage, String::WriteFlags::kReplaceInvalidUtf8); | ||
| target->SetLengthAndZeroTerminate(length); | ||
| size_t actual_length = simdutf::convert_utf16le_to_utf8( |
Member
There was a problem hiding this comment.
Possibly, this could be utf16_to_utf8? I would test this on a big endian system to be sure.
Member
Author
There was a problem hiding this comment.
thanks for review, I changed to convert_utf16_to_utf8 which uses platform-native endianness, and updated bench result
b8cc5e8 to
dcbf493
Compare
dcbf493 to
fb16b2d
Compare
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.
latin-1 already used simdutf #61696,
I changed WriteUtf8V2 to simdutf for two-byte strings.
β node git:(mert/use-simdutf-for-two-byte-utf8) β node-benchmark-compare ./result.csv confidence improvement accuracy (*) (**) (***) util/utf8-value.js n=5000000 type='ascii' -0.11 % Β±2.64% Β±3.69% Β±5.18% util/utf8-value.js n=5000000 type='mixed' *** 49.60 % Β±1.90% Β±2.67% Β±3.78% util/utf8-value.js n=5000000 type='three_bytes' *** 31.10 % Β±2.42% Β±3.34% Β±4.60% util/utf8-value.js n=5000000 type='two_bytes' *** 42.75 % Β±1.42% Β±1.94% Β±2.66% Be aware that when doing many comparisons the risk of a false-positive result increases. In this case, there are 4 comparisons, you can thus expect the following amount of false-positive results: 0.20 false positives, when considering a 5% risk acceptance (*, **, ***), 0.04 false positives, when considering a 1% risk acceptance (**, ***), 0.00 false positives, when considering a 0.1% risk acceptance (***)