RFR: 8340887: Add micro benchmark comparing input stream performance of ZipFile vs ZipInputStream
Eirik Bjørsnøs
eirbjo at openjdk.org
Wed Sep 25 10:56:07 UTC 2024
Please review this test-only PR which adds a micro benchmark exploring performance differences between reading entry data sequentially from a `ZipFile` and reading the same entries using `ZipInputStream` wrapping a `BufferedInputStream`.
Spoiler alert: `ZipFile` streams are ~1.8 X slower on my machine compared to `ZipInputStream`:
Benchmark (buffered) (method) (size) Mode Cnt Score Error Units
ReadZipStreams.zipFile true DEFLATED 1024 avgt 15 7871.679 ? 278.719 us/op
ReadZipStreams.zipFile true STORED 1024 avgt 15 4976.571 ? 87.311 us/op
ReadZipStreams.zipInputStream true DEFLATED 1024 avgt 15 4345.494 ? 40.628 us/op
ReadZipStreams.zipInputStream true STORED 1024 avgt 15 2652.063 ? 13.617 us/op
When not using `BufferedInputStream`, most of the difference disappears, so this is probably related to `ZipFileInputStream`'s lack of buffering:
ReadZipStreams.zipFile false DEFLATED 1024 avgt 15 7980.705 ? 490.846 us/op
ReadZipStreams.zipFile false STORED 1024 avgt 15 4994.301 ? 52.762 us/op
ReadZipStreams.zipInputStream false DEFLATED 1024 avgt 15 8367.171 ? 81.631 us/op
ReadZipStreams.zipInputStream false STORED 1024 avgt 15 4811.824 ? 47.859 us/op
-------------
Commit messages:
- Add micro benchmark comparing input stream performance of ZipFile vs ZipInputStream
Changes: https://git.openjdk.org/jdk/pull/21178/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21178&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8340887
Stats: 118 lines in 1 file changed: 118 ins; 0 del; 0 mod
Patch: https://git.openjdk.org/jdk/pull/21178.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/21178/head:pull/21178
PR: https://git.openjdk.org/jdk/pull/21178
More information about the core-libs-dev
mailing list