[erlang-questions] dict slower than ets?

Ulf Wiger ulf.wiger@REDACTED
Mon Aug 24 09:33:48 CEST 2009

Wanglei wrote:
> dict write x 10000 
>  > {T,D} = timer:tc(test,dict_read,[]).
> {86177,...
> dict read x 10000 
>  > timer:tc(test,dict_read,[D]).
> {17260,

Yes, for small objects, dict is slower than ets.
For larger objects, the copying overhead of using ets
will tip the scales in dict's favor* - at least for a non-
shared dictionary. If you need concurrent access to the
dictionary, you need to keep the dict in a separate process,
which will incur the same copying cost as for ets.

* While both solutions use constant-time algorithms,
dict will also suffer from garbage collection overhead,
which is roughly proportional to the size of the live data
set. Ets tables are not garbage collected.

Ulf W
Ulf Wiger
CTO, Erlang Training & Consulting Ltd

More information about the erlang-questions mailing list