Skip to content

build: enable V8 Sparkplug+ with short builtin calls - #67300

Open
gurgunday wants to merge 1 commit into
nodejs:mainfrom
gurgunday:build-sparkplug-plus
Open

gurgunday wants to merge 1 commit into
nodejs:mainfrom
gurgunday:build-sparkplug-plus

Conversation

@gurgunday

@gurgunday gurgunday commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Sparkplug+ patches calls in Sparkplug baseline code to typed builtins based on the feedback it observes. V8 compiles it in only when V8_ENABLE_SPARKPLUG_PLUS is defined, which its gn build does on x64 arm64 and loong64

Node's gyp files never defined it so --sparkplug-plus was a read-only flag fixed to false

Sparkplug+ became the default in V8 15.4, which is Chrome 154

For more information on Sparkplug+: https://youtu.be/LpJ79MxplUk?t=2638


V8 only uses Sparkplug+ when short builtin calls are enabled because it patches pc-relative calls. Therefore this PR enables it only when short builtin calls are enabled, which Node does by default on x64

On arm64 and loong64, V8 only allows short builtin calls with pointer compression, which Node doesn't use so I left it out

Also, this PR's combination of short builtin calls and Sparkplug+ without pointer compression is already tested upstream

I tested on an Apple silicon MacBook but Sparkplug+ stays off in that configuration. I couldn't run or benchmark the x64 build locally, so x64 coverage comes from CI, and we can run the benchmark CI on x64

What benefits from Sparkplug+

  • Code called somewhere between a dozen and a few hundred times
  • Code that stays in Sparkplug for other reasons:
    • while waiting for a background Maglev compile to finish
    • after being deoptimized, before re-optimizing
    • functions Maglev won't compile

Within those functions, Sparkplug+ speeds up the patched operations:

  • arithmetic (+, *, bitwise)
  • comparisons (===, <)
  • unary operations
  • named property loads (obj.x)

Each patch replaces a generic stub with one specialized for the types actually seen

Workloads that look like this

  • CLI tools and build tooling: tsc, eslint, bundlers, test runners, npm
  • Node's own startup and module loading: the code in lib/ that runs for every require/import, path handling, fs wrappers and so on
  • Servers, mostly during warm-up after a start or deploy

Sparkplug+ patches calls in Sparkplug baseline code to typed builtins
based on the feedback it observes. V8 compiles it in only when
V8_ENABLE_SPARKPLUG_PLUS is defined, which its gn build does on x64,
arm64 and loong64. Node's gyp files never defined it, so
--sparkplug-plus was a read-only flag fixed to false.

V8 only uses Sparkplug+ when short builtin calls are enabled, because
it patches pc-relative calls. Enable it on those architectures when
short builtin calls are enabled, which Node does by default on x64,
and add --v8-disable-sparkplug-plus to opt out.

Assisted-by: Claude Code
Signed-off-by: Gürgün Dayıoğlu <hey@gurgun.day>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

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

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to Node.js builds or CI infrastructure. needs-ci PRs that need a full CI run. tools Issues and PRs related to the tools directory. v8 engine Issues and PRs related to the V8 dependency. labels Nov 6, 2026
@gurgunday
gurgunday marked this pull request as ready for review November 6, 2026 12:32
@gurgunday
gurgunday requested a review from joyeecheung November 6, 2026 16:47
@gurgunday gurgunday added the needs-benchmark-ci PRs that need a benchmark CI run. label Nov 6, 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 Node.js builds or CI infrastructure. needs-benchmark-ci PRs that need a benchmark CI run. needs-ci PRs that need a full CI run. tools Issues and PRs related to the tools directory. 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