[erlang-questions] How long a NIF can block the Erlang BEAM?
Tue Nov 23 11:30:40 CET 2010
Kenji> >I wonder how long a NIF can block the Erlang BEAM. To put it another
Kenji> >way, I want to know the maximum time allowed a NIF can run in the
Kenji> >One millisecond? Or 100 microseconds? Or even shorter?
Alceste> AFAIK, there are no hard limits: a NIF could block its Erlang
Alceste> VM thread as long as needed --- but long-running NIFs will
Alceste> disrupt the scheduling of other Erlang processes, and reduce
Alceste> the responsiveness of unrelated applications running in the
Alceste> same VM.
Exactly. The limit is whatever the tolerable latency in your
application is. If it's fine for your application to freeze for 500ms,
then a NIF which takes 500ms to run is ok.
The rest of Erlang is made so that an application can react to things
within a few milliseconds, so 100 microseconds is unlikely to give
anyone a nasty surprise. 100 milliseconds will.
More information about the erlang-questions