Erlang / Erlang Advanced Interview questions
What is a dirty scheduler and when should a NIF use one?
A regular NIF runs inline on a normal BEAM scheduler thread, which is fine for short operations but dangerous for anything that blocks or takes more than roughly a millisecond, since it stalls that entire scheduler and every process waiting behind it. Dirty schedulers are a separate pool of OS threads reserved for long-running native work, so it doesn't compete with the normal schedulers running lightweight Erlang processes.
There are two dirty scheduler pools:
- Dirty CPU schedulers — for CPU-intensive native computation (heavy math, compression).
- Dirty I/O schedulers — for blocking I/O operations (file access, slow syscalls).
A NIF opts in by declaring itself with ERL_NIF_DIRTY_JOB_CPU_BOUND or
ERL_NIF_DIRTY_JOB_IO_BOUND in its registration table, and the runtime routes calls to that function
onto the appropriate dirty pool instead of a regular scheduler.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
