[erlang-questions] erl_driver vs NIF
Caragea Silviu
silviu.cpp@REDACTED
Wed Dec 7 10:38:47 CET 2016
Hello,
Thanks a lot for your response.
Silviu
On Wed, Dec 7, 2016 at 10:57 AM, Lukas Larsson <lukas@REDACTED> wrote:
> Hello,
>
> On Tue, Dec 6, 2016 at 9:56 PM, Caragea Silviu <silviu.cpp@REDACTED>
> wrote:
>
>>
>> From what I know the NIF is the fastest way to call c/c++ code from
>> erlang. The disadvantage is that you need to return in under 1 ms in order
>> to make sure the schedulers are not affected.
>>
>> using erl_driver and port_control is not the same ? because based on the
>> documentation this is a sync call that blocks scheduler until the native
>> method returns.
>>
>
> The same ~1 ms limit exists for port callbacks as nif function calls.
>
> For some reason there is a rumor circling around that you somehow
> circumvent the limit if you convert your nif code to a linked-in driver.
> This is not the case. The only thing you do by converting the code from a
> nif to linked-in driver is gain access to more tools to partitions the work
> (mostly driver_select[1], but also some other things like the async thread
> pool), and you possibly make some of the problems that long running native
> code can cause less likely.
>
> Lukas
>
> 1: Soon this limit will be removed by the inclusion of enif_select,
> https://github.com/erlang/otp/pull/1264
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20161207/935f831f/attachment.htm>
More information about the erlang-questions
mailing list