RFR: 8350093: RISC-V: java/math/BigInteger/LargeValueExceptions.java timeout with COH

Fei Yang fyang at openjdk.org
Fri Feb 14 16:03:10 UTC 2025


On Fri, 14 Feb 2025 14:50:14 GMT, Hamlin Li <mli at openjdk.org> wrote:

>> Hi, please review this change resolving a timeout issue in `LargeValueExceptions.squareDefiniteOverflow()`.
>> 
>> This issue only happens on platforms with slow unaligned memory accesses like Unmatched or Premier-P550 SBCs.
>> Async profiler shows major time was spent in multiplyToLen stub code. When AvoidUnalignedAccesses is enabled,
>> there is a simple alignment check, which assumes 8-byte alignment for base_offset of int arrays. But this is
>> not the case with COH: base_offset is 12 bytes instead of 16 bytes for int arrays.
>> 
>> Patch simply makes it explicit about the requirement of base_offset. Sanity tested on Premier P550.
>> No obvious change witnessed on JMH after this change:
>> 
>> -----------------------------------------------------------------------------------------------
>> 
>> Without COH:
>> 
>> Benchmark                               (maxNumbits)  Mode  Cnt        Score      Error  Units
>> BigIntegers.SmallShifts.testLeftShift             32  avgt   15      138.939 ±    2.246  ns/op
>> BigIntegers.SmallShifts.testLeftShift            128  avgt   15       88.391 ±    1.210  ns/op
>> BigIntegers.SmallShifts.testLeftShift            256  avgt   15      117.590 ±    1.398  ns/op
>> BigIntegers.SmallShifts.testRightShift            32  avgt   15      150.338 ±    1.961  ns/op
>> BigIntegers.SmallShifts.testRightShift           128  avgt   15      104.540 ±    5.636  ns/op
>> BigIntegers.SmallShifts.testRightShift           256  avgt   15      126.082 ±    1.756  ns/op
>> BigIntegers.testAdd                              N/A  avgt   15       97.513 ±   40.746  ns/op
>> BigIntegers.testGcd                              N/A  avgt   15  5409222.706 ± 5934.667  ns/op
>> BigIntegers.testHugeLargeDivide                  N/A  avgt   15      246.904 ±    1.552  ns/op
>> BigIntegers.testHugeSmallDivide                  N/A  avgt   15      248.997 ±    1.374  ns/op
>> BigIntegers.testHugeToString                     N/A  avgt   15     2421.432 ±   62.208  ns/op
>> BigIntegers.testLargeSmallDivide                 N/A  avgt   15      216.859 ±    1.760  ns/op
>> BigIntegers.testLargeToString                    N/A  avgt   15      425.653 ±   13.305  ns/op
>> BigIntegers.testLeftShift                        N/A  avgt   15     2265.137 ±   24.319  ns/op
>> BigIntegers.testMultiply                         N/A  avgt   15    15862.412 ±  417.880  ns/op <========
>> BigIntegers.testRightShift                       N/A  avgt   15      936.071 ±   15.247  ns/op
>> BigIntegers.testSmallTo...
>
> src/hotspot/cpu/riscv/macroAssembler_riscv.cpp line 5486:
> 
>> 5484:   const Register jdx = tmp1;
>> 5485: 
>> 5486:   if (AvoidUnalignedAccesses) {
> 
> If `AvoidUnalignedAccesses == false`, it will go through all alignment code? But seems original code will not go through this alignment when `AvoidUnalignedAccesses == false`.

Hi, not sure if I understand the question correctly. This only affects platforms where `AvoidUnalignedAccesses` is true.
It does not make a difference on platforms with fast misaligned accesses (which means `AvoidUnalignedAccesses == false`).

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/23631#discussion_r1956379043


More information about the hotspot-dev mailing list