[erlang-questions] Selective receive optimization for NIFs

Sverker Eriksson <>
Mon Jul 9 11:30:47 CEST 2012

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