RFR: 8340571: Outline code from the loop in ZipFile.Source.initCen [v3]

Eirik Bjørsnøs eirbjo at openjdk.org
Wed Sep 25 19:07:34 UTC 2024


On Wed, 25 Sep 2024 13:43:49 GMT, Claes Redestad <redestad at openjdk.org> wrote:

>> This PR suggests refactoring `ZipFile.Source.initCEN` to move as much logic as possible into the per-entry method processor. This inner method will be called often and JIT optimized earlier in the bootstrap sequence.
>> 
>> Startup tests using the OpenJDK benchmarks.jar show a ~1ms improvement on both my M1 macbook and my x64 wokstation, while we also improve on relevant throughput microbenchmarks:
>> 
>> 
>> Name               (size) Cnt       Base      Error        Test      Error  Unit  Change
>> openCloseZipFile      512  15  61372.449 ± 1197.432   58081.423 ± 1751.988 ns/op   1.06x (p = 0.000*)
>> openCloseZipFile     1024  15 117953.727 ± 3202.274  112548.875 ± 5126.665 ns/op   1.05x (p = 0.001*)
>> openCloseZipFilex2    512  15  62141.795 ±  674.121   60520.017 ± 2438.346 ns/op   1.03x (p = 0.017 )
>> openCloseZipFilex2   1024  15 117959.071 ± 1528.426  111773.937 ± 1604.412 ns/op   1.06x (p = 0.000*)
>>   * = significant
>
> Claes Redestad has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Typo

There is a lot going on in this PR..

I've been playing with similar, but different ideas lately and I'm wondering if we could get away with less intrusive changes and still boost performance. 

Instead of pushing everything into `processNextCENEntry`, how about we instead extract methods for checking the fixed-length CEN header and for checking the variable-length CEN header fields (headerSize, extra and comment)?

Here's a sketch of what I'm thinking: https://github.com/openjdk/jdk/compare/master...eirbjo:initCEN-extract-validation?expand=0

This PR:


Benchmark                       (size)  Mode  Cnt       Score      Error  Units
ZipFileOpen.openCloseZipFile       512  avgt   15  104987.960 ? 4191.855  ns/op
ZipFileOpen.openCloseZipFile      1024  avgt   15  172605.991 ? 3546.599  ns/op
ZipFileOpen.openCloseZipFilex2     512  avgt   15  113737.426 ? 5797.246  ns/op
ZipFileOpen.openCloseZipFilex2    1024  avgt   15  189276.928 ? 3195.026  ns/op

  
My branch 


Benchmark                       (size)  Mode  Cnt       Score      Error  Units
ZipFileOpen.openCloseZipFile       512  avgt   15  100435.644 ? 2862.724  ns/op
ZipFileOpen.openCloseZipFile      1024  avgt   15  165181.306 ? 2445.885  ns/op
ZipFileOpen.openCloseZipFilex2     512  avgt   15  103644.570 ? 1615.982  ns/op
ZipFileOpen.openCloseZipFilex2    1024  avgt   15  170362.938 ? 3421.632  ns/op

-------------

PR Comment: https://git.openjdk.org/jdk/pull/21133#issuecomment-2374942705


More information about the core-libs-dev mailing list