Skip to content

8347489: RISC-V: Misaligned memory access with COH#23053

Closed
RealFYang wants to merge 12 commits intoopenjdk:masterfrom
RealFYang:JDK-8347489
Closed

8347489: RISC-V: Misaligned memory access with COH#23053
RealFYang wants to merge 12 commits intoopenjdk:masterfrom
RealFYang:JDK-8347489

Conversation

@RealFYang
Copy link
Copy Markdown
Member

@RealFYang RealFYang commented Jan 12, 2025

Hi, please consider this change.

We have different base_offset for T_BYTE/T_CHAR (4-byte instead of 8-byte aligned) with COH. This causes misaligned memory accesses for several instrinsics like String.Compare or String.Equals. The reason is that we assume 8-byte alignment and process one 8-byte word starting at the first array element for each iteration in the main loop. As a result, we have performance regressions on platforms with slow misaligned memory accesses like Unmatched and Premier P550 SBCs.

PS: Same issue is there even without COH. base_offset for T_BYTE/T_CHAR is 20 (thus 4-byte aligned) when UseCompressedClassPointers is disabled in this case.

Correctness test on linux-riscv64:

  • tier1 (TEST_VM_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseCompactObjectHeaders") (release)
  • tier1 (TEST_VM_OPTS="-XX:+UnlockExperimentalVMOptions -XX:-UseCompactObjectHeaders") (release)
  • hotspot:tier1 (TEST_VM_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseCompactObjectHeaders") (fastdebug)
  • hotspot:tier1 (TEST_VM_OPTS="-XX:+UnlockExperimentalVMOptions -XX:-UseCompactObjectHeaders") (fastdebug)

Performance test on Premier P550 (-XX:+AlwaysPreTouch -Xms8g -Xmx8g):

SPECjbb2005:

1. Without Patch
1.1 -XX:+UseParallelGC -XX:-UseCompactObjectHeaders: 32666
1.2 -XX:+UseParallelGC -XX:+UseCompactObjectHeaders: 27610
1.3 -XX:+UseG1GC       -XX:-UseCompactObjectHeaders: 30911
1.4 -XX:+UseG1GC       -XX:+UseCompactObjectHeaders: 26008

2. With Patch
2.1 -XX:+UseParallelGC -XX:-UseCompactObjectHeaders: 32820
2.2 -XX:+UseParallelGC -XX:+UseCompactObjectHeaders: 34179
2.3 -XX:+UseG1GC       -XX:-UseCompactObjectHeaders: 30620
2.4 -XX:+UseG1GC       -XX:+UseCompactObjectHeaders: 31936

SPECjbb2015:

1. Without Patch
1.1 -XX:+UseG1GC -XX:-UseCompactObjectHeaders: max-jOPS = 1444, critical-jOPS = 431
1.2 -XX:+UseG1GC -XX:+UseCompactObjectHeaders: max-jOPS = 1092, critical-jOPS = 335

2. With Patch
2.1 -XX:+UseG1GC -XX:-UseCompactObjectHeaders: max-jOPS = 1452, critical-jOPS = 419
2.2 -XX:+UseG1GC -XX:+UseCompactObjectHeaders: max-jOPS = 1438, critical-jOPS = 477

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-8347489: RISC-V: Misaligned memory access with COH (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 23053

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper bot commented Jan 12, 2025

👋 Welcome back fyang! 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
Copy Markdown

openjdk bot commented Jan 12, 2025

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

8347489: RISC-V: Misaligned memory access with COH

Reviewed-by: mli, vkempik

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

  • beae884: 8349150: Support precompiled headers on AIX
  • c545a3e: 8346774: Use Predicate classes instead of Node classes

Please see this link for an up-to-date comparison between the source branch of this pull request and 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
Copy link
Copy Markdown

openjdk bot commented Jan 12, 2025

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

  • hotspot-compiler

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.

Copy link
Copy Markdown

@Hamlin-Li Hamlin-Li left a comment

Choose a reason for hiding this comment

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

Thanks for the patch.
Can you post the performance data in description?
And some minor comments.

@RealFYang RealFYang marked this pull request as ready for review January 14, 2025 03:48
@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 14, 2025
@RealFYang
Copy link
Copy Markdown
Member Author

RealFYang commented Jan 14, 2025

@Hamlin-Li
Thanks for the suggestions. I have updated accordingly. Note that base_offset is 12 and 16 bytes respectively w/wo COH.
And I have also added some specjbb2005 scores in PR description for reference.

@mlbridge
Copy link
Copy Markdown

mlbridge bot commented Jan 14, 2025

Webrevs

@Hamlin-Li
Copy link
Copy Markdown

@Hamlin-Li Thanks for the suggestions. I have updated accordingly. Note that base_offset is 12 and 16 bytes respectively w/wo COH. And I have also added some specjbb2005 scores in PR description for reference.

Thank you posting the data!
As G1 is the default one, can you run the specjbb with G1? And it would be good to list both critial and max value for specjbb.
BTW, there are also some string comparison tests in jmh, e.g. StringCompareToDifferentLength and so on.

@Hamlin-Li
Copy link
Copy Markdown

-XX:+UseParallelGC -XX:+AlwaysPreTouch -Xms8g -Xmx8g

I guess the RVV is disabled by default? Will we also address the similar issue when RVV enabled?

Copy link
Copy Markdown

@Hamlin-Li Hamlin-Li left a comment

Choose a reason for hiding this comment

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

Some comments.

@RealFYang
Copy link
Copy Markdown
Member Author

RealFYang commented Jan 16, 2025

@Hamlin-Li Thanks for the suggestions. I have updated accordingly. Note that base_offset is 12 and 16 bytes respectively w/wo COH. And I have also added some specjbb2005 scores in PR description for reference.

Thank you posting the data! As G1 is the default one, can you run the specjbb with G1? And it would be good to list both critial and max value for specjbb. BTW, there are also some string comparison tests in jmh, e.g. StringCompareToDifferentLength and so on.

The purpose of using ParallelGC for the test is to minimize the GC noise. I have also updated SPECjbb2005 score under G1GC in PR description for reference. Note that SPECjbb2005 score means bops (business operations per second). I will update SPECjbb2015 later which has max and critical jops. Thanks.

@RealFYang
Copy link
Copy Markdown
Member Author

-XX:+UseParallelGC -XX:+AlwaysPreTouch -Xms8g -Xmx8g

I guess the RVV is disabled by default? Will we also address the similar issue when RVV enabled?

Yes. SBCs like Unmatched and P550 don't have RVV extensions. And I don't see such an issue with RVV code path for these intrinsics.

Copy link
Copy Markdown

@Hamlin-Li Hamlin-Li 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 for updating.
Just one minor comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Feb 3, 2025
@RealFYang RealFYang requested a review from Hamlin-Li February 4, 2025 07:02
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Feb 4, 2025
Copy link
Copy Markdown

@Hamlin-Li Hamlin-Li left a comment

Choose a reason for hiding this comment

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

Thank you!

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Feb 4, 2025
@RealFYang
Copy link
Copy Markdown
Member Author

Thanks all for the review!
/integrate

@openjdk
Copy link
Copy Markdown

openjdk bot commented Feb 4, 2025

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

  • d699aba: 8349135: Add tests for HttpRequest.Builder.copy()
  • 81126c2: 8349238: Some more FFM benchmarks are broken
  • beae884: 8349150: Support precompiled headers on AIX
  • c545a3e: 8346774: Use Predicate classes instead of Node classes

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Feb 4, 2025

@RealFYang Pushed as commit e91a6ec.

💡 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

hotspot-compiler [email protected] integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants