build,win: enable PGO and LTO for Windows builds#62761
Open
StefanStojanovic wants to merge 4 commits intonodejs:mainfrom
Open
build,win: enable PGO and LTO for Windows builds#62761StefanStojanovic wants to merge 4 commits intonodejs:mainfrom
StefanStojanovic wants to merge 4 commits intonodejs:mainfrom
Conversation
Collaborator
|
Review requested:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 datapgo-use- for building an optimized binary using the generated profile dataPGO is planned to be used like this:
vcbuild.bat pgo-generate- builds instrumented binaryvcbuild.bat pgo-use- builds optimized binaryLTO
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:
ltcgoption, and start usingthin-ltofor 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 bottleneckRefs: #61964