Skip to content
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

8332528: Generate code in SwitchBootstraps.generateTypeSwitch that require fewer adaptations #19307

Closed
wants to merge 7 commits into from

Conversation

cl4es
Copy link
Member

@cl4es cl4es commented May 20, 2024

We can fold the call to Objects.checkIndex into the code generated in generateTypeSwitchSkeleton instead of doing so by filtering the MH argument. This loads 9 less classes (of which 8 generated LFs and Species classes) on a minimal test, while being neutral on a throughput sanity test:

Name                   Cnt  Base   Error   Test   Error  Unit  Change
SwitchSanity.switchSum  15 8,162 ± 0,117  8,152 ± 0,131 ns/op   1,00x (p = 0,800 )
  * = significant

A few additional optimizations includes moving some seldom used findStatic calls to a holder. All in all this means a reduction by 22M cycles to bootstrap a trivial switch expression on my M1.


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-8332528: Generate code in SwitchBootstraps.generateTypeSwitch that require fewer adaptations (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 19307

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 20, 2024

👋 Welcome back redestad! 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 May 20, 2024

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

8332528: Generate code in SwitchBootstraps.generateTypeSwitch that require fewer adaptations

Reviewed-by: liach, jlahoda

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

  • 4e6d851: 8325324: Implement JEP 477: Implicitly Declared Classes and Instance Main Methods (Third Preview)
  • 612ae92: 8332735: [JVMCI] Add extra JVMCI events for exception translation
  • 1ea76d3: 8332675: test/hotspot/jtreg/gc/testlibrary/Helpers.java compileClass javadoc does not match after 8321812
  • 94af3c2: 8329203: Parallel: Investigate Mark-Compact for Full GC to decrease memory usage
  • 1e5a278: 8332676: Remove unused BarrierSetAssembler::incr_allocated_bytes
  • c2180d1: 8315767: InetAddress: constructing objects from BSD literal addresses
  • 2a11e0d: 8332743: Update comment related to JDK-8320522
  • 6829d9a: 8332122: [nmt] Totals for malloc should show total peak
  • 9d332e6: 8307193: Several Swing jtreg tests use class.forName on L&F classes
  • 98f6a80: 8332490: JMH org.openjdk.bench.java.util.zip.InflaterInputStreams.inflaterInputStreamRead OOM
  • ... and 39 more: https://git.openjdk.org/jdk/compare/b92bd671835c37cff58e2cdcecd0fe4277557d7f...master

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
Copy link

openjdk bot commented May 20, 2024

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

  • core-libs

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 core-libs core-libs-dev@openjdk.org label May 20, 2024
@cl4es cl4es changed the title Move Objects.checkIndex call to code generated by generateTypeSwitch Move Objects.checkIndex call to code generated by generateTypeSwitchSkeleton May 20, 2024
@cl4es cl4es changed the title Move Objects.checkIndex call to code generated by generateTypeSwitchSkeleton 8332528: Generate code in SwitchBootstraps.generateTypeSwitch that require fewer adaptations May 20, 2024
@cl4es
Copy link
Member Author

cl4es commented May 20, 2024

To help evaluate and diagnose the startup overheads I added a main method to the provided SwitchSanity micro. This only runs a single invocation and is easy to run using your startup benchmarking script/tool of choice:

Name             Cnt          Base         Error           Test         Error         Unit  Change
Perfstartup-JMH   20        75,000 ±       4,455         62,000 ±       6,042        ms/op   1,21x (p = 0,000*)
  :.cycles           277393501,850 ± 4422757,249  253819501,350 ± 5482340,325       cycles   0,92x (p = 0,000*)
  :.instructions     701618995,500 ± 3774721,992  622929549,250 ± 3634060,803 instructions   0,89x (p = 0,000*)
  :.taskclock               82,000 ±       3,564         74,000 ±       4,365           ms   0,90x (p = 0,000*)
  * = significant

@cl4es cl4es marked this pull request as ready for review May 20, 2024 20:46
@openjdk openjdk bot added the rfr Pull request is ready for review label May 20, 2024
@mlbridge
Copy link

mlbridge bot commented May 20, 2024

Webrevs

@cl4es
Copy link
Member Author

cl4es commented May 21, 2024

By adding a trivial type switch to HelloClasslist we archive a set of classes and avoid some runtime class generation. This grows the default CDS archive by approximately 1.2Mb by pulling in a large number of Classfile API classes, which is bound to happen soon anyway.

On the SwitchSanity test, bootstrap cost drops by another 35M cycles:

Wall clock:    51.0 ms/op
.taskclock:    63.5 ms/op
.cycles:       220064872 average cycles elapsed
.instructions: 544981276 average instructions retired

@cl4es
Copy link
Member Author

cl4es commented May 21, 2024

f04d78e passed tier1-3 testing

Copy link
Contributor

@lahodaj lahodaj left a comment

Choose a reason for hiding this comment

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

Seems goo to me, with one nit related to MethodTypeDescImpl.

Copy link
Contributor

@lahodaj lahodaj left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 23, 2024
@cl4es
Copy link
Member Author

cl4es commented May 23, 2024

Thanks!

/integrate

@openjdk
Copy link

openjdk bot commented May 23, 2024

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

  • b890336: 8328083: degrade virtual thread support for GetObjectMonitorUsage
  • 4e6d851: 8325324: Implement JEP 477: Implicitly Declared Classes and Instance Main Methods (Third Preview)
  • 612ae92: 8332735: [JVMCI] Add extra JVMCI events for exception translation
  • 1ea76d3: 8332675: test/hotspot/jtreg/gc/testlibrary/Helpers.java compileClass javadoc does not match after 8321812
  • 94af3c2: 8329203: Parallel: Investigate Mark-Compact for Full GC to decrease memory usage
  • 1e5a278: 8332676: Remove unused BarrierSetAssembler::incr_allocated_bytes
  • c2180d1: 8315767: InetAddress: constructing objects from BSD literal addresses
  • 2a11e0d: 8332743: Update comment related to JDK-8320522
  • 6829d9a: 8332122: [nmt] Totals for malloc should show total peak
  • 9d332e6: 8307193: Several Swing jtreg tests use class.forName on L&F classes
  • ... and 40 more: https://git.openjdk.org/jdk/compare/b92bd671835c37cff58e2cdcecd0fe4277557d7f...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label May 23, 2024
@openjdk openjdk bot closed this May 23, 2024
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label May 23, 2024
@openjdk openjdk bot removed the rfr Pull request is ready for review label May 23, 2024
@openjdk
Copy link

openjdk bot commented May 23, 2024

@cl4es Pushed as commit 2581935.

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

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

Successfully merging this pull request may close these issues.

3 participants