Skip to content

Tune Linux x64 prebuild for Zen 3 - #4

Merged
ronag merged 1 commit into
mainfrom
codex/znver3-x64
Jul 12, 2026
Merged

Tune Linux x64 prebuild for Zen 3#4
ronag merged 1 commit into
mainfrom
codex/znver3-x64

Conversation

@ronag

@ronag ronag commented Jul 12, 2026

Copy link
Copy Markdown
Member

Summary

  • mirror the RocksDB prebuild pattern with an opt-in NODE_RE2_MARCH GYP variable
  • build the shipped Docker linux/x64 prebuild with -march=znver3 -mtune=znver3
  • keep arm64, macOS, Windows, and ordinary source builds portable when the variable is unset
  • document the Zen 3/AVX2 requirement and the source-build opt-in

Why

The deployment x64 target is Zen 3 and should permit AVX2 optimization, matching @nxtedition/rocksdb. The previous prebuild used the compiler's portable x64 baseline, so RE2 and Abseil could not emit AVX2 or other Zen 3 instructions.

Impact

The shipped glibc linux-x64 prebuild now requires a CPU compatible with GCC's znver3 target, which includes AVX2. Linux x64 source builds remain portable by default and can opt into the same target with NODE_RE2_MARCH=znver3. The Darwin arm64 prebuild is unchanged.

Validation

  • macOS arm64, Node 26.5.0: native rebuild, 14/14 runtime tests, TypeScript tests, and symbol check passed
  • verified the arm64 build metadata contains no -march or -mtune flags
  • Docker linux/amd64, Node 26.5.0: clean prebuild compiled and linked, then passed 14/14 prebuild-only runtime tests and TypeScript tests
  • generated x64 build metadata contains -march=znver3 and -mtune=znver3 in both C and C++ flags
  • the x64 compiler defines __AVX2__=1 under the configured target; the emitted addon is a stripped 64-bit x86-64 ELF
  • only the two known GCC 12 -Wrestrict warnings from vendored Abseil appeared; there were no node-re2 warnings or errors
  • implementation independently reviewed against the RocksDB pattern

@ronag
ronag requested a review from Copilot July 12, 2026 11:22
@ronag
ronag marked this pull request as ready for review July 12, 2026 11:22
@ronag
ronag merged commit 6f0864a into main Jul 12, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an opt-in build-time CPU tuning switch for Linux x64 builds (via NODE_RE2_MARCH) and uses it to produce the shipped glibc linux-x64 prebuild tuned for Zen 3 (-march=znver3 -mtune=znver3), while keeping default/source builds portable when the variable is unset.

Changes:

  • Add NODE_RE2_MARCH -> GYP variable wiring and apply -march/-mtune only on Linux x64 when set.
  • Build the Docker-produced linux/x64 prebuild with NODE_RE2_MARCH=znver3.
  • Document the Linux x64 prebuild tuning/requirement and the source-build opt-in in the README.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
README.md Documents the Zen 3-tuned Linux x64 prebuild and the NODE_RE2_MARCH source-build opt-in.
Dockerfile Sets NODE_RE2_MARCH=znver3 for the prebuildify step to produce the shipped tuned linux-x64 artifact.
binding.gyp Adds the node_re2_march variable and conditionally applies -march/-mtune on Linux x64 only when provided.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants