8227080: (fs) Files.newInputStream(...).skip(n) is slow

Simone Bordet simone.bordet at gmail.com
Tue Jul 2 20:01:45 UTC 2019


Hi,

On Tue, Jul 2, 2019 at 9:42 PM Brian Burkhalter
<brian.burkhalter at oracle.com> wrote:
>
> Oops, I think that skip() needs to be synchronized. Webrev updated in place.
>
> > On Jul 2, 2019, at 12:18 PM, Brian Burkhalter <brian.burkhalter at oracle.com> wrote:
> >
> > https://bugs.openjdk.java.net/browse/JDK-8227080
> > http://cr.openjdk.java.net/~bpb/8227080/webrev.00/
> >
> > This patch overrides ChannelInputStream.skip(long) to use SeekableByteChannel.position(long) if the ReadableByteChannel instance is a SeekableByteChannel. The performance improvement on my dev machine for skipping the first 2 GB of a local file is about 3.6 x 10^4.
> >

That's great!

I'm not a reviewer, but is there a policy to handle long overflows?

Also, ChannelInputStream should be reviewed with respect to synchronization.
For example, you fixed skip(), but available() is not synchronized,
and read(ByteBuffer) should perhaps be (as subclasses may call it
without grabbing the lock)?

Thanks!

-- 
Simone Bordet
---
Finally, no matter how good the architecture and design are,
to deliver bug-free software with optimal performance and reliability,
the implementation technique must be flawless.   Victoria Livschitz


More information about the nio-dev mailing list