[erlang-questions] "sendfile" call as NIF. Good or bad idea?

zabrane Mikael zabrane3@REDACTED
Tue Nov 30 17:38:22 CET 2010


Hi everybody,

Michale Santos pointed me that there's some work (by Björn Gustavsson)
to integrate "sendfile" natively
in Erlang:
https://github.com/erlang/otp/commit/34042f49c7b5f0ac1b91463344db663eddc2e76d#diff-3

Could someone from OTP team tell me if this will happen soon? In which
release if possible?

-- 
Regards
Zabrane

2010/11/27 zabrane Mikael <zabrane3@REDACTED>:
> Hi Steve,
>
>> Not sure why you find it cryptic, since as drivers go it's pretty
>> simple. Can you provide further details?
>
> Maybe it was because NIF are very simple to read/write.
> Again, no offense ... forget about that comment.
>
>> The benefit of a driver is that we can just register each socket FD
>> with erts and it lets us know when each socket is writeable. The
>> driver mainly just handles tracking how much was written by each
>> sendfile call, incrementing offsets, etc.
>
> Thanks for this. I didn't consider this problem at all.
>
>> If you implemented it as a NIF, you'd need to perform your own polling
>> on the socket FDs to know when sendfile can write to them. This alone
>> might mean a portability issue, since you'd have to know to use the
>> right polling mechanism for the given platform. You'd also need to do
>> all this in your own thread, whereas the driver doesn't have to deal
>> with threads.
>
> So, I'll stick with your driver.
> Thanks Steve.
>
> --
> Regards
> Zabrane
>


More information about the erlang-questions mailing list