JDK-8223401 : Inefficiency in ZipFileSystem.sync()
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.nio
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2019-05-06
  • Updated: 2019-05-07
  • Resolved: 2019-05-07
Related Reports
Duplicate :  
Description
JDK-8034802 re-implemented ZipFileSystem.sync(). The new implementation creates a separate OutputStream object (EntryOutputStreamCRC32 or EntryOutputStreamDef) for each entry. For a JAR file with large number of entries, this causes many short lived objects being created. The older version of ZipFileSystem.sync() does not seem to use a separate resource for each entry in the deflated case:

-  if (e.bytes != null) {        // in-memory, deflated
-      os.write(e.bytes);        // already
-      written += e.bytes.length;
-  } else if (e.file != null) {  // tmp file
...
-  }
+  written += writeEntry(e, os, buf); <<<<<<<
Comments
Hi Christoph, That's exactly what I was looking for. It resolves the issue for me. Thanks a lot for pointing to JDK-8222532! Really appreciate it! It's a magic when one wishes for something and it is already materialized. Best regards, Jiangli
07-05-2019

Hi Jiangli, did you check, whether this was already helped by the change for JDK-8222532 [0]? With that change, data for entries will get compressed on the fly again. At the time of sync(), there's no need to have additional OutputStreams. So, maybe this one should be marked as duplicate? Best regards Christoph [0] http://hg.openjdk.java.net/jdk/jdk/rev/c604234be658
07-05-2019