Skip to content

8304893: Link Time Optimization with gcc can be faster #13180

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

Closed
wants to merge 5 commits into from

Conversation

TheShermanTanker
Copy link
Contributor

@TheShermanTanker TheShermanTanker commented Mar 24, 2023

A previous argument against link time optimization support that we have for gcc is that it was extremely slow. After some checks it turns out we are passing rather inefficient flags to gcc in optimized builds. Changing these flags to run the linker optimizations in parallel and passing additional flags to the compiler have the ability to speed this process up significantly. Also fixes some incorrect flags passed to ld for linking as well, since strict-aliasing is required for both linker and compiler, and the same optimization level should be specified instead of letting the default -O1 be passed to the linker


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8304893: Link Time Optimization with gcc can be faster

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/13180/head:pull/13180
$ git checkout pull/13180

Update a local copy of the PR:
$ git checkout pull/13180
$ git pull https://git.openjdk.org/jdk.git pull/13180/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 13180

View PR using the GUI difftool:
$ git pr show -t 13180

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/13180.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 24, 2023

👋 Welcome back jwaters! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Mar 24, 2023

@TheShermanTanker The following label will be automatically applied to this pull request:

  • build

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the build build-dev@openjdk.org label Mar 24, 2023
@TheShermanTanker TheShermanTanker changed the title WIP 8304893 Mar 24, 2023
@openjdk openjdk bot changed the title 8304893 8304893: Link Time Optimization with gcc can be faster Mar 24, 2023
@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 24, 2023
@mlbridge
Copy link

mlbridge bot commented Mar 24, 2023

Webrevs

@@ -169,8 +169,12 @@ ifeq ($(call check-jvm-feature, link-time-opt), true)
# later on if desired
JVM_OPTIMIZATION := HIGHEST_JVM
ifeq ($(call isCompiler, gcc), true)
JVM_CFLAGS_FEATURES += -flto -fuse-linker-plugin
JVM_LDFLAGS_FEATURES += -flto -fuse-linker-plugin -fno-strict-aliasing
JVM_CFLAGS_FEATURES += -flto=$(JOBS) -fuse-linker-plugin -fno-strict-aliasing -fno-fat-lto-objects
Copy link
Member

Choose a reason for hiding this comment

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

-fno-fat-lto-objects has been the default for a while now ( at least gcc 10+)

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Seems okay. Thanks.

@openjdk
Copy link

openjdk bot commented Mar 31, 2023

@TheShermanTanker 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:

8304893: Link Time Optimization with gcc can be faster

Reviewed-by: dholmes, erikj

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 97 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 31, 2023
@tstuefe
Copy link
Member

tstuefe commented Mar 31, 2023

It would be very helpful if PR description and especially JBS issue could be more specific.

Also fixes some incorrect flags passed to ld for linking as well

What incorrect options, what exactly changed?

This is important to gauge the effect it would have on backports, and whether this issue is important to backport.

@TheShermanTanker
Copy link
Contributor Author

I'll update the description to mention those flags

@TheShermanTanker
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Apr 2, 2023

Going to push as commit aa76210.
Since your change was applied there have been 97 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Apr 2, 2023
@openjdk openjdk bot closed this Apr 2, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Apr 2, 2023
@openjdk
Copy link

openjdk bot commented Apr 2, 2023

@TheShermanTanker Pushed as commit aa76210.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@TheShermanTanker TheShermanTanker deleted the patch-7 branch April 2, 2023 06:54
@erikj79
Copy link
Member

erikj79 commented Apr 3, 2023

You made a change to the patch just before integrating, on a weekend when most reviewers aren't paying attention. I would probably have argued against that change, as the JOBS setting reflects the concurrency the user has requested, which may very well be less than the number of available hardware threads in the system. I will most likely never use this feature, so it's not important enough to change it back to warrant another bug/PR/review. This is more about the principle of integrating the code as reviewed.

@TheShermanTanker
Copy link
Contributor Author

Ah, sorry about that, I realized at the last moment that the auto option was available just before integration. Will keep that in mind next time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

4 participants