M4 SMTP - markov2/perl5-Mail-Box GitHub Wiki

Slowness in Net::SMTP

https://github.com/markov2/perl5-Mail-Transport/issues/2

  • Mail::Message prints to IO::Lines, and then uses that as data source for datasend(). This is slow. Switch to "open my $out" (which did not exist when Mail::Box was written) speeds datasend up.
  • Mail::Transport::SMTP is based on Net::SMTP, which is based on Net::Cmd. It's implementation of 'datasend()' is too careful with the data it receives.

Here some details: (take the numbers with a grain of salt: I did run all these tests only once... not an average for many runs. "wait" is especially unstable)

Current code:

real 61.6s          elapse
user 45.4s
sys   1.2s
wait 15.0s (!)      elapse - user - sys

Total sent = 23.9s  elapse

Use 'open my $fh':

real 59.1s
user 42.6s          2.8s faster
sys   1.3s
wait 16.3s

total sent = 20.3s  3.6s faster

use 'open my $fh' + 'datafast':

real 54.6s          7.0s faster than current
user 39.0s
sys   1.3s
wait 14.3s          slightly more efficient

total sent = 16.7s  7.2s faster than current

Expected: "wait" time is close to 100% for internet traffic. Improvement:

elapse:  16.7/23.9               = 70% of the elapse time
perl:    (16.7-14.3)/(23.9-15.0) = 27% of the compute time

"Start time" of the script is 14.6s. After that, it sends 10 large messages. Without changes to the rebuild():

Current code: (61.6-14.6)/10 = 4.7s elapse per message With changes: (54.6-14.6)/10 = 4.0s elapse per message ------- - 15% elapse shorter