RFR: 8349556: RISC-V: improve the performance when -COH and -AvoidUnalignedAccesses for UL and LU string comparison
Hamlin Li
mli at openjdk.org
Thu Feb 6 16:03:21 UTC 2025
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
-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 | 2 | 128 | N/A | avgt | 10 | 32078969.29 | 29532674.32 | 26556.277 | ns/op | 0.086
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 256 | N/A | avgt | 10 | 60265969.7 | 56586871.09 | 137156.033 | ns/op | 0.065
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 512 | N/A | avgt | 10 | 116892685.5 | 111266086.7 | 106542.956 | ns/op | 0.051
</google-sheets-html-origin>
+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 | 6384145.1 | 6386249.278 | 1018.737 | ns/op | 0
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToLU | 2 | 36 | N/A | avgt | 10 | 9484748.389 | 9437921.504 | 25184.962 | ns/op | 0.005
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToLU | 2 | 72 | N/A | avgt | 10 | 18648808.89 | 17610658.36 | 3613.01 | ns/op | 0.059
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToLU | 2 | 128 | N/A | avgt | 10 | 31130870.72 | 30542644.4 | 136527.281 | ns/op | 0.019
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToLU | 2 | 256 | N/A | avgt | 10 | 58943258.88 | 59678929.13 | 9247.37 | ns/op | -0.012
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToLU | 2 | 512 | N/A | avgt | 10 | 115515196.6 | 118941406.1 | 30104.94 | ns/op | -0.029
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 24 | N/A | avgt | 10 | 7640264.164 | 7691120.134 | 8941.255 | ns/op | -0.007
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 36 | N/A | avgt | 10 | 10568117.17 | 10540680.16 | 11225.744 | ns/op | 0.003
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 72 | N/A | avgt | 10 | 19727550.52 | 18982109.53 | 8609.764 | ns/op | 0.039
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 128 | N/A | avgt | 10 | 32125836.11 | 31006763.12 | 13915.357 | ns/op | 0.036
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 256 | N/A | avgt | 10 | 60202330.54 | 59561746.17 | 15817.383 | ns/op | 0.011
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 512 | N/A | avgt | 10 | 116636087.8 | 117264697.5 | 19632.92 | ns/op | -0.005
</google-sheets-html-origin>
-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 | 7885819.391 | 7886391.597 | 1238.502 | ns/op | 0
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToLU | 2 | 36 | N/A | avgt | 10 | 10889126.89 | 10891175.03 | 1399.179 | ns/op | 0
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToLU | 2 | 72 | N/A | avgt | 10 | 16897052.9 | 16774972.05 | 2609.977 | ns/op | 0.007
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToLU | 2 | 128 | N/A | avgt | 10 | 28922269.1 | 28478100.28 | 66442.357 | ns/op | 0.016
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToLU | 2 | 256 | N/A | avgt | 10 | 56180868.95 | 55517886.54 | 48061.692 | ns/op | 0.012
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToLU | 2 | 512 | N/A | avgt | 10 | 110907025.6 | 110201411.8 | 65541.488 | ns/op | 0.006
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 24 | N/A | avgt | 10 | 9160226.336 | 9053922.422 | 30162.696 | ns/op | 0.012
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 36 | N/A | avgt | 10 | 11858619.51 | 11875124.68 | 30883.529 | ns/op | -0.001
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 72 | N/A | avgt | 10 | 18145983.4 | 17975971.55 | 42989.862 | ns/op | 0.009
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 128 | N/A | avgt | 10 | 30239261.15 | 29550149 | 93379.637 | ns/op | 0.023
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 256 | N/A | avgt | 10 | 57340601.37 | 56598661.49 | 63235.889 | ns/op | 0.013
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 512 | N/A | avgt | 10 | 111847228.7 | 111826244.4 | 30457.378 | ns/op | 0
</google-sheets-html-origin>
+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 | 8824614.771 | 8879669.558 | 1136.78 | ns/op | -0.006
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToLU | 2 | 36 | N/A | avgt | 10 | 12453700.16 | 12452977.94 | 2412.16 | ns/op | 0
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToLU | 2 | 72 | N/A | avgt | 10 | 24742973.85 | 24723425.63 | 46396.337 | ns/op | 0.001
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToLU | 2 | 128 | N/A | avgt | 10 | 39673249.81 | 39681763.05 | 10340.791 | ns/op | 0
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToLU | 2 | 256 | N/A | avgt | 10 | 74004446.14 | 73731397.09 | 29337.751 | ns/op | 0.004
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToLU | 2 | 512 | N/A | avgt | 10 | 142806141.5 | 142275494.2 | 52159.737 | ns/op | 0.004
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 24 | N/A | avgt | 10 | 9935969.372 | 10045152.69 | 70155.123 | ns/op | -0.011
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 36 | N/A | avgt | 10 | 13255244.36 | 13280685.46 | 68940.937 | ns/op | -0.002
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 72 | N/A | avgt | 10 | 25848901.97 | 25887363.77 | 16178.629 | ns/op | -0.001
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 128 | N/A | avgt | 10 | 40859613.95 | 40908567.84 | 54621.931 | ns/op | -0.001
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 256 | N/A | avgt | 10 | 74853691.65 | 74878469.62 | 31639.587 | ns/op | 0
com.arm.benchmarks.intrinsics.StringCompareToDifferentLength.compareToUL | 2 | 512 | N/A | avgt | 10 | 143431358.1 | 143495718.8 | 60271.214 | ns/op | 0
</google-sheets-html-origin>
-------------
Commit messages:
- initial commit
Changes: https://git.openjdk.org/jdk/pull/23495/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=23495&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8349556
Stats: 20 lines in 2 files changed: 4 ins; 15 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/23495.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/23495/head:pull/23495
PR: https://git.openjdk.org/jdk/pull/23495
More information about the hotspot-compiler-dev
mailing list