Skip to content

deps: V8: cherry-pick Highway string performance patches#61825

Open
rmagrin wants to merge 2 commits intonodejs:mainfrom
rmagrin:v8-backport-highway-ascii
Open

deps: V8: cherry-pick Highway string performance patches#61825
rmagrin wants to merge 2 commits intonodejs:mainfrom
rmagrin:v8-backport-highway-ascii

Conversation

@rmagrin
Copy link
Contributor

@rmagrin rmagrin commented Feb 14, 2026

Summary

Cherry-picks two V8 patches that improve string performance using Highway SIMD:

  • 67507b2a88f4 — Reland "use highway to check and copy leading ascii" (Dan Carney)
    Replaces IsAsciiOneByteString + memcpy with Highway WriteLeadingAscii in Utf8::Encode, providing a faster ASCII fast path for WriteUtf8V2.
    CL: https://chromium-review.googlesource.com/c/v8/v8/+/7184338

  • c135d5e81f82 — Optimize ContainsOnlyOneByte with SIMD (Yagiz Nizipli)
    Adds Highway-based SIMD implementation for checking if strings contain only one-byte (Latin-1) characters, replacing the scalar loop in both String::ContainsOnlyOneByte() and the internal IsOnly8Bit() helper.
    CL: https://chromium-review.googlesource.com/c/v8/v8/+/7159233

These patches address the remaining ~30-40% performance gap in WriteUtf8V2 vs v22 after #61712 landed the initial simdutf + memcpy fast path.

Refs: #60719

Test plan

  • Node.js V8 test suite passes (25/25)
  • C++ unit tests (StringBytes, Unicode, Utf8) pass
  • Smoke tests: ASCII, mixed, and long string round-trips verified
  • CI: V8 CI + Node.js CI

Original commit message:

    Reland "use highway to check and copy leading ascii"

    This is a reland of commit a3e84e5f01540cec142f4d4f41f1921373c220e5

    Original change's description:
    > use highway to check and copy leading ascii
    >
    > Change-Id: I065532aeeee95273821aa1f25b5ffc5c5c23cbf1
    > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7172479
    > Reviewed-by: Patrick Thier <pthier@chromium.org>
    > Reviewed-by: Toon Verwaest <verwaest@chromium.org>
    > Commit-Queue: Dan Carney <dcarney@chromium.org>
    > Cr-Commit-Position: refs/heads/main@{#103820}

    Change-Id: I43b4ad18817eb52b701e112d2d0a5f685374ae1f
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7184338
    Reviewed-by: Toon Verwaest <verwaest@chromium.org>
    Reviewed-by: Patrick Thier <pthier@chromium.org>
    Commit-Queue: Dan Carney <dcarney@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#103865}

Refs: v8/v8@67507b2
Original commit message:

    [api][strings] Optimize ContainsOnlyOneByte with SIMD

    Add Highway-based SIMD implementation for checking if strings contain
    only one-byte (Latin-1) characters. Highway provides portable SIMD
    abstraction across different architectures with automatic target
    selection at runtime.

    The SIMD implementation processes 8 uint16_t values (128 bits) at
    once,checking if any character has the high byte set. This provides
    significant speedup over the previous implementation which processed 2-4
    values per iteration and only checked every 16 iterations.

    The optimization applies to both String::ContainsOnlyOneByte() in the
    public API and the internal IsOnly8Bit() helper used during string
    hashing. This improves performance for string validation, encoding
    decisions, and UTF-8/UTF-16 conversion operations.

    Additionally, it resolves a TODO by leszeks.

    Change-Id: I41f519339fb96f3bf3f4fa30283f84ccbb5115d0
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7159233
    Reviewed-by: Erik Corry <erikcorry@chromium.org>
    Commit-Queue: Erik Corry <erikcorry@chromium.org>
    Reviewed-by: Leszek Swirski <leszeks@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#104120}

Refs: v8/v8@c135d5e
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/gyp
  • @nodejs/security-wg
  • @nodejs/v8-update

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. needs-ci PRs that need a full CI run. v8 engine Issues and PRs related to the V8 dependency. labels Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Issues and PRs related to build files or the CI. needs-ci PRs that need a full CI run. v8 engine Issues and PRs related to the V8 dependency.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants