leons has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks
I hope someone can give me some advice on the following. Right now
I'm writing a program which will be used for load-test purposes on
one of our mailservers here.
The program can be configured to send a certain amount of messages
over a configurable number of sessions to another system. (No, this
is not for spam-purposes ..... just to make sure ;-)
At first I wrote the program in a kind of way that it would open the
preferred number of sessions and then it would send the messages over
these sessions. This would happen then, more or less, sequentially
I didn't take me long to figure out that it would definitely be a
lot quicker if I were to fork the same number of processes as there
needed to be sessions. Which would then, each start it's own session
to the mailserver
After that came the problem. The program had to have a progress-counter
which would state the number of messages that had been sent. The first
thing I tried was having all the child processes write a '.' to a text-
file, which would then be read by the parent (every 5 seconds or so) for
as long as the number of dots was less than the number of messages that
had need to be sent.
This worked perfectly although it wasn't a very elegant way of doing this,
I think. Then someone proposed to use signals ... which is what I did.
Every child would send a SIGUSR2 to the parent each time a message was sent.
But strange enough the total of signals sent to the parent never came close
to the actual number of messages sent. Not knowing how this signalling stuff
actually worked, someone told me a signal was nothing more than some flag in a
register. Which perfectly explained the fact that there were 'messages missing'
... this was ofcourse because of the fact that some signals were send simulta-
neously.
So I hope someone can give me some advice on this timing/signalling problem ...
or should I just stick with the Dot-solution ? Which, I must confess,
doesn't have my preference
Any advice is more than welcome !
Thanks, Leon
I hope someone can give me some advice on the following. Right now
I'm writing a program which will be used for load-test purposes on
one of our mailservers here.
The program can be configured to send a certain amount of messages
over a configurable number of sessions to another system. (No, this
is not for spam-purposes ..... just to make sure ;-)
At first I wrote the program in a kind of way that it would open the
preferred number of sessions and then it would send the messages over
these sessions. This would happen then, more or less, sequentially
I didn't take me long to figure out that it would definitely be a
lot quicker if I were to fork the same number of processes as there
needed to be sessions. Which would then, each start it's own session
to the mailserver
After that came the problem. The program had to have a progress-counter
which would state the number of messages that had been sent. The first
thing I tried was having all the child processes write a '.' to a text-
file, which would then be read by the parent (every 5 seconds or so) for
as long as the number of dots was less than the number of messages that
had need to be sent.
This worked perfectly although it wasn't a very elegant way of doing this,
I think. Then someone proposed to use signals ... which is what I did.
Every child would send a SIGUSR2 to the parent each time a message was sent.
But strange enough the total of signals sent to the parent never came close
to the actual number of messages sent. Not knowing how this signalling stuff
actually worked, someone told me a signal was nothing more than some flag in a
register. Which perfectly explained the fact that there were 'messages missing'
... this was ofcourse because of the fact that some signals were send simulta-
neously.
So I hope someone can give me some advice on this timing/signalling problem ...
or should I just stick with the Dot-solution ? Which, I must confess,
doesn't have my preference
Any advice is more than welcome !
Thanks, Leon
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Using signals in Perl
by kal (Hermit) on Mar 28, 2001 at 20:17 UTC | |
Re: Using signals in Perl
by merlyn (Sage) on Mar 28, 2001 at 20:48 UTC | |
Re: Using signals in Perl
by mikfire (Deacon) on Mar 28, 2001 at 20:15 UTC | |
Re: Using signals in Perl
by physi (Friar) on Mar 28, 2001 at 20:21 UTC | |
Re (tilly) 1: Using signals in Perl
by tilly (Archbishop) on Mar 28, 2001 at 21:56 UTC | |
Re: Using signals in Perl
by Albannach (Monsignor) on Mar 28, 2001 at 20:15 UTC | |
Re: Using signals in Perl
by suaveant (Parson) on Mar 28, 2001 at 20:09 UTC | |
Re: Using signals in Perl
by ChOas (Curate) on Mar 29, 2001 at 13:50 UTC |
Back to
Seekers of Perl Wisdom