Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v4]

2024-10-08 Thread Claes Redestad
On Tue, 8 Oct 2024 01:14:32 GMT, Chen Liang wrote: >> src/java.base/share/classes/java/util/zip/ZipUtils.java line 173: >> >>> 171: * The bytes are assumed to be in Intel (little-endian) byte order. >>> 172: */ >>> 173: public static final int get16(byte[] b, int off) { >> >> Can

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v4]

2024-10-07 Thread Chen Liang
On Tue, 8 Oct 2024 01:05:14 GMT, Shaojin Wen wrote: >> Claes Redestad has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Rename get64 -> get64S > > src/java.base/share/classes/java/util/zip/ZipUtils.java line 173: > >> 171: * The byte

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v4]

2024-10-07 Thread Shaojin Wen
On Sun, 6 Oct 2024 21:45:08 GMT, Claes Redestad wrote: >> #14632 showed that coalescing loads in the `ZipUtils` utility methods could >> improve performance in zip-related microbenchmarks, but doing so would >> increase startup overheads. Progress was stalled as we backed out some >> related e

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v4]

2024-10-07 Thread Lance Andersen
On Sun, 6 Oct 2024 21:45:08 GMT, Claes Redestad wrote: >> #14632 showed that coalescing loads in the `ZipUtils` utility methods could >> improve performance in zip-related microbenchmarks, but doing so would >> increase startup overheads. Progress was stalled as we backed out some >> related e

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v2]

2024-10-07 Thread Eirik Bjørsnøs
On Sun, 6 Oct 2024 21:49:08 GMT, Claes Redestad wrote: >>> How would you model unsigned long values here, though? >> >> I don't think we should. `9223372036854775807 ` should be enough for >> everyone :-) >> >> It may be worth renaming the method to `get64S` and add a `get64` variant >> which

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v2]

2024-10-06 Thread Claes Redestad
On Sun, 6 Oct 2024 19:33:49 GMT, Eirik Bjørsnøs wrote: >> As it's a pre-existing issue I'd prefer to keep this one focused on the >> switch-over. How would you model unsigned long values here, though? Sure we >> could read into a `BigInteger` or accept negative values, but to really >> support

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v4]

2024-10-06 Thread Claes Redestad
> #14632 showed that coalescing loads in the `ZipUtils` utility methods could > improve performance in zip-related microbenchmarks, but doing so would > increase startup overheads. Progress was stalled as we backed out some > related early use of `ByteArray(LittleEndian)` and started exploring m

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v2]

2024-10-06 Thread Eirik Bjørsnøs
On Sun, 6 Oct 2024 19:19:15 GMT, Claes Redestad wrote: > How would you model unsigned long values here, though? I don't think we should. `9223372036854775807 ` should be enough for everyone :-) It may be worth renaming the method to `get64S` and add a `get64` variant which either clamps at `L

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v3]

2024-10-06 Thread Claes Redestad
On Sun, 6 Oct 2024 15:48:57 GMT, Eirik Bjørsnøs 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 cak

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v2]

2024-10-06 Thread Claes Redestad
On Sun, 6 Oct 2024 15:53:55 GMT, Eirik Bjørsnøs 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 195: > >> 193: * The bytes are assu

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v3]

2024-10-06 Thread Claes Redestad
On Sun, 6 Oct 2024 16:27:52 GMT, Chen Liang wrote: >> test/micro/org/openjdk/bench/java/util/zip/ZipFileOpen.java line 110: >> >>> 108: zf2.close(); >>> 109: } >>> 110: >> >> A short comment stating the purpose of the main method would not hurt. > > https://github.com/openjdk/jdk/p

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v3]

2024-10-06 Thread Claes Redestad
> #14632 showed that coalescing loads in the `ZipUtils` utility methods could > improve performance in zip-related microbenchmarks, but doing so would > increase startup overheads. Progress was stalled as we backed out some > related early use of `ByteArray(LittleEndian)` and started exploring m

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v2]

2024-10-06 Thread Chen Liang
On Sun, 6 Oct 2024 15:27:07 GMT, Eirik Bjørsnøs wrote: >> Claes Redestad has updated the pull request incrementally with one >> additional commit since the last revision: >> >> copyright > > test/micro/org/openjdk/bench/java/util/zip/ZipFileOpen.java line 110: > >> 108: zf2.close();

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v2]

2024-10-06 Thread Claes Redestad
On Sun, 6 Oct 2024 14:56:27 GMT, Eirik Bjørsnøs 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/ZipFile.java line 1644: > >> 1642: // Now s

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v2]

2024-10-06 Thread Chen Liang
On Sun, 6 Oct 2024 15:48:57 GMT, Eirik Bjørsnøs 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 cak

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v2]

2024-10-06 Thread Eirik Bjørsnøs
On Sun, 6 Oct 2024 15:14:05 GMT, Claes Redestad wrote: >> #14632 showed that coalescing loads in the `ZipUtils` utility methods could >> improve performance in zip-related microbenchmarks, but doing so would >> increase startup overheads. Progress was stalled as we backed out some >> related e

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v2]

2024-10-06 Thread Eirik Bjørsnøs
On Sun, 6 Oct 2024 15:35:44 GMT, Claes Redestad wrote: >> Actually if we trust the input index to be nonnegative, we can just check >> our end index for out of bounds too. > > Sure, I think the JIT is pretty good at eliminating the (intrinsic) > `checkIndex` calls when they are redundant though

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v2]

2024-10-06 Thread Claes Redestad
On Sun, 6 Oct 2024 15:29:13 GMT, Eirik Bjørsnøs 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 258: > >> 256: static final long CEN

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v2]

2024-10-06 Thread Eirik Bjørsnøs
On Sun, 6 Oct 2024 15:14:05 GMT, Claes Redestad wrote: >> #14632 showed that coalescing loads in the `ZipUtils` utility methods could >> improve performance in zip-related microbenchmarks, but doing so would >> increase startup overheads. Progress was stalled as we backed out some >> related e

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v2]

2024-10-06 Thread Eirik Bjørsnøs
On Sun, 6 Oct 2024 15:14:05 GMT, Claes Redestad wrote: >> #14632 showed that coalescing loads in the `ZipUtils` utility methods could >> improve performance in zip-related microbenchmarks, but doing so would >> increase startup overheads. Progress was stalled as we backed out some >> related e

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v2]

2024-10-06 Thread Claes Redestad
On Sun, 6 Oct 2024 15:11:19 GMT, Chen Liang wrote: >> 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

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v2]

2024-10-06 Thread Chen Liang
On Sun, 6 Oct 2024 15:07:02 GMT, Claes Redestad wrote: >> 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:

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v2]

2024-10-06 Thread Claes Redestad
> #14632 showed that coalescing loads in the `ZipUtils` utility methods could > improve performance in zip-related microbenchmarks, but doing so would > increase startup overheads. Progress was stalled as we backed out some > related early use of `ByteArray(LittleEndian)` and started exploring m

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils [v2]

2024-10-06 Thread Claes Redestad
On Sun, 6 Oct 2024 14:40:37 GMT, Chen Liang 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 g

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils

2024-10-06 Thread Eirik Bjørsnøs
On Sun, 6 Oct 2024 14:16:44 GMT, Claes Redestad wrote: > #14632 showed that coalescing loads in the `ZipUtils` utility methods could > improve performance in zip-related microbenchmarks, but doing so would > increase startup overheads. Progress was stalled as we backed out some > related early

Re: RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils

2024-10-06 Thread Chen Liang
On Sun, 6 Oct 2024 14:16:44 GMT, Claes Redestad wrote: > #14632 showed that coalescing loads in the `ZipUtils` utility methods could > improve performance in zip-related microbenchmarks, but doing so would > increase startup overheads. Progress was stalled as we backed out some > related early

RFR: 8341594: Use Unsafe to coalesce reads in java.util.zip.ZipUtils

2024-10-06 Thread Claes Redestad
#14632 showed that coalescing loads in the `ZipUtils` utility methods could improve performance in zip-related microbenchmarks, but doing so would increase startup overheads. Progress was stalled as we backed out some related early use of `ByteArray(LittleEndian)` and started exploring merge sto