History log of /libcore/ojluni/src/main/native/zip_util.c
Revision Date Author Comments
d2ad3d317194457c30e9e1cd1f292ede9201bec8 19-Aug-2016 Narayan Kamath <narayan@google.com> Revert "zip_util: temporary debugging on LFH header mismatches."

This reverts commit c68d76de51087f5cd2cd5553fd1d7d8e59502dd0.

bug: 30963384
test: treehugger only

Change-Id: Ie6d228f3dba7e47a0bf0d351dfa817790aeefde9
36d074286912d876489c6ff21bc0c41016180dad 18-Aug-2016 Narayan Kamath <narayan@google.com> ZipFile: Never change file offset during I/O operations.

Use pread instead read and eliminate unnecessary calls to lseek.

dalvik.system.VMClassLoader maintains a cache of JarFile objects
that it creates whenever it loads resources from them. This cache may
be populated in the zygote as a side effect of preloading classes. When
processes are forked from the zygote, the file descriptors associated
with these JarFile objects point to the same kernel file description
and may end up stepping on each others toes. To avoid such issues, we
never make any offset changes to the associated file.

Note that we have a guarantee that the file will never be closed in
any forked process because the associated JarFile objects can never be
collected.

test: run cts -m CtsLibcoreTestCases / ZipStressTest / manual testing
to trigger the race condition.

bug: 30407219
bug: 30904760

(cherry picked from commit 0393d3c84ed9bd24bcf0dac3782a1cc23400ace8)

(cherry picked from commit 50c5924a4a1f78b7722d97dc958317027e25e214)

Change-Id: I1d2be54e768f668616e5b53e038d80fab5aa7e18
d47251ed255544b60de615907eb83f64073dccfa 18-Aug-2016 Narayan Kamath <narayan@google.com> ZipFile: Never change file offset during I/O operations.

Use pread instead read and eliminate unnecessary calls to lseek.

dalvik.system.VMClassLoader maintains a cache of JarFile objects
that it creates whenever it loads resources from them. This cache may
be populated in the zygote as a side effect of preloading classes. When
processes are forked from the zygote, the file descriptors associated
with these JarFile objects point to the same kernel file description
and may end up stepping on each others toes. To avoid such issues, we
never make any offset changes to the associated file.

Note that we have a guarantee that the file will never be closed in
any forked process because the associated JarFile objects can never be
collected.

test: run cts -m CtsLibcoreTestCases / ZipStressTest / manual testing
to trigger the race condition.

bug: 30407219
Change-Id: Ic770a6ab6aca7f123a90002327d7f0a321e9afef
50c5924a4a1f78b7722d97dc958317027e25e214 18-Aug-2016 Narayan Kamath <narayan@google.com> ZipFile: Never change file offset during I/O operations.

Use pread instead read and eliminate unnecessary calls to lseek.

dalvik.system.VMClassLoader maintains a cache of JarFile objects
that it creates whenever it loads resources from them. This cache may
be populated in the zygote as a side effect of preloading classes. When
processes are forked from the zygote, the file descriptors associated
with these JarFile objects point to the same kernel file description
and may end up stepping on each others toes. To avoid such issues, we
never make any offset changes to the associated file.

Note that we have a guarantee that the file will never be closed in
any forked process because the associated JarFile objects can never be
collected.

test: run cts -m CtsLibcoreTestCases / ZipStressTest / manual testing
to trigger the race condition.

bug: 30407219

(cherry picked from commit 0393d3c84ed9bd24bcf0dac3782a1cc23400ace8)

Change-Id: Ic770a6ab6aca7f123a90002327d7f0a321e9afef
0393d3c84ed9bd24bcf0dac3782a1cc23400ace8 18-Aug-2016 Narayan Kamath <narayan@google.com> ZipFile: Never change file offset during I/O operations.

Use pread instead read and eliminate unnecessary calls to lseek.

dalvik.system.VMClassLoader maintains a cache of JarFile objects
that it creates whenever it loads resources from them. This cache may
be populated in the zygote as a side effect of preloading classes. When
processes are forked from the zygote, the file descriptors associated
with these JarFile objects point to the same kernel file description
and may end up stepping on each others toes. To avoid such issues, we
never make any offset changes to the associated file.

Note that we have a guarantee that the file will never be closed in
any forked process because the associated JarFile objects can never be
collected.

test: run cts -m CtsLibcoreTestCases / ZipStressTest / manual testing
to trigger the race condition.

bug: 30407219
Change-Id: Ic770a6ab6aca7f123a90002327d7f0a321e9afef
c68d76de51087f5cd2cd5553fd1d7d8e59502dd0 09-Aug-2016 Narayan Kamath <narayan@google.com> zip_util: temporary debugging on LFH header mismatches.

This should let us determine whether we had bad data, a bad offset
or both.

bug: 30529561
Change-Id: I274cdc4026bec024ae2d66fe10bdd9651680b201
ff96d13467fa65856c19aaf06b151ce60e0edd8f 11-May-2016 Narayan Kamath <narayan@google.com> JarFile: Optimize getMetaInfEntryNames.

Bring back the OpenJDK implementation but make sure that it's
case sensitive in its matching.

Also update JarFile benchmark to use a different set of JarFiles
(ones that actually have resources and are signed).

AFTER:

Experiment {instrument=runtime, benchmarkMethod=time, vm=default, parameters={filename=/system/framework/core-oj.jar}}
runtime(ns): min=89200.91, 1st qu.=92035.88, median=96248.38, mean=95636.11, 3rd qu.=97204.71, max=104263.73
Experiment {instrument=runtime, benchmarkMethod=time, vm=default, parameters={filename=/system/priv-app/Phonesky/Phonesky.apk}}
runtime(ns): min=32815012.40, 1st qu.=33074432.68, median=34521206.63, mean=34974008.88, 3rd qu.=36545497.61, max=39179367.36

BEFORE:
Experiment {instrument=runtime, benchmarkMethod=time, vm=default, parameters={filename=/system/framework/core-oj.jar}}
runtime(ns): min=317222.97, 1st qu.=333416.42, median=339164.45, mean=344867.65, 3rd qu.=352596.11, max=392011.29
Experiment {instrument=runtime, benchmarkMethod=time, vm=default, parameters={filename=/system/priv-app/Phonesky/Phonesky.apk}}
runtime(ns): min=36966924.00, 1st qu.=39058659.29, median=43041285.43, mean=42476010.68, 3rd qu.=45566839.83, max=46848927.18

This isn't a perfect benchmark, because a lot of time is spent constructing the JarFile each time.
However, we've shaved times by a third for files with a "reasonable"
number of entries.

bug: 28713954

Change-Id: Ic0de000be683dc8009818930658ae4a443d81559
fa07c88938c939eea9770e52f4813476e4ba6f3b 12-Feb-2016 Narayan Kamath <narayan@google.com> ZipFile: Improve performance for ZipFile.<init>

Avoid thousands of JNI transitions in the constructor. We can
quite easily check for invalid entry names and duplicates while
parsing the central directory in native code.

The benchmarks show that the median time for opening a file with 8192
entries decreased from 488ms to 120us.

AFTER:
Trial Report (1 of 3):
Experiment {instrument=runtime, benchmarkMethod=timeZipFileOpen, vm=default, parameters={numEntries=128}}
Results:
runtime(ns): min=112794.57, 1st qu.=113238.72, median=114539.28, mean=119694.66, 3rd qu.=125191.84, max=143145.02
Trial Report (2 of 3):
Experiment {instrument=runtime, benchmarkMethod=timeZipFileOpen, vm=default, parameters={numEntries=1024}}
Results:
runtime(ns): min=112868.04, 1st qu.=113582.70, median=115180.93, mean=117760.32, 3rd qu.=118067.87, max=137760.10
Trial Report (3 of 3):
Experiment {instrument=runtime, benchmarkMethod=timeZipFileOpen, vm=default, parameters={numEntries=8192}}
Results:
runtime(ns): min=112417.27, 1st qu.=114630.16, median=117272.70, mean=119197.74, 3rd qu.=122742.84, max=135330.50

BEFORE:
Trial Report (1 of 3):
Experiment {instrument=runtime, benchmarkMethod=benchmarkZipFileOpen, vm=default, parameters={numEntries=128}}
Results:
runtime(ns): min=9360144.37, 1st qu.=9559712.86, median=9839983.50, mean=9816559.27, 3rd qu.=10057399.81, max=10170918.14
Trial Report (2 of 3):
Experiment {instrument=runtime, benchmarkMethod=benchmarkZipFileOpen, vm=default, parameters={numEntries=1024}}
Results:
runtime(ns): min=60682471.64, 1st qu.=62388598.00, median=64319977.57, mean=66545494.60, 3rd qu.=72114121.64, max=77298980.57
Trial Report (3 of 3):
Experiment {instrument=runtime, benchmarkMethod=benchmarkZipFileOpen, vm=default, parameters={numEntries=8192}}
Results:
runtime(ns): min=485804479.00, 1st qu.=487322656.00, median=488986250.00, mean=489820034.67, 3rd qu.=492383229.50, max=495372604.00

bug: 27145664

(cherry picked from commit 8c6a910cd20026c9181a46c8e800a4a566f14527)

Change-Id: Ic1bfe934548f7baf8b8789f069f654725a4b228b
8c6a910cd20026c9181a46c8e800a4a566f14527 12-Feb-2016 Narayan Kamath <narayan@google.com> ZipFile: Improve performance for ZipFile.<init>

Avoid thousands of JNI transitions in the constructor. We can
quite easily check for invalid entry names and duplicates while
parsing the central directory in native code.

The benchmarks show that the median time for opening a file with 8192
entries decreased from 488ms to 120us.

AFTER:
Trial Report (1 of 3):
Experiment {instrument=runtime, benchmarkMethod=timeZipFileOpen, vm=default, parameters={numEntries=128}}
Results:
runtime(ns): min=112794.57, 1st qu.=113238.72, median=114539.28, mean=119694.66, 3rd qu.=125191.84, max=143145.02
Trial Report (2 of 3):
Experiment {instrument=runtime, benchmarkMethod=timeZipFileOpen, vm=default, parameters={numEntries=1024}}
Results:
runtime(ns): min=112868.04, 1st qu.=113582.70, median=115180.93, mean=117760.32, 3rd qu.=118067.87, max=137760.10
Trial Report (3 of 3):
Experiment {instrument=runtime, benchmarkMethod=timeZipFileOpen, vm=default, parameters={numEntries=8192}}
Results:
runtime(ns): min=112417.27, 1st qu.=114630.16, median=117272.70, mean=119197.74, 3rd qu.=122742.84, max=135330.50

BEFORE:
Trial Report (1 of 3):
Experiment {instrument=runtime, benchmarkMethod=benchmarkZipFileOpen, vm=default, parameters={numEntries=128}}
Results:
runtime(ns): min=9360144.37, 1st qu.=9559712.86, median=9839983.50, mean=9816559.27, 3rd qu.=10057399.81, max=10170918.14
Trial Report (2 of 3):
Experiment {instrument=runtime, benchmarkMethod=benchmarkZipFileOpen, vm=default, parameters={numEntries=1024}}
Results:
runtime(ns): min=60682471.64, 1st qu.=62388598.00, median=64319977.57, mean=66545494.60, 3rd qu.=72114121.64, max=77298980.57
Trial Report (3 of 3):
Experiment {instrument=runtime, benchmarkMethod=benchmarkZipFileOpen, vm=default, parameters={numEntries=8192}}
Results:
runtime(ns): min=485804479.00, 1st qu.=487322656.00, median=488986250.00, mean=489820034.67, 3rd qu.=492383229.50, max=495372604.00

bug: 27145664

Change-Id: I510e923ac54d52082b9eafa0f151ad4f71826333
b1f26e7268a34bce1dd2f20a03ee1fb1563e99a9 02-Jun-2015 Piotr Jastrzebski <haaawk@google.com> Fix LP64 build.

Change-Id: I950130babc125e27a0da254aea8ee8152c17332c
a8ed084745590c5e4a0e8559b5821809d60fe242 21-Apr-2015 Piotr Jastrzebski <haaawk@google.com> Use OpenJdk implementation of java.util.zip.*

- Move some of the internal implementation details of libcore's
zipfile into StrictJarFile.
- TODO: Adler32 continues to use old native code from libcore, this
must be switched over.
- InflaterInputStream: |closed| becomes protected.
- ZipFile : Always use mmap.
- ZipEntry : Add a long dataOffset.
- Switch all native code over to explicit registration.

Change-Id: Id5519b4548ea1eb22fd182edfbd2c804dc6f3bb5
51b1b6997fd3f980076b8081f7f1165ccc2a4008 16-Feb-2015 Piotr Jastrzebski <haaawk@google.com> Initial import of OpenJdk files.

Create new libcore/ojluni directory with src/main/java and
src/main/native subdirectiories.

Build ojluni into core-oj jar.

Use openjdk classes from java.awt.font package.

Copy all files from jdk/src/share/classes and jdk/src/solaris/classes
directories in openjdk into libcore/ojluni/src/main/java.

Copy following native files from openjdk to
libcore/ojluni/src/main/native:
jdk/src/solaris/native/java/io/canonicalize_md.c
build/linux-amd64/include/classfile_constants.h
jdk/src/share/native/java/net/DatagramPacket.c
jdk/src/solaris/native/sun/net/spi/DefaultProxySelector.c
jdk/src/share/native/java/lang/Double.c
jdk/src/share/native/java/lang/fdlibm/include/fdlibm.h
jdk/src/solaris/native/sun/nio/ch/FileChannelImpl.c
jdk/src/solaris/native/java/io/FileDescriptor_md.c
jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c
jdk/src/share/native/java/io/FileInputStream.c
jdk/src/solaris/native/sun/nio/ch/FileKey.c
jdk/src/solaris/native/java/io/FileOutputStream_md.c
jdk/src/solaris/native/java/io/FileSystem_md.c
jdk/src/share/native/java/lang/Float.c
jdk/src/share/native/java/net/Inet4Address.c
jdk/src/solaris/native/java/net/Inet4AddressImpl.c
jdk/src/share/native/java/net/Inet6Address.c
jdk/src/solaris/native/java/net/Inet6AddressImpl.c
jdk/src/share/native/java/net/InetAddress.c
jdk/src/solaris/native/java/net/InetAddressImplFactory.c
jdk/src/share/native/java/io/io_util.c
jdk/src/solaris/native/sun/nio/ch/IOUtil.c
jdk/src/share/native/java/io/io_util.h
jdk/src/solaris/native/java/io/io_util_md.c
jdk/src/solaris/native/java/io/io_util_md.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/java_io_FileDescriptor.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_io_FileInputStream.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_io_FileOutputStream.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_io_FileSystem.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_io_ObjectStreamClass.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_io_UnixFileSystem.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Double.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Float.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Integer.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Long.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Runtime.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Shutdown.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_StrictMath.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_String.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_System.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Thread.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Throwable.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_DatagramPacket.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_Inet4Address.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_Inet4AddressImpl.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_Inet6Address.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_Inet6AddressImpl.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_InetAddress.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_InetAddressImplFactory.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_NetworkInterface.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_PlainDatagramSocketImpl.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_PlainSocketImpl.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_SocketInputStream.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_SocketOptions.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_SocketOutputStream.h
jdk/src/share/native/java/lang/java_props.h
jdk/src/solaris/native/java/lang/java_props_md.c
jdk/src/share/native/java/util/zip/Adler32.c as java_util_zip_Adler32.c
jdk/src/share/native/java/util/zip/CRC32.c as java_util_zip_CRC32.c
build/linux-amd64/tmp/sun/java.util.zip/zip/CClassHeaders/java_util_zip_CRC32.h
jdk/src/share/native/java/util/zip/Deflater.c as java_util_zip_Deflater.c
build/linux-amd64/tmp/sun/java.util.zip/zip/CClassHeaders/java_util_zip_Deflater.h
jdk/src/share/native/java/util/zip/Inflater.c as java_util_zip_Inflater.c
build/linux-amd64/tmp/sun/java.util.zip/zip/CClassHeaders/java_util_zip_Inflater.h
jdk/src/share/native/java/util/zip/ZipFile.c as java_util_zip_ZipFile.c
build/linux-amd64/tmp/sun/java.util.zip/zip/CClassHeaders/java_util_zip_ZipFile.h
jdk/src/share/native/java/lang/fdlibm/include/jfdlibm.h
jdk/src/share/native/common/jlong.h
jdk/src/solaris/native/common/jlong_md.h
jdk/src/share/native/common/jni_util.c
jdk/src/share/native/common/jni_util.h
jdk/src/solaris/native/common/jni_util_md.c
jdk/src/share/javavm/export/jvm.h
jdk/src/solaris/javavm/export/jvm_md.h
jdk/src/solaris/native/java/net/linux_close.c
jdk/src/share/native/sun/misc/NativeSignalHandler.c
jdk/src/solaris/native/sun/nio/ch/NativeThread.c
jdk/src/share/native/java/net/net_util.c
jdk/src/share/native/java/net/net_util.h
jdk/src/solaris/native/java/net/net_util_md.c
jdk/src/solaris/native/java/net/net_util_md.h
jdk/src/solaris/native/java/net/NetworkInterface.c
jdk/src/share/native/sun/nio/ch/nio.h
jdk/src/solaris/native/sun/nio/ch/nio_util.h
jdk/src/share/native/java/io/ObjectStreamClass.c
jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c
jdk/src/solaris/native/java/net/PlainSocketImpl.c
jdk/src/solaris/native/java/lang/ProcessEnvironment_md.c
jdk/src/share/native/java/lang/Runtime.c
jdk/src/share/native/java/lang/Shutdown.c
jdk/src/share/native/sun/misc/Signal.c
jdk/src/solaris/native/java/net/SocketInputStream.c
jdk/src/solaris/native/java/net/SocketOutputStream.c
jdk/src/share/native/java/lang/StrictMath.c
jdk/src/share/native/java/lang/String.c
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/sun_misc_NativeSignalHandler.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/sun_misc_Signal.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/sun_net_spi_DefaultProxySelector.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_FileChannelImpl.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_FileDispatcherImpl.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_FileKey.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_IOStatus.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_IOUtil.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_NativeThread.h
jdk/src/share/native/java/lang/System.c
jdk/src/share/native/java/lang/Thread.c
jdk/src/share/native/java/lang/Throwable.c
jdk/src/solaris/native/java/io/UnixFileSystem_md.c
jdk/src/solaris/native/java/lang/UNIXProcess_md.c
jdk/src/share/native/java/util/zip/zip_util.c
jdk/src/share/native/java/util/zip/zip_util.h

Change-Id: Ib237df4e1b7b5b4d9f12e74d189e6ec9eed3c31d