[erlang-questions] Low disk logging performance in SMP

chaitanya Chalasani <>
Fri Apr 24 16:23:19 CEST 2009


Hi,

I am facing performance issue with my file logger. The file logger is an
event handler holding the file reference is its state. The performance
of the module is way ahead in the smp disabled erl shell compared with
default smp enabled erl shell.

I tried ...
case#1
Erlang R13B (erts-5.7.1) [source] [rq:1] [async-threads:0] [hipe]
[kernel-poll:false]

Eshell V5.7.1  (abort with ^G)
1> testLogger:start("test.log").
true
2> testLogger:write("Testing...",1000000).
{ok,done}
3>

and 

case#2
Erlang R13B (erts-5.7.1) [source] [smp:2:2] [rq:2] [async-threads:0]
[hipe] [kernel-poll:false]

Eshell V5.7.1  (abort with ^G)
1> testLogger:start("test.log").
true
2> testLogger:write("Testing...",1000000).
{ok,done}
3>


What I observed was -
Case 1: 
   1. The testLogger:write("Testing...",1000000) did not return back the
control to the shell until all the messages are written to log.
    2. The data was written at 400 KB/s

Case 2:
    1. The testLogger:write("Testing...",1000000) return back the
control to the shell with {ok, done} after a short while but the
messages where being written to log even after that.
    2. The data was written at 4 KB/s
    3. I checked in the pman tool it shows current funtion as
io:wait_io_mon_reply/2 and the messages in the message pool are about
880k.

Below is the code which I tested.

start(Filename) ->
register(testLogger,spawn(testLogger,listener,[Filename])).

listener(Filename) ->
	case file:open(Filename,[append]) of
		{ok,Fd} -> listener(Fd,0);
		{error,Reason} -> error_logger:error_msg(Reason)
	end.

listener(Fd,N) ->
	receive
		{data,Data} -> file:write(Fd,Data), listener(Fd,N+1);
		{count,From} -> From ! {count,N}, listener(Fd,N);
		{stop,From} -> 	From ! {stop,success}
	end.

write(_Data,0) -> {ok,done};
write(Data,N) ->  testLogger ! {data,Data}, write(Data,N-1).

Is there a problem with my code or is it a known issue?
	
------
CHAITANYA CHALASANI
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090424/d92be5ad/attachment.html>


More information about the erlang-questions mailing list