[erlang-questions] How does Erland get maximum performance from a multi-core cpu?

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Wed Jun 13 11:55:37 CEST 2018

Another important point to add:

Erlang doesn't make maximal usage of the CPU cores it is given. The system
usually values low latency operation over throughput, so it has to forgo
some raw throughput in order to achieve this goal. To be precise, there has
to be a check in each loop in the program to make sure preemption can
happen of a process which has run for too long on a CPU core. This check is
a function call, because loops are implemented as tail-calling functions.

In turn, you cannot maximize the CPU doing productive work as these checks
will cost something.

The tradeoff is also made in e.g., Go, and they have recently added an
option to preempt loops as well. However, people are somewhat reluctant of
that option since it hurts their throughput.

These tradeoff turned out to be valuable in the original setting of the
Erlang language, but it also works for modern distributed systems.

On Wed, Jun 13, 2018 at 7:39 AM Vance Shipley <vances@REDACTED> wrote:

> Joe,
> The answer is multiple schedulers.
> In the days before the SMP enabled Erlang emulator (VM) we would need to
> run multiple nodes (VM) to take advantage of multiple cores. Now the
> default mode for the VM is to run as many schedulers as there are cores
> available. This also highly configurable.
> Although Erlang's distribution allows processes to transparently
> communicate across nodes there is a great performance advantage in
> intra-node messaging as there is reference passing and it avoids
> serialization in the external term format.
> It's interesting though how everything goes in cycles. Five years ago I
> was keeping the core counts very high, and the node counts very low, to get
> great performance. Now with cloud native we run a node in a container and
> communicate with other (microservices) nodes using either distribution or
> external protocols (e.g. REST) so the overheads are again much higher. But
> the old way was vertical scaling and this is horizontal scaling, we pay a
> tax but go from dozens of cores to hundreds or thousands.
> On Wed, Jun 13, 2018, 08:46 joe mcguckin <joe@REDACTED> wrote:
>> If erlang is one large unix process with hundreds or thousands of it's
>> own processes internally, how does Erlang make maximum use of a multi-core
>> cpu?
>> Wouldn’t Erlang be scheduled and run on a single core ?
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180613/1fbf1f78/attachment.htm>

More information about the erlang-questions mailing list