[erlang-questions] Some facts about Erlang and SMP

Kenneth Lundin <>
Wed Sep 17 21:38:40 CEST 2008

> ...
> Kenneth,
> Do you have any insight into why I might be seeing much higher CPU cost for
> SMP on linux vs. Mac?  Is there some difference in the lock implementations
> that might be relevant?

In general I don't think the measured CPU cost on different operating
systems is a reliable way of measuring how well a program performs. I
think is is more reliable to create measurements where the wall clock
is used , e.g how long time does a certain operation take or how many
calls per second can a system handle etc.

Anyway the lock mechanisms used in the VM are:

pthread mutex, for the run-queue
pthread rwlock, for ets-tables

inline spinlock and inline atomics
these are part of the VM source code, for x86 32 and 64 bit, ppc 32
bit, sparc 32 and 64 bit. For other architectures the build will fall
back to pthread spinlock and if that
does not exist there is another fall back to pthread mutex.

Linux and Mac OSx for x86 will use exactly the same spinlock and atomics but the
pthread mutex and rwlock will be OS specific as well as the thread
scheduling in general and this can of course give differences in
performance even on the same HW.

/Kenneth Erlang/OTP, Ericsson
> -kevin

More information about the erlang-questions mailing list