[erlang-questions] optimizing an asynchronous architecture

Joel Reymont joelr1@REDACTED
Wed Jul 8 19:30:32 CEST 2009


On Jul 7, 2009, at 9:40 PM, Jeroen Koops wrote:

> Not that I have any experience with it, but did you have a look at  
> the sequential tracing facility (http://www.erlang.org/doc/man/seq_trace.html)? 
>  Looks like it does pretty much what you need.


I rolled my own version of sequential tracing by wrapping a message up  
in another message with a timestamp at each stage. This way I can  
calculate how long it took the message to get from process to process,  
a total of 5 stages. The pipeline stops right before gen_tcp:send but  
it's still only 50% the time I calculate by other means, described  
below.

I can't believe that 50% of the time is spent going through the TCP  
stack so perhaps my testing methodology is flawed.

I need to broadcast my message once all the bots have connected to the  
server and subscribed to a particular topic. To make this happen, I  
have a "barrier" process that I start with the total number of bots I  
plan to run. Bots ping the barrier once they are ready which  
decrements the counter. Once the counter is 0 the barrier process exits.

Bots monitor the barrier process to get notified of its exit and so  
does the broadcasting process. A single message is broadcast to all  
bots once the barrier opens. Bots log the time when they received the  
barrier exit notification as well as the time when they receive the  
message itself.

The difference is what I compare against the "pipeline length" at the  
beginning of this message. It turns out that a message takes twice as  
long to get to a bot as the total time it takes a message to travel  
through all stages.

Is it safe to assume that erlang:monitor is wicked fast and has no  
problem notifying 10-20k processes monitoring a single one? Are there  
better ways to implement a "barrier" in Erlang?

Is there anything else, apart from gen_tcp:send, that could be  
accounting for that 50% difference between bot notification time and  
message travel time within the server?

	Thanks, Joel

---
Mac hacker with a performance bent
http://www.linkedin.com/in/joelreymont



More information about the erlang-questions mailing list