[erlang-questions] Selective receive optimization for NIFs

Paul Davis <>
Mon Jul 9 15:52:07 CEST 2012


Sverker,

Ah! That would explain a lot of my confusion. I spent a lot of time
reading through code thinking the magic was that refs were tagged with
when they were created or had some special flag when they got copied
out of a process. If I have time later this week I'll take some time
to start reading through decompiled beam to try and get a better
understanding and see what I can come up with.

Thanks,
Paul

On Mon, Jul 9, 2012 at 4:30 AM, Sverker Eriksson
<> wrote:
> Hi Paul
>
> The OTP-8623 selective receive optimization was achieved partly with static
> code analysis done by the Erlang compiler.
>
> In your case the NIF is creating the ref. To do the same optimization for
> that, would need some sort of dynamic analysis done in runtime.
>
>
> /Sverker, Erlang/OTP
>
>
>
> Paul Davis wrote:
>>
>> I've got a bit of a curious question in relation to OTP-8623 (which is
>> the selective receive for a newly created ref skips messages in the
>> inbox). Apparently this doesn't appear to apply to messages generated
>> from NIFs. Or at least, not in the code I've got.
>>
>> I did spend some time trawling around erts internals but the few
>> references I found weren't enough for the whole thing to click. I'll
>> paste the sample test code I've been using in case I'm doing something
>> supremely silly.
>>
>> Thanks,
>> Paul Davis
>>
>> https://gist.github.com/3073295
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
>
>



More information about the erlang-questions mailing list