RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v2]
Claes Redestad
redestad at openjdk.org
Sun Oct 6 15:14:06 UTC 2024
On Sun, 6 Oct 2024 14:40:37 GMT, Chen Liang <liach at openjdk.org> wrote:
>> Claes Redestad has updated the pull request incrementally with one additional commit since the last revision:
>>
>> copyright
>
> src/java.base/share/classes/java/util/zip/ZipUtils.java line 175:
>
>> 173: public static final int get16(byte[] b, int off) {
>> 174: Preconditions.checkIndex(off, b.length, Preconditions.AIOOBE_FORMATTER);
>> 175: Preconditions.checkIndex(off + 1, b.length, Preconditions.AIOOBE_FORMATTER);
>
> Please use `Preconditions.checkFromIndexSize`, which should be less overhead:
> Suggestion:
>
> Preconditions.checkFromIndexSize(off, 2, b.length, Preconditions.AIOOBE_FORMATTER);
>
> Similarly for other methods.
It's actually not less overhead in my tests, since `checkIndex` is intrinsic and mostly disappears, while with `checkFromIndexSize` performance gets significantly worse (on par with baseline). It's on my todo to investigate this in-depth but I think `checkFromIndexSize` needs to be given similar intrinsification treatment as `checkIndex`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21377#discussion_r1789126101
More information about the core-libs-dev
mailing list