RFR: 8304020: Speed up test/jdk/java/util/zip/ZipFile/TestTooManyEntries.java and clarify its purpose [v8]

Eirik Bjorsnos duke at openjdk.org
Mon Oct 30 15:25:02 UTC 2023


> Please review this PR which speeds up TestTooManyEntries and clarifies its purpose:
> 
> - The name 'TestTooManyEntries' does not clearly convey the purpose of the test. What is tested is the validation that the total CEN size fits in a Java byte array. Suggested rename: CenSizeTooLarge
> - The test creates DEFLATED entries which incurs zlib costs and File Data / Data Descriptors for no additional benefit. We can use STORED instead.
> - By creating a single LocalDateTime and setting it with `ZipEntry.setTimeLocal`, we can avoid repeated time zone calculations. 
> - The name of entries is generated by calling UUID.randomUUID, we could use simple counter instead.
> - The produced file is unnecessarily large. We know how large a CEN entry is, let's take advantage of that to create a file with the minimal size.
> - By adding a maximally large extra field to the CEN entries, we get away with fewer CEN records and save memory
> - The summary and comments of the test can be improved to help explain the purpose of the test and how we reach the limit being tested.
> - By writing sparse 'holes' until the last CEN entry, we can reduce required disk space.
> 
> These speedups reduced the runtime from 4 min 17 sec to 3 seconds on my Macbook Pro. The produced ZIP size was reduced from 5.7 GB to ~4K. Memory consumption is down from 8GB to something like 12MB.

Eirik Bjorsnos has updated the pull request incrementally with four additional commits since the last revision:

 - Extract the expected ZipException message into a class constant
 - Add comment explaining the MAX_EXTRA_FIELD_SIZE constant
 - Convert test to junit
 - Remove @requires for sun.arch.data.model == "64", assuming the updated test doesn't need it.

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/12991/files
  - new: https://git.openjdk.org/jdk/pull/12991/files/9629b8d2..c21789b0

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=12991&range=07
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=12991&range=06-07

  Stats: 27 lines in 1 file changed: 17 ins; 1 del; 9 mod
  Patch: https://git.openjdk.org/jdk/pull/12991.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/12991/head:pull/12991

PR: https://git.openjdk.org/jdk/pull/12991


More information about the core-libs-dev mailing list