Are elixir NIFs executed concurrently and in a non-blocking manner?

Hello, are elixir NIFs executed concurrently and in a non-blocking manner?

NIFs block the scheduler they’re executed in, but they can also yield in a cooperative multitasking manner

3 Likes

No, during a NIF call you got zero guarantees. You can also easily crash the entire VM.

There are NIF APIs you can use with which you guarantee your NIF call is being a good citizen, however. (And obviously don’t have memory access bugs.)

2 Likes

I would like to build my system with Rust NIFs, so that it won’t crash the entire BEAM. Will the rest of the processes pause when a NIF get’s run?

Please familiarize yourself with the erl_nif docs, and in particular the section on “Long-running NIFs”. If you have any questions after that, please do come ask!

1 Like