How does Erland get maximum performance from a multi-core cpu?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How does Erland get maximum performance from a multi-core cpu?

joe mcguckin

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 ?

Thanks,

joe

Joe McGuckin
ViaNet Communications

[hidden email]
650-207-0372 cell
650-213-1302 office
650-969-2124 fax



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: How does Erland get maximum performance from a multi-core cpu?

Bob Ippolito
Threads allow a single process to utilize multiple cores. Erlang takes advantage of them to run its schedulers.
On Tue, Jun 12, 2018 at 20:16 joe mcguckin <[hidden email]> 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 ?

Thanks,

joe

Joe McGuckin
ViaNet Communications

[hidden email]
650-207-0372 cell
650-213-1302 office
650-969-2124 fax



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: How does Erland get maximum performance from a multi-core cpu?

Vance Shipley
In reply to this post by joe mcguckin
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 <[hidden email]> 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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: How does Erland get maximum performance from a multi-core cpu?

Jesper Louis Andersen-2
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 <[hidden email]> 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 <[hidden email]> 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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions