buffer: re-enable Fast API for Buffer.write #54526
buffer: re-enable Fast API for Buffer.write #54526nodejs-github-bot merged 1 commit intonodejs:mainfrom
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.
Having a non-deterministic test is unpleasant.
There was a problem hiding this comment.
You can trigger fast api call using the method @targos implemented in his previous pull requests.
lemire
left a comment
There was a problem hiding this comment.
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.
jasnell
left a comment
There was a problem hiding this comment.
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? |
Commit Queue failed- Loading data for nodejs/node/pull/54526 ✔ Done loading data for nodejs/node/pull/54526 ----------------------------------- PR info ------------------------------------ Title buffer: validate UTF8 on fast path (#54526) Author Robert Nagy <[email protected]> (@ronag) Branch ronag:fast-utf8-2 -> nodejs:main Labels buffer, c++, author ready, needs-ci Commits 1 - buffer: validate UTF8 on fast path Committers 1 - Robert Nagy <[email protected]> PR-URL: https://github.com/nodejs/node/pull/54526 Fixes: https://github.com/nodejs/node/issues/54521 Reviewed-By: Daniel Lemire <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/54526 Fixes: https://github.com/nodejs/node/issues/54521 Reviewed-By: Daniel Lemire <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> -------------------------------------------------------------------------------- ℹ This PR was created on Fri, 23 Aug 2024 14:34:31 GMT ✔ Approvals: 6 ✔ - Daniel Lemire (@lemire): https://github.com/nodejs/node/pull/54526#pullrequestreview-2257470621 ✔ - Benjamin Gruenbaum (@benjamingr) (TSC): https://github.com/nodejs/node/pull/54526#pullrequestreview-2273156047 ✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/54526#pullrequestreview-2258976699 ✔ - Anna Henningsen (@addaleax): https://github.com/nodejs/node/pull/54526#pullrequestreview-2258958504 ✔ - Yagiz Nizipli (@anonrig) (TSC): https://github.com/nodejs/node/pull/54526#pullrequestreview-2272343097 ✔ - Paolo Insogna (@ShogunPanda) (TSC): https://github.com/nodejs/node/pull/54526#pullrequestreview-2260113366 ✘ Last GitHub CI failed ℹ Last Full PR CI on 2024-08-30T13:34:03Z: https://ci.nodejs.org/job/node-test-pull-request/61707/ ℹ Last Benchmark CI on 2024-08-30T10:28:48Z: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1626/ - Querying data for job/node-test-pull-request/61707/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/10637813307 |
|
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. |
|
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
|
Landed in dc74f17 |
Re-enables fast Fast API for Buffer.write after fixing UTF8 handling.