[erlang-questions] reductions galore

Angel Alvarez clist@REDACTED
Wed Feb 24 11:56:52 CET 2010


El Miércoles, 24 de Febrero de 2010 11:45:01 Anthony Shipman escribió:
> Here is some code from experimenting with profiling.
> 
> run() ->
>     Keys = lists:seq(1, 2000),
> 
>     Child = spawn(fun() -> receive after 5000 -> ok end end),
>     %Child = spawn(fun() -> receive _ -> ok end end),
> 
> 
>     {reductions,R1} = process_info(self(), reductions),
>     lists:foreach(fun(K) -> Child!K end, Keys),
>     {reductions,R2} = process_info(self(), reductions),
> 
>     io:format("reductions ~p~n", [R2 - R1]),
>     ok.
> 
> 
> It prints
> 	reductions 3344538
> 
> If I change the child process to the second one with the receive X I get
> 	reductions 6334
> 
> In the first case messages are queuing in the child process. But can the 
> reduction count be real?
> 

IIRC reductions are bumped for a process sending large amount of messages filling up other porcess queue.
This is a counter measure to allow receiver process messages in case of flooding...

You should read:

http://www.erlang.org/cgi-bin/ezmlm-cgi/4/18382


for the classical "log process flooding" problem.

/angel

-- 
Este correo no tiene dibujos. Las formas extrañas en la pantalla son letras.
__________________________________________

Clist UAH a.k.a Angel
__________________________________________
If debugging is the process of removing bugs, then programming must be the process of putting them in. Dijkstra.


More information about the erlang-questions mailing list