On Sun, 12 Mar 2023 21:25:46 GMT, Eirik Bjorsnos <d...@openjdk.org> wrote:
>> 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. >> >> These speedups reduced the runtime from 4 min 17 sec to 4 seconds on my >> Macbook Pro. The produced ZIP size was reduced from 5.7 GB to 2 GB. Memory >> consumption is down from 8GB to something like 12MB. > > Eirik Bjorsnos has updated the pull request incrementally with two additional > commits since the last revision: > > - MAX_EXTRA_FIELD_SIZE can be better expressed as 0xFFFF > - Bring back '@requires sun.arch.data.model == 64' for now test/jdk/java/util/zip/ZipFile/CenSizeTooLarge.java line 53: > 51: > 52: // Maximum size (unsigned short) of an extra field allowed by the > standard > 53: static final int MAX_EXTRA_FIELD_SIZE = 0XFFFF; 4.4.10 file name length: (2 bytes) 4.4.11 extra field length: (2 bytes) 4.4.12 file comment length: (2 bytes) The length of the file name, extra field, and comment fields respectively. The combined length of any directory record and these three fields SHOULD NOT generally exceed 65,535 bytes. ------------- PR: https://git.openjdk.org/jdk/pull/12991