[erlang-questions] BIFs use with care

Mikael Pettersson mikpelinux@REDACTED
Tue Oct 17 19:42:48 CEST 2017

On Tue, Oct 17, 2017 at 4:47 PM, nato <nbartley@REDACTED> wrote:

> I recently saw an ESL video advising that one should
> use Erlang BIFs with care... it was a bit of an aside, so
> I was wondering if someone could could elaborate
> on this. It seemed to suggest that BIFs (the ones written
> in C?) could block/cause problems ...

Presumably they were referring to preemption.

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

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20171017/18ce0d61/attachment.htm>

More information about the erlang-questions mailing list