-
Notifications
You must be signed in to change notification settings - Fork 5.9k
8349214: Improve size optimization flags for MSVC builds #23432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
👋 Welcome back mbaesken! A progress list of the required criteria for merging this PR into |
@MBaesken This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 8 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
What libraries are currently optimized for size on Windows, i.e. is affected by this change? What testing have you performed to ensure no new compiler bugs show up? Changing optimization level introduces a risk of compiler-related bugs, similar to compiler upgrades. Note that this is not only about bugs in the compiler, but in our code where we use undefined behavior, which happily have worked out fine for one optimization level, but which results in bad code generated (correctly) by the compiler. |
No libraries are optimized for size by default. Optimization for size is only used by hotspot, and only when Optimization level |
True, it is at the moment only for opt-size / jvm.dll . In future I plan to create a PR for libsplashscreen using SIZE optimization, but currently this would lead to a larger (!) lib with MSVC because of the bad -Os , this does not make sense. |
splashscreen already uses LOW for its optimization flags though. Is the intent to change it to SIZE for all compilers? |
LOW uses NORM so for Windows switching to SIZE won't change anything after this PR. So yes it will probably be SIZE for splashscreen for all compilers. |
Sounds good then. The optimization levels were kind of a mess that we "inherited" from the old build system, were they had just agglutinated over the years, probably dating back to Java 1.0, with nobody left around to remember why they were the way they were. So it is definitely ripe for an overhaul. Anything you can do in this area is much appreciated, as long as it does not cause any regressions. |
Thanks for the reviews ! /integrate |
Going to push as commit 40603a5.
Your commit was automatically rebased without conflicts. |
Thanks for the clarification ! |
Looks like the binary size optimization flags are not ideal when compiling with MSVC.
On other compilers (gcc/clang) the current size optimization flags lead in most cases to smaller libraries. On MSVC this seems to be not the case, the libs often get larger when optimizing for SIZE.
For example jvm.dll (build with VS2022) with current -Os size optimization
20M images/jdk/bin/server/jvm.dll
with -O1 set for size optimization
13M images/jdk/bin/server/jvm.dll
See the doc from MSVC about "optimize for size"
https://learn.microsoft.com/en-us/cpp/build/reference/o1-o2-minimize-size-maximize-speed?view=msvc-170
"The /O1 option sets the individual optimization options that create the smallest code in the majority of cases."
The Os option is only a part of the size minimization flag set :
/O1 (Minimize Size) equivalent to /Og /Os /Oy /Ob2 /GF /Gy
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/23432/head:pull/23432
$ git checkout pull/23432
Update a local copy of the PR:
$ git checkout pull/23432
$ git pull https://git.openjdk.org/jdk.git pull/23432/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 23432
View PR using the GUI difftool:
$ git pr show -t 23432
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/23432.diff
Using Webrev
Link to Webrev Comment