node
node copied to clipboard
src: Fix inefficient usage of v8_inspector::StringView
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.
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?
CI: https://ci.nodejs.org/job/node-test-pull-request/58242/
CI: https://ci.nodejs.org/job/node-test-pull-request/58268/
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?
CI: https://ci.nodejs.org/job/node-test-pull-request/58399/
CI: https://ci.nodejs.org/job/node-test-pull-request/58428/
Rebased the PR after https://github.com/nodejs/node/pull/51783 has landed.
FYI @joyeecheung
CI: https://ci.nodejs.org/job/node-test-pull-request/58593/
CI: https://ci.nodejs.org/job/node-test-pull-request/58639/
CI: https://ci.nodejs.org/job/node-test-pull-request/58684/
CI: https://ci.nodejs.org/job/node-test-pull-request/58751/
CI: https://ci.nodejs.org/job/node-test-pull-request/58798/
CI: https://ci.nodejs.org/job/node-test-pull-request/59446/