-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
util: improve textencoder encodeInto performance #60843
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
Merged
nodejs-github-bot
merged 7 commits into
nodejs:main
from
anonrig:yagiz/improve-textencoder-encodeinto
Dec 1, 2025
Merged
util: improve textencoder encodeInto performance #60843
nodejs-github-bot
merged 7 commits into
nodejs:main
from
anonrig:yagiz/improve-textencoder-encodeinto
Dec 1, 2025
+201
−8
Conversation
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
518b877 to
d6ac366
Compare
jasnell
reviewed
Nov 24, 2025
d47585e to
699bf56
Compare
erikcorry
reviewed
Nov 24, 2025
495c148 to
52dc8a7
Compare
erikcorry
reviewed
Nov 24, 2025
028c409 to
6c5656f
Compare
Co-authored-by: Erik Corry <[email protected]> Co-authored-by: Daniel Lemire <[email protected]>
6c5656f to
f993411
Compare
9f9733a to
66bc586
Compare
Member
Author
|
@RafaelGSS please take a look |
RafaelGSS
approved these changes
Nov 26, 2025
Collaborator
jasnell
reviewed
Nov 26, 2025
jasnell
reviewed
Nov 26, 2025
jasnell
reviewed
Nov 26, 2025
|
|
||
| size_t read = 0; | ||
| size_t written = 0; | ||
| v8::String::ValueView view(isolate, source); |
Member
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.
Suggested change
| v8::String::ValueView view(isolate, source); | |
| // Note: Take care not to perform any action in v8 that would | |
| // trigger GC as it could cause the view to become invalid. | |
| v8::String::ValueView view(isolate, source); |
jasnell
reviewed
Nov 26, 2025
| simdutf::result result = | ||
| simdutf::validate_ascii_with_errors(data, length_that_fits); | ||
| written = read = result.count; | ||
| memcpy(write_result, data, read); |
Member
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.
A DCHECK for bounds checking would be nice here.
jasnell
reviewed
Nov 26, 2025
jasnell
reviewed
Nov 26, 2025
bdd8c13 to
730da98
Compare
lemire
approved these changes
Nov 30, 2025
Collaborator
Collaborator
RafaelGSS
approved these changes
Nov 30, 2025
jasnell
reviewed
Nov 30, 2025
Collaborator
|
Landed in b1e941e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
c++
Issues and PRs that require attention from people who are familiar with C++.
commit-queue-squash
Add this label to instruct the Commit Queue to squash all the PR commits into the first one.
needs-ci
PRs that need a full CI run.
performance
Issues and PRs related to the performance of Node.js.
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.
Port of cloudflare/workerd#5448
Co-authored-by: Erik Corry (@erikcorry)
Co-authored-by: Daniel Lemire (@lemire)
This path can be optimized even more when Chromium PR (for updating simdutf https://chromium-review.googlesource.com/c/chromium/src/+/7199521) lands and v8 updates and includes it in a new release, and node.js updates v8 version...
Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1767/