Skip to content

Conversation

@shipilev
Copy link
Member

@shipilev shipilev commented Mar 19, 2025

Interpreter performance is the still important for faster startup, since it would carry application until compilers kick in. After looking at Leyden scenarios in Xint mode, I believe incremental improvements are possible in template interpreter to make it faster.

One of those improvements is tightening up method entry code. Profiling shows the hottest path in the whole ordeal for non-native methods is resolving the Java mirror to store the GC root for currently executing Method*. It involves 4-5 chained memory accesses, which incurs significant latency.

We can massage the code to reuse some memory accesses and also spread them out to allow more latency-hiding hardware mechanisms to kick in.

Additional testing:

  • Ad-hoc -Xint benchmarks
  • Linux x86_64 server fastdebug, all

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-8352415: x86: Tighten up template interpreter method entry code (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 24114

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@shipilev
Copy link
Member Author

shipilev commented Mar 19, 2025

Motivational improvements on 5950X, about 1.8% faster interpreted code.

Benchmark 1: build/linux-x86_64-server-release/images/jdk/bin/java -Xms1g -Xmx1g -XX:+UseSerialGC \
   -Xint -cp JavacBenchApp.jar JavacBenchApp 1

# Before
  Time (mean ± σ):      1.533 s ±  0.013 s    [User: 1.479 s, System: 0.051 s]
  Range (min … max):    1.517 s …  1.551 s    10 runs

# After
  Time (mean ± σ):      1.506 s ±  0.012 s    [User: 1.451 s, System: 0.051 s]
  Range (min … max):    1.493 s …  1.528 s    10 runs

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 19, 2025

👋 Welcome back shade! 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 19, 2025

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

8352415: x86: Tighten up template interpreter method entry code

Reviewed-by: adinn, jsjolen

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

  • 993eae4: 8346948: Update CLDR to Version 47.0
  • e98838f: 8352065: [PPC64] C2: Implement PopCountVL, CountLeadingZerosV and CountTrailingZerosV nodes
  • 03105fc: 8351601: [JMH] test UnixSocketChannelReadWrite failed for 2 threads config
  • fe03e2e: 8351897: Extra closing curly brace typos in Javadoc
  • fa0b18b: 8352509: Update jdk.test.lib.SecurityTools jar method to accept List parameter
  • 3ac9678: 8351224: Deprecate com.sun.tools.attach.AttachPermission for removal
  • 997aa17: 8351310: Deprecate com.sun.jdi.JDIPermission for removal
  • c953e0e: 8350579: Remove Template Assertion Predicates belonging to a loop once it is folded away
  • 67c4405: 8352866: TestLogJIT.java runs wrong test class
  • bab9372: 8352618: Remove old deprecated functionality in the build system
  • ... and 86 more: https://git.openjdk.org/jdk/compare/20f1bca0770b6b4d935b068e7f6a742cef4f5449...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 openjdk bot added the rfr Pull request is ready for review label Mar 19, 2025
@openjdk
Copy link

openjdk bot commented Mar 19, 2025

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

  • hotspot

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 hotspot hotspot-dev@openjdk.org label Mar 19, 2025
@mlbridge
Copy link

mlbridge bot commented Mar 19, 2025

Webrevs

Copy link
Contributor

@adinn adinn 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 to me.

Have you looked at aarch64 to see if this also a bottleneck there? It could use a similar trick to avoid calling load_mirror (which repeats the first two of three loads that intitialize rcpool).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 19, 2025
@shipilev
Copy link
Member Author

Have you looked at aarch64 to see if this also a bottleneck there? It could use a similar trick to avoid calling load_mirror (which repeats the first two of three loads that intitialize rcpool).

Only briefly. AArch64 is clunkier, since it does things in pairs, but I think improvements there are possible as well. As usual, we do arch-specific optimizations in separate PRs, with one architecture being a pilot :)

Copy link
Contributor

@jdksjolen jdksjolen left a comment

Choose a reason for hiding this comment

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

LGTM

@shipilev
Copy link
Member Author

Thanks for reviews!

@coleenp, you are likely interested in this area :)

@shipilev
Copy link
Member Author

If there are no other comments, I am going to integrate this soon. Thanks!

@shipilev
Copy link
Member Author

There we go!

/integrate

@openjdk
Copy link

openjdk bot commented Mar 31, 2025

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

  • 6fbaa06: 8353176: C1: x86 patching stub always calls Thread::current()
  • 79d0c94: 8352114: New test runtime/interpreter/CountBytecodesTest.java is failing
  • 23e3b3f: 8351156: C1: Remove FPU stack support after 32-bit x86 removal
  • 2592513: 8350577: Fix missing Assertion Predicates when splitting loops
  • 59629f8: 8351040: [REDO] Protection zone for easier detection of accidental zero-nKlass use
  • 8cbadf7: 8317976: Optimize SIMD sort for AMD Zen 4
  • b9d7a75: 8352879: TestPeriod.java and TestGetContentType.java run wrong test class
  • 895aabc: 8351233: [ASAN] avx2-emu-funcs.hpp:151:20: error: ‘D.82188’ is used uninitialized
  • 3d2c3cd: 8352970: Remove unnecessary Windows version check in Win32ShellFolderManager2
  • c70ad6a: 8352906: stdout/err.encoding on Windows set by incorrect Win32 call
  • ... and 160 more: https://git.openjdk.org/jdk/compare/20f1bca0770b6b4d935b068e7f6a742cef4f5449...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Mar 31, 2025

@shipilev Pushed as commit 22f630c.

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

Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

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

Sorry I was away and didn't see this. For the record, it looks good. I liked the load_mirror macro assembler function but it did redundant work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

4 participants