Atomic ets

Ulf Wiger (AL/EAB) ulf.wiger@REDACTED
Tue Dec 20 11:42:10 CET 2005

Bengt Kleberg wrote:
> is this still true?

Don't know. Some very naiive measurements indicated that
the break-even point on my SunBLADE is about 90 elements
(comparing worst-case lists:keysearch() with ets:lookup(),
which is probably not a fair comparison. 

The outcome is probably dependent on hardware architecture.

> what would the number be for the list alternatives (dict, 
> gb_trees, etc)?

That depends on what you're doing. And it also depends on
gc cost, which requires a much more ambitious benchmark
to get a handle on. The worst-case cost for a gb_trees:
lookup seemed to equal ets:lookup() at around 900 
elements, but that's of course also assuming that you're
not going to pass the data around. I once wrote an
erlang library that was fully API-compatible with ets
(including named tables). It was up to 30x slower than
ets, but the cost was almost totally driven by the
adaptations to the ets API. The back-end storage
mechanism could even be faster in some cases.

I'd say that the main reason for having different 
access structure implementations is that they have
different semantics and are good at different things.
Spend some time getting acquainted with the available
alternatives. Each one should have a section in the 
manual about what it's good for, and how well it 

How well the different solutions stack up in this 
regard (the documented characteristics) varies:

- gb_sets: excellent Complexity note with examples
- gb_trees: well, it does say that it's logarithmic
- lists: says nothing, but perhaps it doesn't need to?
- sets: only says that the representation (and, I
        gather, also the complexity?) is undefined.
- dict: same as for sets.
- ets: briefly explains the characteristics of set 
       and ordered_set


> -----Original Message-----
> From: owner-erlang-questions@REDACTED 
> [mailto:owner-erlang-questions@REDACTED] On Behalf Of Bengt Kleberg
> Sent: den 20 december 2005 10:04
> To: erlang-questions@REDACTED
> Subject: Re: Atomic ets
> On 2005-12-20 09:59, Ulf Wiger (AL/EAB) wrote:
> ...deleted
> > is. Can you? BTW, 20 items used to be roughly the break-even point 
> > between a list and ets. After that, ets was superior for random 
> > access.
> bengt

More information about the erlang-questions mailing list