spf-discuss
[Top] [All Lists]

Re: Updates on SRS crypto

2004-02-11 17:50:58

On Feb 11, 2004, at 2:18 PM, Seth Goodman wrote:
Since the MTA has to do other things than simply calculate a hash function, I respectfully disagree. SPF is supposed to be lightweight. Every task you add decreases system capacity. Ask the MTA vendors if they have CPU cycles
to burn.

I can chime in there:

-- being stupid test --
use Mail::SRS;
use Time::HiRes qw/gettimeofday tv_interval/;

my $count = shift || 10000;
my $erate = shift || 1000000;

my $srs = new Mail::SRS(
        Secret    => "soopers3cr3t!",    # scalar or array
        MaxAge    => 49,          # days
                );
my $sender = q{joe(_dot_)frank(_dot_)doe(_at_)example(_dot_)org};
my $alias =  q{john(_dot_)ed(_dot_)smith(_at_)example(_dot_)com};

my $t0 = [gettimeofday];
my $i;
for($i=0;$i<$count;$i++) {
  my $srsaddress = $srs->forward($sender, $alias);
}
my $elapsed = tv_interval ( $t0, [gettimeofday]);

my $mcost = $elapsed / $count;
print  "CPU seconds/message: $mcost\n";
printf "%d messages/hour = %0.1f seconds!\n", $erate, $mcost*$erate;

-- end stupid test --

So, if I run this on a development server here, I get:
; perl ./t.pl 10000 1000000
CPU seconds/message: 0.0004080458
2000000 messages/hour = 820.8 seconds!

Extrapolated, that means that 22% of all my time sending mail is spent on the CPU doing SRS.

Obviously an implementation aimed solely at performance could increase this by a factor of 10 (probably). But that is 2%, which is a damn lot. There are a lot of other functions that MTAs perform and every 2% counts. Of course, if we end up having to use the DB backing store, this is going to unravel.

This test was whipped up in a few seconds, feel free to poke holes in it -- I'll take no offense.

// Theo Schlossnagle
// Principal Engineer -- http://www.omniti.com/~jesus/
// Postal Engine -- http://www.postalengine.com/
// Ecelerity: fastest MTA on earth


<Prev in Thread] Current Thread [Next in Thread>