[erlang-questions] Dirty NIF - classifying as CPU or I/O bound

Stanislaw Klekot erlang.org@REDACTED
Sun Oct 14 14:49:26 CEST 2018


On Sun, Oct 14, 2018 at 01:41:50PM +0100, Roger Lipscombe wrote:
> The documentation (http://erlang.org/doc/man/erl_nif.html#dirty_nifs) says:
> 
> "It is important to classify the dirty job correct [sic]. An I/O bound job
> should be classified as such, and a CPU bound job should be classified as
> such. If you should classify CPU bound jobs as I/O bound jobs, dirty I/O
> schedulers might starve ordinary schedulers. I/O bound jobs are expected to
> either block waiting for I/O, and/or spend a limited amount of time moving
> data."
> 
> If I *don't know* whether the job is going to be CPU bound or I/O bound (it
> executes arbitrary code provided by a third party), am I safest to just
> classify the dirty job as CPU-bound? Or is this warning hinting at a
> disaster of biblical proportions[1] if I even *think* about fudging the
> classification?

If you execute a third party code you have no control over, you don't
execute it as NIF, but as a separate program through a port (or maybe as
a C node). NIFs are not a solution for each and all problems in Erlang.

-- 
Stanislaw Klekot



More information about the erlang-questions mailing list