RFR: 8347009: Speed up parseInt and parseLong [v11]
Shaojin Wen
swen at openjdk.org
Thu Jan 30 05:36:56 UTC 2025
On Wed, 29 Jan 2025 18:47:25 GMT, Johannes Graham <duke at openjdk.org> wrote:
>> Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision:
>>
>> copyright
>
> src/java.base/share/classes/jdk/internal/util/DecimalDigits.java line 181:
>
>> 179: return -1;
>> 180: }
>> 181: return ((d & 0xF) << 3) + ((d & 0xF) << 1) // (d & 0xF) * 10
>
> Is simply using `(d & 0xF) * 10` any worse? I expect the compiler knows this trick and would use it when appropriate.
The performance results are identical across x64 and AArch64 platforms.
## 1. Script
git remote add wenshao git at github.com:wenshao/jdk.git
git fetch wenshao
#baseline (shift)
git checkout 0b04a70609b3195aca6481c6f1c88b27c872a65b
make test TEST="micro:java.lang.Longs.parseLong"
# current (muliti 10)
git checkout a6d9846809d6213fd70e852773ff2f57b5bf0201
make test TEST="micro:java.lang.Longs.parseLong"
## 2. MacBook M1 Pro (aarch64)
Benchmark (size) Mode Cnt Score Error Units (0b04a70609b)
Longs.parseLong 500 avgt 15 2.237 ? 0.029 us/op
Benchmark (size) Mode Cnt Score Error Units (a6d9846809d)
Longs.parseLong 500 avgt 15 2.225 ? 0.021 us/op
## 3. aliyun_ecs_c8a_x64 (CPU AMD EPYC™ Genoa)
Benchmark (size) Mode Cnt Score Error Units (0b04a70609b)
Longs.parseLong 500 avgt 15 2.920 ± 0.018 us/op
Benchmark (size) Mode Cnt Score Error Units (a6d9846809d)
Longs.parseLong 500 avgt 15 2.912 ± 0.020 us/op
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22919#discussion_r1935027236
More information about the core-libs-dev
mailing list