<div dir="ltr">On Tue, Oct 17, 2017 at 4:47 PM, nato <span dir="ltr"><<a href="mailto:nbartley@umail.iu.edu" target="_blank">nbartley@umail.iu.edu</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I recently saw an ESL video advising that one should<br>
use Erlang BIFs with care... it was a bit of an aside, so<br>
I was wondering if someone could could elaborate<br>
on this. It seemed to suggest that BIFs (the ones written<br>
in C?) could block/cause problems ...<br></blockquote><div><br></div>Presumably they were referring to preemption.</div><div class="gmail_quote"><br></div><div class="gmail_quote">BEAM code is preemptive by design, meaning that the VM can suspend a process and schedule another at almost any instant. (I'm simplifying, but that's the essence of it.) BIFs, being C code inside the VM, are not preemptive by default: they have to be written in a special and potentially slower way to make them preemptive. This means that for large inputs (e.g. long lists or binaries, or deep terms) a broken BIF may block its scheduler until it's finished. That's potentially very bad, depending on your application.</div><div class="gmail_quote"><br></div><div class="gmail_quote">Most such bugs should be fixed by now (they were more common 5+ years ago), but it's possible some remain. I wouldn't avoid BIFs unless I knew for a fact that the VM I was using had such a bug in it.<br></div></div></div>