Skip to content

8388837: RISC-V: Track card addresses directly in G1 array post-write barrier loop - #32020

Closed
zifeihan wants to merge 3 commits into
openjdk:masterfrom
zifeihan:JDK-8388837
Closed

8388837: RISC-V: Track card addresses directly in G1 array post-write barrier loop#32020
zifeihan wants to merge 3 commits into
openjdk:masterfrom
zifeihan:JDK-8388837

Conversation

@zifeihan

@zifeihan zifeihan commented Jul 23, 2026

Copy link
Copy Markdown
Member

As discussed here: #31956 (comment)

We can propose this array card-loop optimization and apply it on both RISC-V and AArch64. However, AArch64's indexed addressing may limit the performance benefit, so I need to run performance tests to verify it first. After that, I'll submit a new PR for AArch64.
For now, let's only apply the optimization to the RISC-V backend here.

Correctness Testing

  • Run tier1-tier3 test with release on SG2044

Performance test:

We can observe the throughput scores increased from 604.565 to 616.446. While this may not look like a huge improvement, we can also use the perfnorm profiler to observe normalized metrics such as instructions per operation and cycles per operation. From the data below, we can see that after applying the patch, instructions:u decreased — which is exactly our goal.

Performance test command:

make test TEST="micro:org.openjdk.bench.java.lang.ArrayCopyObject"  MICRO="OPTIONS=-f 3 -wi 4 -i 4 -prof perfnorm -p size=8191"

without this patch:

Benchmark                                                 (size)   Mode  Cnt     Score      Error      Units
ArrayCopyObject.conjoint_micro                              8191  thrpt   12   604.565 ±   25.992     ops/ms
ArrayCopyObject.conjoint_micro:CPI                          8191  thrpt    3     2.081 ±    1.478  clks/insn
ArrayCopyObject.conjoint_micro:IPC                          8191  thrpt    3     0.481 ±    0.334  insns/clk
ArrayCopyObject.conjoint_micro:L1-dcache-load-misses:u      8191  thrpt    3     0.241 ±    1.885       #/op
ArrayCopyObject.conjoint_micro:L1-dcache-loads:u            8191  thrpt    3  2228.127 ± 1321.906       #/op
ArrayCopyObject.conjoint_micro:L1-dcache-store-misses:u     8191  thrpt    3     0.005 ±    0.042       #/op
ArrayCopyObject.conjoint_micro:L1-dcache-stores:u           8191  thrpt    3  2098.435 ± 1369.781       #/op
ArrayCopyObject.conjoint_micro:L1-icache-load-misses:u      8191  thrpt    3     0.072 ±    0.263       #/op
ArrayCopyObject.conjoint_micro:L1-icache-loads:u            8191  thrpt    3  1152.612 ±  164.830       #/op
ArrayCopyObject.conjoint_micro:branch-misses:u              8191  thrpt    3     1.067 ±    0.446       #/op
ArrayCopyObject.conjoint_micro:branches:u                   8191  thrpt    3   396.510 ±   24.555       #/op
ArrayCopyObject.conjoint_micro:cycles:u                     8191  thrpt    3  3618.339 ± 2730.820       #/op
ArrayCopyObject.conjoint_micro:dTLB-loads:u                 8191  thrpt    3  2227.473 ± 1297.338       #/op
ArrayCopyObject.conjoint_micro:dTLB-store-misses:u          8191  thrpt    3     0.004 ±    0.040       #/op
ArrayCopyObject.conjoint_micro:dTLB-stores:u                8191  thrpt    3  2099.337 ± 1412.496       #/op
ArrayCopyObject.conjoint_micro:iTLB-load-misses:u           8191  thrpt    3     0.079 ±    0.463       #/op
ArrayCopyObject.conjoint_micro:iTLB-loads:u                 8191  thrpt    3  3606.789 ± 2721.584       #/op
ArrayCopyObject.conjoint_micro:instructions:u               8191  thrpt    3  1738.801 ±  124.064       #/op
ArrayCopyObject.conjoint_micro:stalled-cycles-backend:u     8191  thrpt    3   320.011 ±   93.319       #/op
ArrayCopyObject.conjoint_micro:stalled-cycles-frontend:u    8191  thrpt    3  2666.511 ± 2685.390       #/op
ArrayCopyObject.disjoint_micro                              8191  thrpt   12   579.264 ±   18.531     ops/ms
ArrayCopyObject.disjoint_micro:CPI                          8191  thrpt    3     2.546 ±    1.062  clks/insn
ArrayCopyObject.disjoint_micro:IPC                          8191  thrpt    3     0.393 ±    0.163  insns/clk
ArrayCopyObject.disjoint_micro:L1-dcache-load-misses:u      8191  thrpt    3     0.230 ±    1.781       #/op
ArrayCopyObject.disjoint_micro:L1-dcache-loads:u            8191  thrpt    3  2261.139 ±   37.568       #/op
ArrayCopyObject.disjoint_micro:L1-dcache-store-misses:u     8191  thrpt    3     0.005 ±    0.041       #/op
ArrayCopyObject.disjoint_micro:L1-dcache-stores:u           8191  thrpt    3  2183.380 ±   33.429       #/op
ArrayCopyObject.disjoint_micro:L1-icache-load-misses:u      8191  thrpt    3     0.070 ±    0.242       #/op
ArrayCopyObject.disjoint_micro:L1-icache-loads:u            8191  thrpt    3   744.459 ±   89.813       #/op
ArrayCopyObject.disjoint_micro:branch-misses:u              8191  thrpt    3     0.060 ±    0.499       #/op
ArrayCopyObject.disjoint_micro:branches:u                   8191  thrpt    3   267.182 ±   23.352       #/op
ArrayCopyObject.disjoint_micro:cycles:u                     8191  thrpt    3  3770.776 ± 1545.010       #/op
ArrayCopyObject.disjoint_micro:dTLB-loads:u                 8191  thrpt    3  2261.116 ±   50.406       #/op
ArrayCopyObject.disjoint_micro:dTLB-store-misses:u          8191  thrpt    3     0.011 ±    0.016       #/op
ArrayCopyObject.disjoint_micro:dTLB-stores:u                8191  thrpt    3  2184.226 ±   29.152       #/op
ArrayCopyObject.disjoint_micro:iTLB-load-misses:u           8191  thrpt    3     0.057 ±    0.436       #/op
ArrayCopyObject.disjoint_micro:iTLB-loads:u                 8191  thrpt    3  3759.905 ± 1534.102       #/op
ArrayCopyObject.disjoint_micro:instructions:u               8191  thrpt    3  1480.863 ±  118.388       #/op
ArrayCopyObject.disjoint_micro:stalled-cycles-backend:u     8191  thrpt    3   396.390 ± 1054.563       #/op
ArrayCopyObject.disjoint_micro:stalled-cycles-frontend:u    8191  thrpt    3  3218.591 ± 1539.425       #/op
Finished running test 'micro:org.openjdk.bench.java.lang.ArrayCopyObject'

with this patch:

Benchmark                                                 (size)   Mode  Cnt     Score      Error      Units
ArrayCopyObject.conjoint_micro                              8191  thrpt   12   616.446 ±   20.798     ops/ms
ArrayCopyObject.conjoint_micro:CPI                          8191  thrpt    3     2.120 ±    1.094  clks/insn
ArrayCopyObject.conjoint_micro:IPC                          8191  thrpt    3     0.472 ±    0.242  insns/clk
ArrayCopyObject.conjoint_micro:L1-dcache-load-misses:u      8191  thrpt    3     0.251 ±    1.386       #/op
ArrayCopyObject.conjoint_micro:L1-dcache-loads:u            8191  thrpt    3  2184.269 ± 1359.380       #/op
ArrayCopyObject.conjoint_micro:L1-dcache-store-misses:u     8191  thrpt    3     0.006 ±    0.043       #/op
ArrayCopyObject.conjoint_micro:L1-dcache-stores:u           8191  thrpt    3  2141.624 ± 1374.834       #/op
ArrayCopyObject.conjoint_micro:L1-icache-load-misses:u      8191  thrpt    3     0.070 ±    0.190       #/op
ArrayCopyObject.conjoint_micro:L1-icache-loads:u            8191  thrpt    3  3242.818 ± 4713.124       #/op
ArrayCopyObject.conjoint_micro:branch-misses:u              8191  thrpt    3     1.067 ±    0.521       #/op
ArrayCopyObject.conjoint_micro:branches:u                   8191  thrpt    3   396.447 ±   21.196       #/op
ArrayCopyObject.conjoint_micro:cycles:u                     8191  thrpt    3  3546.340 ± 2001.676       #/op
ArrayCopyObject.conjoint_micro:dTLB-loads:u                 8191  thrpt    3  2184.483 ± 1365.906       #/op
ArrayCopyObject.conjoint_micro:dTLB-store-misses:u          8191  thrpt    3     0.046 ±    0.282       #/op
ArrayCopyObject.conjoint_micro:dTLB-stores:u                8191  thrpt    3  2141.689 ± 1344.038       #/op
ArrayCopyObject.conjoint_micro:iTLB-load-misses:u           8191  thrpt    3     0.080 ±    0.350       #/op
ArrayCopyObject.conjoint_micro:iTLB-loads:u                 8191  thrpt    3  3535.857 ± 1996.573       #/op
ArrayCopyObject.conjoint_micro:instructions:u               8191  thrpt    3  1672.908 ±  103.335       #/op
ArrayCopyObject.conjoint_micro:stalled-cycles-backend:u     8191  thrpt    3   356.269 ±   56.656       #/op
ArrayCopyObject.conjoint_micro:stalled-cycles-frontend:u    8191  thrpt    3  2607.772 ± 1967.460       #/op
ArrayCopyObject.disjoint_micro                              8191  thrpt   12   593.736 ±   20.701     ops/ms
ArrayCopyObject.disjoint_micro:CPI                          8191  thrpt    3     2.596 ±    1.396  clks/insn
ArrayCopyObject.disjoint_micro:IPC                          8191  thrpt    3     0.385 ±    0.207  insns/clk
ArrayCopyObject.disjoint_micro:L1-dcache-load-misses:u      8191  thrpt    3     0.297 ±    0.073       #/op
ArrayCopyObject.disjoint_micro:L1-dcache-loads:u            8191  thrpt    3  2262.918 ±   27.918       #/op
ArrayCopyObject.disjoint_micro:L1-dcache-store-misses:u     8191  thrpt    3     0.008 ±    0.002       #/op
ArrayCopyObject.disjoint_micro:L1-dcache-stores:u           8191  thrpt    3  2183.234 ±   17.175       #/op
ArrayCopyObject.disjoint_micro:L1-icache-load-misses:u      8191  thrpt    3     0.082 ±    0.029       #/op
ArrayCopyObject.disjoint_micro:L1-icache-loads:u            8191  thrpt    3   783.750 ±   83.736       #/op
ArrayCopyObject.disjoint_micro:branch-misses:u              8191  thrpt    3     0.083 ±    0.107       #/op
ArrayCopyObject.disjoint_micro:branches:u                   8191  thrpt    3   268.309 ±    3.777       #/op
ArrayCopyObject.disjoint_micro:cycles:u                     8191  thrpt    3  3689.134 ± 1978.110       #/op
ArrayCopyObject.disjoint_micro:dTLB-loads:u                 8191  thrpt    3  2262.315 ±   12.862       #/op
ArrayCopyObject.disjoint_micro:dTLB-store-misses:u          8191  thrpt    3     0.074 ±    0.218       #/op
ArrayCopyObject.disjoint_micro:dTLB-stores:u                8191  thrpt    3  2182.850 ±   18.595       #/op
ArrayCopyObject.disjoint_micro:iTLB-load-misses:u           8191  thrpt    3     0.102 ±    0.104       #/op
ArrayCopyObject.disjoint_micro:iTLB-loads:u                 8191  thrpt    3  3677.326 ± 1991.190       #/op
ArrayCopyObject.disjoint_micro:instructions:u               8191  thrpt    3  1421.135 ±    2.488       #/op
ArrayCopyObject.disjoint_micro:stalled-cycles-backend:u     8191  thrpt    3   239.125 ±  974.147       #/op
ArrayCopyObject.disjoint_micro:stalled-cycles-frontend:u    8191  thrpt    3  3133.978 ± 1983.534       #/op
Finished running test 'micro:org.openjdk.bench.java.lang.ArrayCopyObject'


Progress

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

Issue

  • JDK-8388837: RISC-V: Track card addresses directly in G1 array post-write barrier loop (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 32020

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper

bridgekeeper Bot commented Jul 23, 2026

Copy link
Copy Markdown

👋 Welcome back gcao! 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

openjdk Bot commented Jul 23, 2026

Copy link
Copy Markdown

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

8388837: RISC-V: Track card addresses directly in G1 array post-write barrier loop

Reviewed-by: ayang, fyang

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 24 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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@albertnetymk, @RealFYang) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk Bot added the hotspot hotspot-dev@openjdk.org label Jul 23, 2026
@openjdk

openjdk Bot commented Jul 23, 2026

Copy link
Copy Markdown

@zifeihan 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 commented Jul 23, 2026

Copy link
Copy Markdown

The total number of required reviews for this PR has been set to 2 based on the presence of this label: hotspot. This can be overridden with the /reviewers command.

@zifeihan
zifeihan marked this pull request as ready for review July 23, 2026 10:19
@openjdk openjdk Bot added the rfr Pull request is ready for review label Jul 23, 2026
@mlbridge

mlbridge Bot commented Jul 23, 2026

Copy link
Copy Markdown

Webrevs

@albertnetymk albertnetymk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good.

(For consistency, could we increment start, as x86 does, instead of decrementing the end address?)

@albertnetymk

Copy link
Copy Markdown
Member

/cc hotspot-gc

@openjdk openjdk Bot added the hotspot-gc hotspot-gc-dev@openjdk.org label Jul 23, 2026
@openjdk

openjdk Bot commented Jul 23, 2026

Copy link
Copy Markdown

@albertnetymk
The hotspot-gc label was successfully added.

@zifeihan

Copy link
Copy Markdown
Member Author

Looks good.

(For consistency, could we increment start, as x86 does, instead of decrementing the end address?)

@albertnetymk Thanks for your review, Fixed.

__ subi(count, count, 1);
__ bgez(count, loop);
__ addi(start, start, 1);
__ bge(count, start, loop);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggestion: __ ble(start, count, loop);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Suggestion: __ ble(start, count, loop);

Fixed

@RealFYang RealFYang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Updated change looks fine to me. Thanks.

@openjdk openjdk Bot added the ready Pull request is ready to be integrated label Jul 25, 2026
@zifeihan

Copy link
Copy Markdown
Member Author

Thanks all for the review.
/integrate

@openjdk openjdk Bot added the sponsor Pull request is ready to be sponsored label Jul 26, 2026
@openjdk

openjdk Bot commented Jul 26, 2026

Copy link
Copy Markdown

@zifeihan
Your change (at version 4c7307e) is now ready to be sponsored by a Committer.

@DingliZhang

Copy link
Copy Markdown
Member

/sponsor

@openjdk

openjdk Bot commented Jul 27, 2026

Copy link
Copy Markdown

Going to push as commit e8fdd54.
Since your change was applied there have been 26 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 Jul 27, 2026
@openjdk openjdk Bot closed this Jul 27, 2026
@openjdk openjdk Bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jul 27, 2026
@openjdk openjdk Bot removed the sponsor Pull request is ready to be sponsored label Jul 27, 2026
@openjdk

openjdk Bot commented Jul 27, 2026

Copy link
Copy Markdown

@DingliZhang @zifeihan Pushed as commit e8fdd54.

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

@zifeihan
zifeihan deleted the JDK-8388837 branch July 27, 2026 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Development

Successfully merging this pull request may close these issues.

4 participants