RFR: 8317678: Fix up hashCode() for ZipFile.Source.Key [v6]

Sean Coffey coffeys at openjdk.org
Tue Oct 17 19:58:49 UTC 2023


On Tue, 17 Oct 2023 19:55:19 GMT, Sean Coffey <coffeys at openjdk.org> wrote:

>> Fix up java.util.zip.ZipFile$Source hashCode() impl so that duplicate Source objects aren't created for the same zip file.
>
> Sean Coffey has updated the pull request incrementally with one additional commit since the last revision:
> 
>   remove getCanonicalFile calls, update ZipFile jmh benchmark test, tidy up junit test

Removed the `getCanonicalFile `calls. The patch now optimizes the case where fileKey() is supported. Updated the ZipFileOpen.java benchmark test case also. before and after benchmark results for linux and windows posted below


linux:
without patch:

Benchmark                       (size)  Mode  Cnt       Score       Error  Units
ZipFileOpen.openCloseZipFile       512  avgt   15   75378.890 ?   642.370  ns/op
ZipFileOpen.openCloseZipFile      1024  avgt   15  150814.293 ? 29801.424  ns/op
ZipFileOpen.openCloseZipFilex2     512  avgt   15  168104.286 ? 41505.778  ns/op
ZipFileOpen.openCloseZipFilex2    1024  avgt   15  299282.488 ? 44496.777  ns/op
Finished running test 'micro:java.util.zip.ZipFileOpen'

with patch
Benchmark                       (size)  Mode  Cnt       Score       Error  Units
ZipFileOpen.openCloseZipFile       512  avgt   15   82715.346 ? 21700.950  ns/op
ZipFileOpen.openCloseZipFile      1024  avgt   15  142253.235 ?  1054.553  ns/op
ZipFileOpen.openCloseZipFilex2     512  avgt   15   77238.320 ?   194.585  ns/op
ZipFileOpen.openCloseZipFilex2    1024  avgt   15  161828.411 ? 45486.890  ns/op
Finished running test 'micro:java.util.zip.ZipFileOpen'

windows:
without patch:
ZipFileOpen.openCloseZipFile       512  avgt   15  319543.232 ±  46112.481  ns/op
ZipFileOpen.openCloseZipFile      1024  avgt   15  463719.381 ± 139409.316  ns/op
ZipFileOpen.openCloseZipFilex2     512  avgt   15  750838.029 ± 190726.572  ns/op
ZipFileOpen.openCloseZipFilex2    1024  avgt   15  875174.035 ± 140971.036  ns/op

with patch:
Benchmark                       (size)  Mode  Cnt       Score        Error  Units
ZipFileOpen.openCloseZipFile       512  avgt   15  400393.718 ± 161890.652  ns/op
ZipFileOpen.openCloseZipFile      1024  avgt   15  380922.933 ±  21776.006  ns/op
ZipFileOpen.openCloseZipFilex2     512  avgt   15  623589.801 ±  38110.510  ns/op
ZipFileOpen.openCloseZipFilex2    1024  avgt   15  774654.146 ±  50413.718  ns/op

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

PR Comment: https://git.openjdk.org/jdk/pull/16115#issuecomment-1767073176


More information about the core-libs-dev mailing list