On Tue, 4 May 2021 13:07:34 GMT, Jason Zaugg <jza...@openjdk.org> wrote:

> 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

src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java line 2223:

> 2221:                 synchronized (zfch) {
> 2222:                     n = zfch.position(pos).read(bb);
> 2223:                 }

@LanceAndersen Are you planning to look at this? Do you mind checking the async 
close case to make sure that the synchronization isn't masking anything?

Also just to point out that pattern matching for instanceof ca be used here.

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

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

Reply via email to