[erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names
Thu Oct 9 13:08:01 CEST 2008
I'm still trying to figure out how to optimize pid <-> integer mapping
and I thought I'd try several approaches. My goal is to lookup a
process id as quickly as possible given an integer.
My system is a Mac Pro 2x2.8Ghz Quad Xeon, 14Gb of memory
Erlang (BEAM) emulator version 5.6.3 [source] [smp:8] [async-threads:
Here's my set of timings, code at the end of this message.
Dict seems to be the winner for 100K values. What's particularly
interesting to me is that gb_trees, dict and ets give take about the
same time to look up 1 mil. values. Is there an explanation?
map4, map5 and map6 that test mnesia ram_copies, disc_only_copies and
ram_copies in a 2-node setup. There seems to be no overhead compared
to ets, though. Can't explain this either.
The absolutely bizarre and surprising discovery are the timings for
registered names. On a hunch, I thought I'd try to register a process
under its id. This way I could just send messages to that id from any
node in the cluster, without having to go through a separate
%% registered names
It seems that registering processes under their integer id is the way
to go. Am I right in my conclusion? Are there any pitfalls with going
Between players and games, I would most likely have <100K ids
registered at any given time.
Code in follow-up messages, registered names first, then gb_trees,
dict, ets and mnesia.
More information about the erlang-questions