RFR: 8347009: Speed up parseInt and parseLong [v24]
Shaojin Wen
swen at openjdk.org
Thu Jan 22 06:34:33 UTC 2026
On Thu, 4 Dec 2025 14:47:05 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:
>> In my latest implementation, I removed `Unsafe` from the `DecimalDigits::digit2` method, which resulted in a performance decrease, but it's still better than the master branch. Below are my performance tests on x64 and aarch64:
>>
>>
>> # 1. Test Script
>>
>> git remote add wenshao git at github.com:wenshao/jdk.git
>> git fetch wenshao
>>
>> # base (master banch)
>> git checkout 9ea0dcd3eaf07658aeb92ba0defb5098e1f7b192
>> make test TEST="micro:java.lang.Longs.parseLong"
>> make test TEST="micro:java.lang.Integers.parseInt"
>>
>> # Digit2 (current)
>> git checkout cebefd7b89f2dbf29bb13c4903060707a5574e67
>> make test TEST="micro:java.lang.Longs.parseLong"
>> make test TEST="micro:java.lang.Integers.parseInt"
>>
>> # Digit2_Unsafe (before)
>> git checkout c58aa7071867f386407f33defe2b346176fc1e91
>> make test TEST="micro:java.lang.Longs.parseLong"
>> make test TEST="micro:java.lang.Integers.parseInt"
>>
>>
>> # 2. Performance Results on MacBook M1 Pro
>>
>> * Raw Data
>>
>> # base
>> Benchmark (size) Mode Cnt Score Error Units
>> Integers.parseInt 500 avgt 15 2.371 ± 0.012 us/op
>> Longs.parseLong 500 avgt 15 2.731 ± 0.030 us/op
>>
>> # digit2
>> Benchmark (size) Mode Cnt Score Error Units
>> Integers.parseInt 500 avgt 15 2.221 ± 0.009 us/op
>> Longs.parseLong 500 avgt 15 2.517 ± 0.016 us/op
>>
>> # digit2_unsafe
>> Benchmark (size) Mode Cnt Score Error Units
>> Integers.parseInt 500 avgt 15 2.114 ± 0.012 us/op
>> Longs.parseLong 500 avgt 15 2.344 ± 0.028 us/op
>>
>>
>> * Comparison
>>
>> | Benchmark | base | Digit2 | Digit2_Unsafe | base vs Digit2 (%) | Digit2 vs Digit2_Unsafe (%) |
>> |-----------|--------|--------|---------------|----------------------|------------------------------|
>> | Integers.parseInt | 2.371 | 2.221 | 2.114 | +6.33% | +4.82% |
>> | Longs.parseLong | 2.731 | 2.517 | 2.344 | +7.84% | +6.87% |
>>
>>
>> # 3. Performance Results on Aliyun_ECS_c9a (x64, AMD AMD EPYC™ Turin)
>>
>> * Row Data
>>
>> # base
>> Benchmark (size) Mode Cnt Score Error Units
>> Integers.parseInt 500 avgt 15 2.541 ± 0.022 us/op
>> Longs.parseLong 500 avgt 15 2.941 ± 0.014 us/op
>>
>> # digit2
>> Benchmark (size) Mode Cnt Score Error Units
>> Integers.parseInt 500 avgt 15 2.542 ± 0.003 us/op
>> Longs.parseLong 500 avgt 15 2.527 ± 0.014 us/op
>>
>> # digit2_unsafe
>> Benchmark (size) Mode Cnt Score Error Units
>> Integers....
>
> Thanks @wenshao for trying out without making use of `Unsafe`!
> I'll have another look sometimes next week.
@rgiulietti Is there any progress on this PR?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/22919#issuecomment-3782733867
More information about the core-libs-dev
mailing list