Skip to content

build,win: enable PGO and LTO for Windows builds#62761

Merged
nodejs-github-bot merged 4 commits intonodejs:mainfrom
JaneaSystems:mefi-win-pgo
Apr 23, 2026
Merged

build,win: enable PGO and LTO for Windows builds#62761
nodejs-github-bot merged 4 commits intonodejs:mainfrom
JaneaSystems:mefi-win-pgo

Conversation

@StefanStojanovic
Copy link
Copy Markdown
Contributor

Description

This PR enables Profile-Guided Optimization (PGO) and Link-Time Optimization (LTO) for Windows builds (x64 and ARM64). The changes used the Linux implementation of these optimizations as guidelines. They can be used separately, but can also be used alongside each other for the best results.


PGO

PGO adds 2 new, mutually exclusive, vcbuild options:

  • pgo-generate - for building an instrumented binary for generating profile data
  • pgo-use - for building an optimized binary using the generated profile data

PGO is planned to be used like this:

  1. vcbuild.bat pgo-generate - builds instrumented binary
  2. Run workload to generate profile data
  3. vcbuild.bat pgo-use - builds optimized binary

LTO

On Windows, LTCG was used for a long time. Since moving to ClangCL, LTO is an option, and this PR adds support for it. Together with adapting the legacy LTCG option (which is still available and used for release builds), there are 2 new LTO options in vcbuild. All 3 are mutually exclusive:

  • ltcg - since LTCG is an MSVC-specific optimization, it is now changed to apply thin LTO, but only to the Node.js executable. This is how LTCG was applied previously.
  • thin-lto - applies thin LTO to all projects (except build-time tools)
  • lto - applies full LTO to all projects (except build-time tools)

Next steps

This PR simply enables using PGO and/or LTO in Windows builds, and as such, is a good starting point, but in order to capitalize on it, more work is needed in the future. Because of this, I believe these changes are safe to land, as they just enable optimizations, without forcing them anywhere. Here is a rough set of a few future steps we could take if we wanted to leverage this:

  • Remove the ltcg option, and start using thin-lto for Windows builds. This is a simple change to make, but we need to investigate how it will affect build time and performance, as we do not want to make the Windows compilation job a bottleneck
  • Enabling PGO in the release CI for official releases. This is a much bigger task, and should probably be separated into a few minor ones. For example, first we'd have to come up with a good workload for instrumented build, validate the benefits it can give us, and after all of that, we'd need to change the release CI build job to start using this for official releases.

Refs: #61964

@StefanStojanovic StefanStojanovic added windows Issues and PRs related to the Windows platform. build Issues and PRs related to build files or the CI. labels Apr 15, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

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

@nodejs-github-bot nodejs-github-bot added dependencies Pull requests that update a dependency file. i18n-api Issues and PRs related to the i18n implementation. icu Issues and PRs related to the ICU dependency. needs-ci PRs that need a full CI run. openssl Issues and PRs related to the OpenSSL dependency. tools Issues and PRs related to the tools directory. v8 engine Issues and PRs related to the V8 dependency. labels Apr 15, 2026
@meixg meixg added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 16, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 16, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Member

@lpinca lpinca left a comment

Choose a reason for hiding this comment

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

RSLGTM

@StefanStojanovic
Copy link
Copy Markdown
Contributor Author

Since there are 3 approvals and the CI has passed, I'll add the commit-queue label tomorrow to land it, so if someone wants to review it and leave comments, please do that today.

@StefanStojanovic StefanStojanovic added the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 23, 2026
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Apr 23, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/62761
✔  Done loading data for nodejs/node/pull/62761
----------------------------------- PR info ------------------------------------
Title      build,win: enable PGO and LTO for Windows builds (#62761)
   ⚠  Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch     StefanStojanovic:mefi-win-pgo -> nodejs:main
Labels     windows, build, v8 engine, openssl, tools, i18n-api, needs-ci, dependencies, icu
Commits    4
 - build,win: enable x64 PGO
 - build,win: change LTCG to thin LTO
 - build,win: enable full LTO
 - build,win: enable ARM64 PGO
Committers 1
 - StefanStojanovic <stefan.stojanovic@janeasystems.com>
PR-URL: https://github.com/nodejs/node/pull/62761
Refs: https://github.com/nodejs/node/issues/61964
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/62761
Refs: https://github.com/nodejs/node/issues/61964
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
--------------------------------------------------------------------------------
   ℹ  This PR was created on Wed, 15 Apr 2026 17:55:08 GMT
   ✔  Approvals: 3
   ✔  - Xuguang Mei (@meixg): https://github.com/nodejs/node/pull/62761#pullrequestreview-4120394786
   ✔  - Luigi Pinca (@lpinca): https://github.com/nodejs/node/pull/62761#pullrequestreview-4131453924
   ✔  - Tobias Nießen (@tniessen) (TSC): https://github.com/nodejs/node/pull/62761#pullrequestreview-4135179752
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2026-04-17T08:01:16Z: https://ci.nodejs.org/job/node-test-pull-request/72734/
- Querying data for job/node-test-pull-request/72734/
✔  Build data downloaded
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  No git cherry-pick in progress
   ✔  No git am in progress
   ✔  No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
 * branch                  main       -> FETCH_HEAD
✔  origin/main is now up-to-date
- Downloading patch for 62761
From https://github.com/nodejs/node
 * branch                  refs/pull/62761/merge -> FETCH_HEAD
✔  Fetched commits as d44a71a25111..c58fb1f05b3e
--------------------------------------------------------------------------------
Auto-merging common.gypi
Auto-merging configure.py
Auto-merging node.gyp
Auto-merging vcbuild.bat
[main a8fd13f7e7] build,win: enable x64 PGO
 Author: StefanStojanovic <stefan.stojanovic@janeasystems.com>
 Date: Fri Feb 27 14:18:04 2026 +0100
 4 files changed, 77 insertions(+), 22 deletions(-)
Auto-merging configure.py
Auto-merging node.gyp
[main 225ed5cbe7] build,win: change LTCG to thin LTO
 Author: StefanStojanovic <stefan.stojanovic@janeasystems.com>
 Date: Fri Feb 27 16:13:38 2026 +0100
 2 files changed, 27 insertions(+), 32 deletions(-)
Auto-merging common.gypi
Auto-merging configure.py
Auto-merging node.gyp
Auto-merging vcbuild.bat
[main d21c15f2fa] build,win: enable full LTO
 Author: StefanStojanovic <stefan.stojanovic@janeasystems.com>
 Date: Thu Mar 19 09:07:54 2026 +0100
 9 files changed, 255 insertions(+), 6 deletions(-)
Auto-merging common.gypi
Auto-merging configure.py
[main 182e805eca] build,win: enable ARM64 PGO
 Author: StefanStojanovic <stefan.stojanovic@janeasystems.com>
 Date: Thu Mar 26 11:41:44 2026 +0100
 2 files changed, 47 insertions(+), 19 deletions(-)
   ✔  Patches applied
There are 4 commits in the PR. Attempting autorebase.
(node:347) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Rebasing (2/8)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
build,win: enable x64 PGO

PR-URL: #62761
Refs: #61964
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>

[detached HEAD 65b90a335f] build,win: enable x64 PGO
Author: StefanStojanovic <stefan.stojanovic@janeasystems.com>
Date: Fri Feb 27 14:18:04 2026 +0100
4 files changed, 77 insertions(+), 22 deletions(-)
Rebasing (3/8)
Rebasing (4/8)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
build,win: change LTCG to thin LTO

PR-URL: #62761
Refs: #61964
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>

[detached HEAD 92625c6c6d] build,win: change LTCG to thin LTO
Author: StefanStojanovic <stefan.stojanovic@janeasystems.com>
Date: Fri Feb 27 16:13:38 2026 +0100
2 files changed, 27 insertions(+), 32 deletions(-)
Rebasing (5/8)
Rebasing (6/8)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
build,win: enable full LTO

PR-URL: #62761
Refs: #61964
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>

[detached HEAD 9b3b43ec3a] build,win: enable full LTO
Author: StefanStojanovic <stefan.stojanovic@janeasystems.com>
Date: Thu Mar 19 09:07:54 2026 +0100
9 files changed, 255 insertions(+), 6 deletions(-)
Rebasing (7/8)
Rebasing (8/8)
Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
build,win: enable ARM64 PGO

PR-URL: #62761
Refs: #61964
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>

[detached HEAD 941f23777f] build,win: enable ARM64 PGO
Author: StefanStojanovic <stefan.stojanovic@janeasystems.com>
Date: Thu Mar 26 11:41:44 2026 +0100
2 files changed, 47 insertions(+), 19 deletions(-)
Successfully rebased and updated refs/heads/main.

ℹ Add commit-queue-squash label to land the PR as one commit, or commit-queue-rebase to land as separate commits.

https://github.com/nodejs/node/actions/runs/24834484916

@StefanStojanovic StefanStojanovic removed the commit-queue-failed An error occurred while landing this pull request using GitHub Actions. label Apr 23, 2026
@StefanStojanovic StefanStojanovic added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Apr 23, 2026
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 23, 2026
@nodejs-github-bot nodejs-github-bot merged commit 262dee5 into nodejs:main Apr 23, 2026
115 checks passed
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. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. dependencies Pull requests that update a dependency file. i18n-api Issues and PRs related to the i18n implementation. icu Issues and PRs related to the ICU dependency. needs-ci PRs that need a full CI run. openssl Issues and PRs related to the OpenSSL dependency. tools Issues and PRs related to the tools directory. v8 engine Issues and PRs related to the V8 dependency. windows Issues and PRs related to the Windows platform.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants