RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v3]
Claes Redestad
redestad at openjdk.org
Sun Oct 6 19:27:33 UTC 2024
On Sun, 6 Oct 2024 15:48:57 GMT, Eirik Bjørsnøs <eirbjo at openjdk.org> wrote:
>> Sure, I think the JIT is pretty good at eliminating the (intrinsic) `checkIndex` calls when they are redundant though. Performance with and without these `checkIndex`es are the same in my testing, so we can eat and have the cake on this one.
>>
>> FWIW I wouldn't mind giving similar treatment to `ByteArray(-LittleEndian)` and avoid the `VarHandles` dependency in those utility classes, but I have no urge to get into the sort of discussions that were spawned in #19616
>
>> Actually if we trust the input index to be nonnegative, we can just check our end index for out of bounds too.
>
> I would not trust that. Perhaps for well-formed ZIP files, but trust me, not all ZIPs are well-formed ;-)
Like @eirbjo suggests we'd have to put a lot of validation in other places if we went down this route. Regardless this is an academic discussion since the PR suggests the safe route and we don't pay much of a cost for that in microbenchmarks.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21377#discussion_r1789217693
More information about the core-libs-dev
mailing list