-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
src: Fix inefficient usage of v8_inspector::StringView #52372
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: Fix inefficient usage of v8_inspector::StringView #52372
Conversation
0d43fab
to
a4087c9
Compare
Failed to start CI- Validating Jenkins credentials ✘ Jenkins credentials invalidhttps://github.com./nodejs/node/actions/runs/8605010252 |
@addaleax Anything I need to address from my side for the failed CI run? |
I'm not too familiar with the node CI. Are the failing tests from the two CI runs generally known to be flaky or should I investigate? |
66345c0
to
f79c3cb
Compare
Rebased the PR after #51783 has landed. FYI @joyeecheung |
@szuend could you please rebase the branch? We may not have merge commits for the CI and it has to run once more for this to land. I believe it's otherwise good to land. |
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.
After the latest update on the main branch, this needs an update to fix the build failure.
Thank you for the patch!
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #52372 +/- ##
==========================================
+ Coverage 90.23% 90.24% +0.01%
==========================================
Files 630 630
Lines 185017 185032 +15
Branches 36207 36222 +15
==========================================
+ Hits 166948 166985 +37
- Misses 11020 11029 +9
+ Partials 7049 7018 -31
🚀 New features to boost your workflow:
|
Failed to start CI⚠ Commits were pushed since the last approving review: ⚠ - src: fix inefficient usage of v8_inspector::StringView ⚠ - Apply linter ⚠ - Rename function to ToV8Value and mirror std::string_view overload ⚠ - Merge branch 'main' into fix-inspector-string-view-usage ⚠ - Fix usage of UNLIKELY ✘ Refusing to run CI on potentially unsafe PRhttps://github.com./nodejs/node/actions/runs/14238536161 |
@szuend I think the CI failed to due merge commits. Would you mind rebase onto the tip of the main branch? thanks! |
v8_inspector::StringView can either be one-byte or two-byte strings. Node has currently two places where it's unconditionally assumed that it's a two-byte StringView. This requires the upstream V8 inspector to unnecessarily create a copy of the string: https://source.chromium.org/chromium/chromium/src/+/main:v8/src/inspector/v8-inspector-session-impl.cc;l=192-199;drc=05bacd38e7a31e92afe0fd66081dfa2cc03b934a This is particularly slow, especially for large CDP messages, as the serialized JSON is iterated 8-bit char by 8-bit char and each one widened to a 16-bit char. This PR introduces a small helper that correctly converts a StringView to a v8::String instance honoring the "is8Bit" flag. This allows upstream V8 to remove the unnecessary widening copy.
fe2ea75
to
b144ac0
Compare
@legendecas done! Thanks! |
Landed in 264d031 |
v8_inspector::StringView can either be one-byte or two-byte strings. Node has currently two places where it's unconditionally assumed that it's a two-byte StringView. This requires the upstream V8 inspector to unnecessarily create a copy of the string: https://source.chromium.org/chromium/chromium/src/+/main:v8/src/inspector/v8-inspector-session-impl.cc;l=192-199;drc=05bacd38e7a31e92afe0fd66081dfa2cc03b934a This is particularly slow, especially for large CDP messages, as the serialized JSON is iterated 8-bit char by 8-bit char and each one widened to a 16-bit char. This PR introduces a small helper that correctly converts a StringView to a v8::String instance honoring the "is8Bit" flag. This allows upstream V8 to remove the unnecessary widening copy. PR-URL: nodejs#52372 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]>
v8_inspector::StringView can either be one-byte or two-byte strings. Node has currently two places where it's unconditionally assumed that it's a two-byte StringView.
This requires the upstream V8 inspector to unnecessarily create a copy of the string:
https://source.chromium.org/chromium/chromium/src/+/main:v8/src/inspector/v8-inspector-session-impl.cc;l=192-199;drc=05bacd38e7a31e92afe0fd66081dfa2cc03b934a
This is particularly slow, especially for large CDP messages, as the serialized JSON is iterated 8-bit char by 8-bit char and each one widened to a 16-bit char.
This PR introduces a small helper that correctly converts a StringView to a v8::String instance honoring the "is8Bit" flag. This allows upstream V8 to remove the unnecessary widening copy.
Tested locally with removing the widening copy in v8-inspector-session-impl.cc: Without the PR lots of tests will fail. But I'm happy to add unit tests for the
JSBindingsConnection
/V8ProfilerConnection
if desired.