RFR: 8338931: ZipEntry.flags could be made internal to ZipOutputStream

Eirik Bjørsnøs eirbjo at openjdk.org
Sun Aug 25 19:29:01 UTC 2024


On Sat, 24 Aug 2024 10:49:56 GMT, Eirik Bjørsnøs <eirbjo at openjdk.org> wrote:

> Please review this refactoring PR which moves the `ZipEntry.flags` field to `ZipOutputStream.XEntry`.
> 
> Moving this field will save four bytes from the `ZipEntry` object size and also saves an unneccessary read in `ZipFile.getZipEntry`.
> 
> Testing:
> 
> This PR is a refactoring of existing code and does not update any tests. I added the label `noreg-cleanup` to the JBS issue.
> 
> The following runs clean:
> 
> 
> make test TEST="test/jdk/java/util/zip"
> make test TEST="test/jdk/java/util/jar"
> 
> 
> Performance:
> 
> The JMH benchmark `java.util.zip.ZipFileGetEntry.getEntryHit` show a small but consistent improvement (2-3%).

Sorry, the renaming was just an accident, It was “flags” in my head, but that was wrong.

Will revert the rename once I’m in front of a keyboard again in a few days.


The reason I’m looking at this is that ZipEntry is 88 bytes, and the allocation cost is significant when iterating entries. So it would be beneficial to move unused or optional parts out of the common lookup/enumeration code paths. This seemed like a small but obvious win.

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

PR Comment: https://git.openjdk.org/jdk/pull/20702#issuecomment-2308965369


More information about the core-libs-dev mailing list