[erlang-questions] Why should you ever use atoms?

Richard A. O'Keefe ok@REDACTED
Mon Oct 12 01:22:16 CEST 2015


For what it's worth, SWI Prolog now has a lock-free
atom symbol table and has garbage collected the atom
table for a very long time.

It is long past time for Erlang's fixed size bottlenecking
atom table to be replaced by something less troublesome.

There is an EEP proposing an approach to lots-of-atoms
based on the LOGIX implementation of Flat Concurrent Prolog.
From what I've heard, the SWI Prolog lock-free atom table
sounds superior.

For what it's worth, benchmarking is always able to surprise
us.  I benchmarked comparing atoms, comparing strings, and
comparing binaries.
   Atoms:    1.0
   Strings:  1.3
   Binaries: 1.4
With hindsight, it was obvious: most string comparisons fail
at the first character.  Of course, if you have lots of
strings (maybe file names or URIs) with long common prefixes,
comparing those is going to be costly, but you're not going to
use atoms for those anyway, and you should probably use a
data structure like A/B/C -> [C,B,A] so that the different
bits get compared first.





More information about the erlang-questions mailing list