[erlang-questions] Benchmarking Erlang: Deathmatch of gb_trees, dict, ets, mnesia ... and registered names
Joel Reymont
joelr1@REDACTED
Thu Oct 9 14:15:54 CEST 2008
On Oct 9, 2008, at 1:05 PM, Ulf Wiger (TN/EAB) wrote:
> How many nodes did you have there?
Same 4 nodes.
> It seems as if you have quite a large variation on
> the populate benchmark - esp if the first test above
> is with only one node.
No, there's no variation, it's the same 4 nodes.
> Anyway, the worst part of global's algorithm is the
> random backoff at lock conflicts, but that shouldn't
> affect you in this particular case.
Here's the version of the code I'm testing with 50 nodes now.
Use start_slaves/1 with your desired number of nodes and try test/1
right after. I think it will be tomorrow before my 50 nodes and 100k
processes test is done.
---
-module(map8).
-behaviour(gen_server).
-export([init/1, handle_call/3, handle_cast/2,
handle_info/2, terminate/2, code_change/3]).
-export([start/1, test/1, populate/1, lookup/1, start_slaves/1]).
start(N) ->
gen_server:start({global, N}, map8, [], []).
init([]) ->
{ok, none}.
terminate(_, _) ->
ok.
handle_cast(stop, Data) ->
{stop, normal, Data}.
handle_call(Event, From, Data) ->
error_logger:info_report([{module, ?MODULE},
{line, ?LINE},
{self, self()},
{event, Event},
{from, From}
]),
{noreply, Data}.
handle_info(Info, Data) ->
error_logger:info_report([{module, ?MODULE},
{line, ?LINE},
{self, self()},
{message, Info}]),
{noreply, Data}.
code_change(_, Data, _) ->
{ok, Data}.
test(N) ->
{T1, _} = timer:tc(map8, populate, [N]),
{T2, _} = timer:tc(map8, lookup, [N]),
io:format("Populate: ~.4. f~n", [T1 / 1000000]),
io:format("Lookup: ~.4. f~n", [T2 / 1000000]),
stop(N).
populate(0) ->
ok;
populate(N) ->
{ok, _} = start(N),
populate(N - 1).
lookup(0) ->
ok;
lookup(N) ->
P = global:whereis_name(N),
true = is_process_alive(P),
lookup(N - 1).
stop(0) ->
ok;
stop(N) ->
gen_server:cast({global, N}, stop),
stop(N - 1).
start_slaves(0) ->
ok;
start_slaves(N) ->
Name = list_to_atom(integer_to_list(N)),
Args = "",
Node = start_slave_node(Name, Args),
io:format("~p up running~n", [Node]),
timer:sleep(100),
start_slaves(N - 1).
start_slave_node(Name, Args) ->
{ok, Node} = slave:start_link(net_adm:localhost(), Name, Args),
Node.
--
wagerlabs.com
More information about the erlang-questions
mailing list