RFR: 8347009: Speed up parseInt and parseLong [v24]
Raffaello Giulietti
rgiulietti at openjdk.org
Thu Dec 4 14:49:27 UTC 2025
On Thu, 4 Dec 2025 14:42:32 GMT, Shaojin Wen <swen at openjdk.org> wrote:
>> Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision:
>>
>> remove unsafe
>
> 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.parseInt 500 avgt 15 2.244 ± 0.010 us/op
> Longs.parseLong 500 avgt 15 2.432 ± 0.033 us/op
>
>
> * Comparison
>
> | benchmark |...
Thanks @wenshao for trying out without making use of `Unsafe`!
I'll have another look sometimes next week.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/22919#issuecomment-3612606581
More information about the core-libs-dev
mailing list