RFR: 8349556: RISC-V: improve the performance when -COH and -AvoidUnalignedAccesses for UL and LU string comparison
Fei Yang
fyang at openjdk.org
Fri Feb 7 11:11:10 UTC 2025
On Thu, 6 Feb 2025 15:59:16 GMT, Hamlin Li <mli at openjdk.org> wrote:
> Hi,
>
> Can you help to review the patch?
>
> It tries to improve the string compare when AvoidUnalignedAccesses == false && encoding is LU or UL (i.e. 2 strings encodings are different with each other).
> The jmh test shows when `-CompactObjectHeaders` (i.e. -COH) && `-AvoidUnalignedAccesses`, the patch bring much better performance, and in other cases, it does not bring obvious regression. And currently by default it's -COH.
>
> Thanks
>
> ### Performance
>
> it's run on bananapi.
>
> -COH-AvoidUnalignedAccesses
> <google-sheets-html-origin style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
> “-COH-Avoid” | (delta) | (size) | (utf16) | Mode | Cnt | Score - master | Score - patch | Error | Units | Improvement
> -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | --
> com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToLU | 2 | 24 | N/A | avgt | 10 | 6438443.073 | 6383881.891 | 36912.539 | ns/op | 0.009
> com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToLU | 2 | 36 | N/A | avgt | 10 | 9421176.34 | 9390907.1 | 21034.266 | ns/op | 0.003
> com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToLU | 2 | 72 | N/A | avgt | 10 | 18592342.33 | 16871350.38 | 15550.827 | ns/op | 0.102
> com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToLU | 2 | 128 | N/A | avgt | 10 | 30916157.05 | 28646961.11 | 9263.556 | ns/op | 0.079
> com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToLU | 2 | 256 | N/A | avgt | 10 | 58945069.17 | 55505097.77 | 8803.847 | ns/op | 0.062
> com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToLU | 2 | 512 | N/A | avgt | 10 | 115520355.5 | 110233842.8 | 35056.972 | ns/op | 0.048
> com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 24 | N/A | avgt | 10 | 7541299.83 | 7481385.995 | 43240.713 | ns/op | 0.008
> com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 36 | N/A | avgt | 10 | 10295051.77 | 10264978.04 | 38938.956 | ns/op | 0.003
> com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 72 | N/A | avgt | 10 | 19652419.64 | 17953481.41 | 10987.17 | ns/op | 0.095
> com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL ...
Marked as reviewed by fyang (Reviewer).
src/hotspot/cpu/riscv/stubGenerator_riscv.cpp line 2529:
> 2527:
> 2528: if (AvoidUnalignedAccesses && (base_offset1 % 8) != 0) {
> 2529: // Load another 4 bytes from strL to make sure main loop is 8-byte aligned
Nit: You might want to update this code comment removing the word `another`.
`// Load another 4 bytes from strL to make sure main loop is 8-byte aligned`
=>
`// Load 4 bytes from strL to make sure main loop is 8-byte aligned`
-------------
PR Review: https://git.openjdk.org/jdk/pull/23495#pullrequestreview-2601459963
PR Review Comment: https://git.openjdk.org/jdk/pull/23495#discussion_r1946363699
More information about the hotspot-compiler-dev
mailing list