RFR: 8293502: (fc) FileChannel::transfer methods fail to copy /proc files on Linux

Brian Burkhalter bpb at openjdk.org
Thu Sep 15 20:07:54 UTC 2022


On Thu, 15 Sep 2022 11:00:02 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Files in `/proc` advertise a size of zero for which direct and mapped transfers do not work. For this case, fall back to arbitrary channel transfer.
>
> src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java line 949:
> 
>> 947:         // System calls supporting fast transfers might not work on files
>> 948:         // which advertise zero size such as those in Linux /proc
>> 949:         if (src instanceof FileChannelImpl fci && fci.size() > 0) {
> 
> This means an extra fstat per transferFrom but maybe you've measured it with small files and it's okay?

It's about 20% slower for sizes 32 and 4096 (disk block size), and about 13% slower for size 32768. Instead making the direct and trusted methods fail independently does not help.

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

PR: https://git.openjdk.org/jdk/pull/10267


More information about the nio-dev mailing list