Re: [erlang-questions] What OS threads get used in Erlang’s abstract machine, BEAM?

Kresten Krab Thorup krab@REDACTED
Mon Sep 13 18:10:52 CEST 2010


Here is AFAIK, the basic scenario:

Erlang code will be run in as many "green threads" as there are processes; the process limit is controlled by the +P flag.

The green threads are mapped on to S threads, where S is the number of cores/CPUs.  The fact that these threads are also called schedulers can seem somewhat confusing, but from the VMs point of view they are.  From the developer's point of view, they are the threads that run your erlang code.  The number S can be controlled with the +S option to the erl command line.

In addition hereto, there are a number of so-called "Async Threads".  That's a thread pool which is used by I/O processes called linked in drivers, to react to select / poll etc.  The number of asynch threads is dynamic, but limited by the +A flag.

So, the 11 threads you see on a dual-core may be 2 schedulers, and 9 async threads.  For instance.

Read more about the flags here ...
http://www.erlang.org/doc/man/erl.html

Kresten

<http://www.erlang.org/doc/man/erl.html>
On Sep 13, 2010, at 17:08 , Alan Labouseur wrote:

Folks,

I’ve begun studying Erlang and find the BEAM runtime environment fascinating. It’s commonly stated that in Erlang, processes belong to the language rather than the OS (meaning the runtime, meaning BEAM in this case). These are the lightweight, “green processes” that Erlang is getting famous for. It’s further stated (on page 5 of http://www.cs.ucsb.edu/~puneet/reports/erlang.pdf) that BEAM uses one (1) OS thread per CPU core for scheduling and another OS thread for i/o. So I wonder: From what thread do the CPU cycles needed to actually execute Erlang code come from?

Further, if I’m running on a dual core machine I would expect -- based on what I’ve read so far -- to see three (3) threads running under the BEAM process: two schedulers (one for each core) and one i/o thread. But I see 10. Sometimes 11. Sometimes it starts at 13 and, like high-quality amplifiers, goes to 11.

I’m confused. Any insight will be appreciated.

Thanks,
- Alan Labouseur
________________________________________________________________
erlang-questions (at) erlang.org<http://erlang.org> mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED


Kresten Krab Thorup, CTO, Trifork



More information about the erlang-questions mailing list