-
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: re-enable Fast API for Buffer.write #54526
Conversation
a930ad4
to
0fda693
Compare
23f1b23
to
8be5c43
Compare
test/parallel/test-buffer-write.js
Outdated
{ | ||
let i = 0; | ||
|
||
while (i < 1_000_000) { |
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.
Having a non-deterministic test is unpleasant.
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.
You can trigger fast api call using the method @targos implemented in his previous pull requests.
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.
This looks to me. I wish we could use a deterministic test. Having to loop a million times to trigger and issue is both slow and error prone.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #54526 +/- ##
==========================================
- Coverage 87.61% 87.60% -0.01%
==========================================
Files 650 650
Lines 182835 182889 +54
Branches 35382 35389 +7
==========================================
+ Hits 160185 160227 +42
- Misses 15925 15927 +2
- Partials 6725 6735 +10
|
This comment was marked as outdated.
This comment was marked as outdated.
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.
Some lint issues but otherwise LGTM
This comment was marked as outdated.
This comment was marked as outdated.
With the current commits, the following test will fail: let i = 0;
const testStr = "\xc2\x80"; // when stored in 1-byte chars, this is a valid UTF-8 encoding
const expected = Buffer.from(testStr).toString("hex");
for(; i < 1_000_000; i++) {
const buf = Buffer.from(testStr);
const ashex = buf.toString("hex");
if (ashex !== expected) {
console.log(`Decoding changed in iteration ${i} when changing to FastWriteStringUTF8, got ${ashex}, expected ${expected}`);
break;
}
}
if(i<1_000_000) {
console.error("FAILED after %d iterations",i);
} else
console.log("PASSED after %d iterations",i); The source string is stored as UTF16 (compressed to 1 byte), but still needs to be converted to UTF-8. The fast path can only be implemented as memcpy when only characters from the range 0-127 are present. |
I thought |
< when only characters from the range 0-127 are present @lemira does simdutf have this? |
Given the repeated activity since the failed commit, I assume it is known that the commit-queue originally failed, so I removed the label. Feel free to re-add. |
164f7f2
to
34edef6
Compare
Correct me if I'm wrong, but shouldn't the "PR-URL" meta be added by the bot? |
You're right. @ronag please remove the PR-URL from the commit. |
Re-enables fast Fast API for Buffer.write after fixing UTF8 handling. Fixes: nodejs#54521
* feat: convert_latin1_to_utf8_s Adds a "safe" version of convert_latin1_to_utf8 with a maximum output length. Refs: nodejs/node#54526 * various fixes * [no-ci] just some code reformatting --------- Co-authored-by: Robert Nagy <ronagy@icloud.com>
Landed in dc74f17 |
Re-enables fast Fast API for Buffer.write after fixing UTF8 handling. Fixes: #54521 PR-URL: #54526 Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Re-enables fast Fast API for Buffer.write after fixing UTF8 handling. Fixes: nodejs#54521 PR-URL: nodejs#54526 Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Re-enables fast Fast API for Buffer.write after fixing UTF8 handling.