8227080: (fs) Files.newInputStream(...).skip(n) is slow
Brian Burkhalter
brian.burkhalter at oracle.com
Wed Jul 3 14:50:43 UTC 2019
Hi Florian,
> On Jul 3, 2019, at 7:11 AM, Florian Weimer <fweimer at redhat.com> wrote:
>
>> 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.
>
> Doesn't this need a fallback in case the seek operation fails? I think
> you can have FileChannels which are not seekable in practice, e.g. if
> the file is actually a FIFO.
Would that not violate the SeekableByteChannel specification? On the other hand, I suppose one might be able to fall back to super.skip(). If the seek however actually did skip a few bytes before failing then it would be possible to skip an incorrect number of bytes in this case.
Thanks,
Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20190703/d51c43bf/attachment.html>
More information about the nio-dev
mailing list