-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
src: add fast path to TextEncoder.encodeInto #45701
Conversation
Original commit message: [fastcall] Implement support for onebyte string arguments This CL adds one byte string specialization support for fast API call arguments. It introduces a kOneByteString variant to CTypeInfo. We see a ~6x improvement in Deno's TextEncoder#encode microbenchmark. Rendered results: https://divy-v8-patches.deno.dev/ Bug: chromium:1052746 Change-Id: I47c3a9e101cd18ddc6ad58f627db3a34231b60f7 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4036884 Reviewed-by: Toon Verwaest <verwaest@chromium.org> Reviewed-by: Maya Lekova <mslekova@chromium.org> Commit-Queue: Maya Lekova <mslekova@chromium.org> Cr-Commit-Position: refs/heads/main@{#84552} Refs: v8/v8@bc831f8
Review requested:
|
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 would be more inclined to accept this if the new capabilities were used by a subsequent commit. Otherwise the change doesn't bring anything to Node.js.
@targos Should I include my changes depending on this to this particular pull request, and add |
That would be fine, yes. |
These changes look fine to me. I'm approving, but I agree on what @targos said. |
@@ -498,6 +498,7 @@ | |||
'src/node_contextify.cc', | |||
'src/node_credentials.cc', | |||
'src/node_dir.cc', | |||
'src/node_encoding.cc', |
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.
Nit: we already have so many files dealing with encodings, does this really need to be a new one (instead of, e.g., staying in node_buffer
or maybe string_bytes
)? And if so, is this the encoding file?
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 don’t have any specific thoughts on this. I’ll try to move the encode utf8 to the node_encoding once this is implementation improves the existing benchmark.
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'm still not sure why this is a new file when it only covers a tiny part of all encoding-related routines.
@tniessen Can you review this, since in your last review, you |
Co-authored-by: Anna Henningsen <anna@addaleax.net>
@targos If it's ok, I recommend creating a pull request for merging the v8 cherry-pick, and continue this performance experiment in this pull request. There are several new areas (wasm for example) that can leverage this cherry-pick. |
// For loop is required to trigger the fast path for encodeInto | ||
// Since v8 fast path is only triggered when v8 optimization starts. |
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.
There is no guarantee that V8 would take the fast path.
// For loop is required to trigger the fast path for encodeInto | |
// Since v8 fast path is only triggered when v8 optimization starts. | |
// Using a loop increases the chances of triggering the fast path for encodeInto | |
// because V8 heuristically optimizes based on information gathered at runtime. |
@@ -498,6 +498,7 @@ | |||
'src/node_contextify.cc', | |||
'src/node_credentials.cc', | |||
'src/node_dir.cc', | |||
'src/node_encoding.cc', |
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'm still not sure why this is a new file when it only covers a tiny part of all encoding-related routines.
There are git conflicts, no Jenkins CI run on the last commit, and two collaborators blocking the PR, removing
author ready
|
Thanks, @aduh95. Since other pull requests are merged, I’ll update this pull request only focusing on encodeInto. |
Original commit message:
Refs: v8/v8@bc831f8
Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1259/