Erlang Efficiency quesitons

Ulf Wiger <>
Wed Mar 14 18:10:06 CET 2001


On Wed, 14 Mar 2001, Francesco Cesarini wrote:

>I was wondering if there is any documentation on how to write efficient
>Erlang programs based on the virtual machine delivered in with OTP R7?

Why, Francesco, don't you know that we shouldn't worry about making
our programs fast?!  ;-)

To my knowledge, there is no such document.

>Many odds and ends have been discussed on this list, but I have been
>unable to find something comprehensive.

I've attached some old documents that we wrote a while back on
performance. I must warn you that we don't stand by some of the
recommendations made within anymore. Special warning against foregoing
gen_server for hard-coded servers. This is really not a good idea, and
not nearly as relevant now as it was then. The overhead of gen_server
is pretty insignificant.

Other bad advice is using integers instead of atoms.

Having said this, there are some good ideas in there as well. (:

The compiler nowadays does a pretty good job of optimizing case
and function clauses and also removes dead code. This is good news
for those of us who are interested in squeezing every drop of
performance out of our Erlang programs.

I also know that higher-order functions are very efficient now. This
also means that old warnings about list comprehensions are no longer
quite as valid.

All in all, the document helps to demonstrate that any advice on
writing fast code, other than selecting efficient algorithms, is
something that needs to be updated frequently. Nonetheless, this kind
of document is needed.


>Another example had to do with avoiding the dynamic creation of
>atoms as there was no GC for them. Is that still the case?

Yes, this is still true.

However, if I recall correctly, BEAM doesn't have a hard limit on the
size of the atom table, so you can have quite a few atoms, provided
you have enough memory.

/Uffe
-- 
Ulf Wiger                                    tfn: +46  8 719 81 95
Senior System Architect                      mob: +46 70 519 81 95
Strategic Product & System Management    ATM Multiservice Networks
Data Backbone & Optical Services Division      Ericsson Telecom AB
-------------- next part --------------
A non-text attachment was scrubbed...
Name: performance.tar.gz
Type: application/x-gzip
Size: 19493 bytes
Desc: performance.tar.gz
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20010314/f8600b9f/attachment.bin>


More information about the erlang-questions mailing list