Homepage
 
Search
Ericsson Global
Erlang goes multi-core 
Erlang goes multi-core
In Erlang/OTP R11B released on May 17 the major news is the support for SMP (Symmetric MultiProcessing).

SMP is supported by most modern operating systems like Linux, Windows, Mac OSx, Solaris and is becoming more important now when dual processors, hyper-threading technology and multi-core systems is a reality.
Multi-core is a software challenge

Although it is possible to take advantage of multi-core technology by running several applications processes in parallel, the real benefit would be for multi-threaded applications. The challenge then is to change single-threaded or sparsely threaded applications into multi-threaded and also to debug them.

Erlang has unique properties for taking advantage of multi-core technology
One of the fundamental properties of the Erlang language is built-in support for very light-weight processes, each with its own memory, and using explicit message passing for their communication. Because of this most applications written in Erlang are realized as a number of cooperating Erlang processes representing something in the problem domain of the application, for example active call sessions, connections or transactions. Typically this will result in many thousands of simultaneously executing processes in a heavily loaded application.

The parallelism already present in most Erlang applications makes them ideal for taking advantage of multi-core technology, without there being any need to modify them.

The only thing needed is an Erlang virtual machine (VM) which works in a multi-threaded way, and that is what we now are releasing in Erlang/OTP R11B.

Of course, it is still highly dependant on the application how much it can take advantage of the multi-core technology but our initial tests shows that many existing Erlang applications, without having to be modified in any way, gets significantly improved performance.

Multi-threaded software problems are solved in the Erlang VM
Writing multi-threaded software in popular languages like C++ and Java is a challenge and getting them stable and bug free is an even bigger challenge.

With Erlang, most of the problems which occur in multi-threaded programs have been solved once and for all in the Erlang VM and does not have to be handled by the application programmers.

Multi-threading support in Erlang

The Erlang VM is written in C and run as one process on the host operating system (OS). Within the Erlang VM an internal scheduler is responsible for running the Erlang processes (which can be many thousands). In the SMP version of the Erlang VM, there can be many such schedulers running in separate OS threads. As default there will be as many schedulers as there are processors or processor cores on the system.

The SMP support is totally transparent for the Erlang programs. That is, there is no need to change or recompile existing programs. Programs with built-in assumptions about sequential execution must be rewritten in order to take advantage of the SMP support, however.

This is the first step

In this release, the Erlang VM supports SMP with focus on stability. There will follow a number of subsequent steps with necessary optimizations and support for more platforms.

The Erlang VM with SMP support has been tested on the following platforms:

  • Solaris 10 sparc
  • Suse Linux (SLES 9) x86
  • Mac OSx PPC
Some promising benchmarks


Big
700 Erlang processes that "ping" each other. That all processes send a message to and receives an acknowledgement from all other processes.

Encode-decode
16 Erlang processes performing encode/decode of typical telecom protocol messages independent of each other for a duration of ten minutes, the total number of decodes counted. Some of the processing involves calls to Erlang drivers which are not parallelized yet.

Sun Fire T2000 Server, Solaris 10, UltraSPARC T1 Processor which is an 8 core CPU with 4 threads per core. Comparison between single-threaded Erlang VM and Erlang SMP VM with 32 schedulers.

  no SMP SMP 32
Big 14 
Encode-decode  1

ADM Opteron: 2 dual core CPUs running Suse Linux Enterprise Server 9. Comparison between single-threaded Erlang VM and Erlang SMP VM with 4 schedulers.

  no SMP SMP 4 
Big
Encode-decode  3.6 

Intel Xeon: 2 Hyper-threaded processors running Suse Linux Enterprise Server 9. Comparison between single-threaded Erlang VM and Erlang SMP VM with 4 schedulers.

  no SMP  SMP 4  
Big  2,5 
Encode-decode   3

AMD Athlon(tm): 64 X2 Dual Core Processor 4200+, 2x512Kb L2 Cache ,Linux Fedora Core 5; 2.6.16-1.2096_FC5.  Comparision between single-threaded Erlang VM and Erlang SMP VM with 2 schedulers.

  no SMP   SMP 2   
Big 1 2,8 
Encode-decode  2,3