RFR: 8265448: (zipfs): Reduce read contention in ZipFileSystem

Jason Zaugg jzaugg at openjdk.java.net
Tue May 4 13:15:04 UTC 2021


If the given Path represents a file, use the overload of read defined
in FileChannel that accepts an explicit position and avoid serializing
reads.

Note: The underlying NIO implementation is not required to implement
FileChannel.read(ByteBuffer, long) concurrently; Windows still appears
to lock, as it returns true for NativeDispatcher.needsPositionLock.


On MacOS X, the enclosed benchmark improves from:


Benchmark                    Mode  Cnt   Score   Error  Units
ZipFileSystemBenchmark.read  avgt   10  75.311 ? 3.301  ms/op


To:


Benchmark                    Mode  Cnt   Score   Error  Units
ZipFileSystemBenchmark.read  avgt   10  12.520 ? 0.875  ms/op

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

Commit messages:
 - 8265448: Avoid lock contention in reads from zipfs when possible

Changes: https://git.openjdk.java.net/jdk/pull/3853/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=3853&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8265448
  Stats: 101 lines in 2 files changed: 97 ins; 0 del; 4 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3853.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3853/head:pull/3853

PR: https://git.openjdk.java.net/jdk/pull/3853


More information about the core-libs-dev mailing list