sendfile() in FileChannelImpl.c
msa at allman.ms
Sun Oct 18 23:14:12 PDT 2009
On Sun, 18 Oct 2009, Greg Lewis wrote:
> G'day Michael,
> On Fri, Oct 16, 2009 at 04:55:08PM -0700, Michael Allman wrote:
>> Can someone explain why we aren't using sendfile() in the transferTo0 call
>> for the case of a file transfer to a network socket in FileChannelImpl.c?
>> Also, my understanding is that if this call cannot do a sendfile(), it
>> should return IOS_UNSUPPORTED_CASE. This will tell the caller to do a
>> loop-based transfer (see sun.nio.ch.FileChannelImpl.transferTo(), line
> I think the reason is basically historical. I don't recall there being
> a fallback when we originally ported the NIO code, so sendfile() didn't
> make sense since it only transferred to network sockets.
> Before switching I'd want to see what sort of affect that had performance
> wise on the case of transferring to a file descriptor.
>From a Darwin perspective, it would be awful nice if Apple open-sourced
their implementation. I recall finding a while back that Apple's Java
runtime used sendfile() by using DTrace.
Thanks for the info. If I had a knowledge of C++ and system programming
on BSD platforms, I'd be happy to submit a patch.
More information about the bsd-port-dev