← Index
NYTProf Performance Profile   « line view »
For /usr/local/bin/sa-learn
  Run on Sun Nov 5 02:36:06 2017
Reported on Sun Nov 5 02:56:23 2017

Filename/usr/local/lib/perl5/site_perl/Mail/SpamAssassin/DBBasedAddrList.pm
StatementsExecuted 18514173 statements in 616s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
17531413s616sMail::SpamAssassin::DBBasedAddrList::::remove_entryMail::SpamAssassin::DBBasedAddrList::remove_entry
92401881135.8s35.8sMail::SpamAssassin::DBBasedAddrList::::CORE:regcompMail::SpamAssassin::DBBasedAddrList::CORE:regcomp (opcode)
92403632120.0s20.0sMail::SpamAssassin::DBBasedAddrList::::CORE:matchMail::SpamAssassin::DBBasedAddrList::CORE:match (opcode)
220931171ms575msMail::SpamAssassin::DBBasedAddrList::::get_addr_entryMail::SpamAssassin::DBBasedAddrList::get_addr_entry
212131165ms245msMail::SpamAssassin::DBBasedAddrList::::add_scoreMail::SpamAssassin::DBBasedAddrList::add_score
1111.08ms1.43msMail::SpamAssassin::DBBasedAddrList::::BEGIN@26Mail::SpamAssassin::DBBasedAddrList::BEGIN@26
111241µs4.18msMail::SpamAssassin::DBBasedAddrList::::new_checkerMail::SpamAssassin::DBBasedAddrList::new_checker
111185µs5.67sMail::SpamAssassin::DBBasedAddrList::::finishMail::SpamAssassin::DBBasedAddrList::finish
11174µs98µsMail::SpamAssassin::DBBasedAddrList::::newMail::SpamAssassin::DBBasedAddrList::new
22161µs61µsMail::SpamAssassin::DBBasedAddrList::::CORE:umaskMail::SpamAssassin::DBBasedAddrList::CORE:umask (opcode)
11149µs61µsMail::SpamAssassin::DBBasedAddrList::::BEGIN@20Mail::SpamAssassin::DBBasedAddrList::BEGIN@20
11148µs111µsMail::SpamAssassin::DBBasedAddrList::::BEGIN@23Mail::SpamAssassin::DBBasedAddrList::BEGIN@23
11143µs266µsMail::SpamAssassin::DBBasedAddrList::::BEGIN@28Mail::SpamAssassin::DBBasedAddrList::BEGIN@28
11133µs152µsMail::SpamAssassin::DBBasedAddrList::::BEGIN@27Mail::SpamAssassin::DBBasedAddrList::BEGIN@27
11130µs2.34msMail::SpamAssassin::DBBasedAddrList::::BEGIN@24Mail::SpamAssassin::DBBasedAddrList::BEGIN@24
11129µs68µsMail::SpamAssassin::DBBasedAddrList::::BEGIN@21Mail::SpamAssassin::DBBasedAddrList::BEGIN@21
11129µs35µsMail::SpamAssassin::DBBasedAddrList::::BEGIN@22Mail::SpamAssassin::DBBasedAddrList::BEGIN@22
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# <@LICENSE>
2# Licensed to the Apache Software Foundation (ASF) under one or more
3# contributor license agreements. See the NOTICE file distributed with
4# this work for additional information regarding copyright ownership.
5# The ASF licenses this file to you under the Apache License, Version 2.0
6# (the "License"); you may not use this file except in compliance with
7# the License. You may obtain a copy of the License at:
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16# </@LICENSE>
17
18package Mail::SpamAssassin::DBBasedAddrList;
19
20271µs272µs
# spent 61µs (49+12) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@20 which was called: # once (49µs+12µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 20
use strict;
# spent 61µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@20 # spent 12µs making 1 call to strict::import
21272µs2106µs
# spent 68µs (29+38) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@21 which was called: # once (29µs+38µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 21
use warnings;
# spent 68µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@21 # spent 38µs making 1 call to warnings::import
22285µs242µs
# spent 35µs (29+6) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@22 which was called: # once (29µs+6µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 22
use bytes;
# spent 35µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@22 # spent 6µs making 1 call to bytes::import
23282µs2174µs
# spent 111µs (48+63) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@23 which was called: # once (48µs+63µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 23
use re 'taint';
# spent 111µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@23 # spent 63µs making 1 call to re::import
24286µs24.64ms
# spent 2.34ms (30µs+2.31) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@24 which was called: # once (30µs+2.31ms) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 24
use Fcntl;
# spent 2.34ms making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@24 # spent 2.31ms making 1 call to Exporter::import
25
262384µs11.43ms
# spent 1.43ms (1.08+356µs) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@26 which was called: # once (1.08ms+356µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 26
use Mail::SpamAssassin::PersistentAddrList;
# spent 1.43ms making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@26
27274µs2272µs
# spent 152µs (33+119) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@27 which was called: # once (33µs+119µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 27
use Mail::SpamAssassin::Util qw(untaint_var);
# spent 152µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@27 # spent 119µs making 1 call to Exporter::import
2821.59ms2488µs
# spent 266µs (43+222) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@28 which was called: # once (43µs+222µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 28
use Mail::SpamAssassin::Logger;
# spent 266µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@28 # spent 222µs making 1 call to Exporter::import
29
30113µsour @ISA = qw(Mail::SpamAssassin::PersistentAddrList);
31
32###########################################################################
33
34
# spent 98µs (74+23) within Mail::SpamAssassin::DBBasedAddrList::new which was called: # once (74µs+23µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 2 of (eval 1135)[Mail/SpamAssassin/Plugin/TxRep.pm:1581]
sub new {
3512µs my $class = shift;
3612µs $class = ref($class) || $class;
37121µs123µs my $self = $class->SUPER::new(@_);
# spent 23µs making 1 call to Mail::SpamAssassin::PersistentAddrList::new
38114µs $self->{class} = $class;
3912µs bless ($self, $class);
40114µs $self;
41}
42
43###########################################################################
44
45
# spent 4.18ms (241µs+3.93) within Mail::SpamAssassin::DBBasedAddrList::new_checker which was called: # once (241µs+3.93ms) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 1590 of Mail/SpamAssassin/Plugin/TxRep.pm
sub new_checker {
4612µs my ($factory, $main) = @_;
4712µs my $class = $factory->{class};
48
49113µs my $self = {
50 'main' => $main,
51 'accum' => { },
52 'is_locked' => 0,
53 'locked_file' => ''
54 };
55
5619µs my @order = split (' ', $main->{conf}->{auto_whitelist_db_modules});
5719µs1191µs untaint_var(\@order);
# spent 191µs making 1 call to Mail::SpamAssassin::Util::untaint_var
58116µs175µs my $dbm_module = Mail::SpamAssassin::Util::first_available_module (@order);
# spent 75µs making 1 call to Mail::SpamAssassin::Util::first_available_module
5912µs if (!$dbm_module) {
60 die "auto-whitelist: cannot find a usable DB package from auto_whitelist_db_modules: " .
61 $main->{conf}->{auto_whitelist_db_modules}."\n";
62 }
63
64181µs156µs my $umask = umask ~ (oct($main->{conf}->{auto_whitelist_file_mode}));
# spent 56µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::CORE:umask
65
66 # if undef then don't worry -- empty hash!
6714µs if (defined($main->{conf}->{auto_whitelist_path})) {
6819µs1559µs my $path = $main->sed_path($main->{conf}->{auto_whitelist_path});
# spent 559µs making 1 call to Mail::SpamAssassin::sed_path
6912µs my ($mod1, $mod2);
70
71115µs11.65ms if ($main->{locker}->safe_lock
72 ($path, 30, $main->{conf}->{auto_whitelist_file_mode}))
73 {
7417µs $self->{locked_file} = $path;
7513µs $self->{is_locked} = 1;
7614µs ($mod1, $mod2) = ('R/W', O_RDWR | O_CREAT);
77 }
78 else {
79 $self->{is_locked} = 0;
80 ($mod1, $mod2) = ('R/O', O_RDONLY);
81 }
82
83120µs118µs dbg("auto-whitelist: tie-ing to DB file of type $dbm_module $mod1 in $path");
# spent 18µs making 1 call to Mail::SpamAssassin::Logger::dbg
84
85115µs11.12ms ($self->{is_locked} && $dbm_module eq 'DB_File') and
86 Mail::SpamAssassin::Util::avoid_db_file_locking_bug($path);
87
88250µs1262µs if (! tie %{ $self->{accum} }, $dbm_module, $path, $mod2,
# spent 262µs making 1 call to DB_File::TIEHASH
89 oct($main->{conf}->{auto_whitelist_file_mode}) & 0666)
90 {
91 my $err = $!; # might get overwritten later
92 if ($self->{is_locked}) {
93 $self->{main}->{locker}->safe_unlock($self->{locked_file});
94 $self->{is_locked} = 0;
95 }
96 die "auto-whitelist: cannot open auto_whitelist_path $path: $err\n";
97 }
98 }
99115µs15µs umask $umask;
100
10114µs bless ($self, $class);
102115µs return $self;
103}
104
105###########################################################################
106
107
# spent 5.67s (185µs+5.67) within Mail::SpamAssassin::DBBasedAddrList::finish which was called: # once (185µs+5.67s) by Mail::SpamAssassin::Plugin::TxRep::finish at line 1658 of Mail/SpamAssassin/Plugin/TxRep.pm
sub finish {
10812µs my $self = shift;
10917µs17µs dbg("auto-whitelist: DB addr list: untie-ing and unlocking");
# spent 7µs making 1 call to Mail::SpamAssassin::Logger::dbg
110224.8ms124.7ms untie %{$self->{accum}};
# spent 24.7ms making 1 call to DB_File::DESTROY
111126µs if ($self->{is_locked}) {
112117µs118µs dbg("auto-whitelist: DB addr list: file locked, breaking lock");
# spent 18µs making 1 call to Mail::SpamAssassin::Logger::dbg
113119µs15.64s $self->{main}->{locker}->safe_unlock ($self->{locked_file});
11419µs $self->{is_locked} = 0;
115 }
116 # TODO: untrap signals to unlock the db file here
117}
118
119###########################################################################
120
121
# spent 575ms (171+404) within Mail::SpamAssassin::DBBasedAddrList::get_addr_entry which was called 2209 times, avg 260µs/call: # 2207 times (170ms+404ms) by Mail::SpamAssassin::Plugin::TxRep::get_sender at line 1476 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 260µs/call # once (90µs+307µs) by Mail::SpamAssassin::Plugin::TxRep::modify_reputation at line 1545 of Mail/SpamAssassin/Plugin/TxRep.pm # once (77µs+165µs) by Mail::SpamAssassin::Plugin::TxRep::modify_reputation at line 1555 of Mail/SpamAssassin/Plugin/TxRep.pm
sub get_addr_entry {
122220914.4ms my ($self, $addr, $signedby) = @_;
123
124220913.4ms my $entry = {
125 addr => $addr,
126 };
127
1282209252ms2209207ms $entry->{count} = $self->{accum}->{$addr} || 0;
# spent 207ms making 2209 calls to DB_File::FETCH, avg 94µs/call
1292209219ms2209174ms $entry->{totscore} = $self->{accum}->{$addr.'|totscore'} || 0;
# spent 174ms making 2209 calls to DB_File::FETCH, avg 79µs/call
130
131220932.4ms220922.6ms dbg("auto-whitelist: db-based $addr scores ".$entry->{count}.'/'.$entry->{totscore});
# spent 22.6ms making 2209 calls to Mail::SpamAssassin::Logger::dbg, avg 10µs/call
132220936.7ms return $entry;
133}
134
135###########################################################################
136
137
# spent 245ms (165+79.8) within Mail::SpamAssassin::DBBasedAddrList::add_score which was called 2121 times, avg 115µs/call: # 1608 times (128ms+61.1ms) by Mail::SpamAssassin::Plugin::TxRep::add_score at line 1510 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 118µs/call # 512 times (36.7ms+18.7ms) by Mail::SpamAssassin::Plugin::TxRep::remove_score at line 1533 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 108µs/call # once (83µs+25µs) by Mail::SpamAssassin::Plugin::TxRep::modify_reputation at line 1556 of Mail/SpamAssassin/Plugin/TxRep.pm
sub add_score {
13821219.83ms my($self, $entry, $score) = @_;
139
14021216.41ms $entry->{count} ||= 0;
14121214.54ms $entry->{addr} ||= '';
142
14321214.44ms $entry->{count}++;
14421217.00ms $entry->{totscore} += $score;
145
146212126.4ms212116.7ms dbg("auto-whitelist: add_score: new count: ".$entry->{count}.", new totscore: ".$entry->{totscore});
# spent 16.7ms making 2121 calls to Mail::SpamAssassin::Logger::dbg, avg 8µs/call
147
148212171.8ms212134.1ms $self->{accum}->{$entry->{addr}} = $entry->{count};
# spent 34.1ms making 2121 calls to DB_File::STORE, avg 16µs/call
149212173.6ms212129.0ms $self->{accum}->{$entry->{addr}.'|totscore'} = $entry->{totscore};
# spent 29.0ms making 2121 calls to DB_File::STORE, avg 14µs/call
150212131.6ms return $entry;
151}
152
153###########################################################################
154
155
# spent 616s (413+203) within Mail::SpamAssassin::DBBasedAddrList::remove_entry which was called 175 times, avg 3.52s/call: # 87 times (208s+108s) by Mail::SpamAssassin::Plugin::TxRep::check_reputation at line 1448 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 3.63s/call # 87 times (203s+93.5s) by Mail::SpamAssassin::Plugin::TxRep::check_reputation at line 1439 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 3.41s/call # once (2.14s+1.07s) by Mail::SpamAssassin::Plugin::TxRep::modify_reputation at line 1550 of Mail/SpamAssassin/Plugin/TxRep.pm
sub remove_entry {
156175367µs my ($self, $entry) = @_;
157
158175622µs my $addr = $entry->{addr};
1591756.36ms1753.41ms delete $self->{accum}->{$addr};
# spent 3.41ms making 175 calls to DB_File::DELETE, avg 19µs/call
1601755.78ms1752.70ms delete $self->{accum}->{$addr.'|totscore'};
# spent 2.70ms making 175 calls to DB_File::DELETE, avg 15µs/call
161
1621755.17ms1751.39ms if ($addr =~ /^(.*)\|ip=none$/) {
# spent 1.39ms making 175 calls to Mail::SpamAssassin::DBBasedAddrList::CORE:match, avg 8µs/call
163 # it doesn't have an IP attached.
164 # try to delete any per-IP entries for this addr as well.
165 # could be slow...
166175668µs my $mailaddr = $1;
167
1689240538426s18480551147s while (my ($key, $value) = each %{$self->{accum}}) {
# spent 87.5s making 9240188 calls to DB_File::FETCH, avg 9µs/call # spent 59.6s making 9240188 calls to DB_File::NEXTKEY, avg 6µs/call # spent 15.0ms making 175 calls to DB_File::FIRSTKEY, avg 86µs/call
169 # regex will catch both key and key|totscore entries and delete them
1709240188190s1848037655.7s if ($key =~ /^\Q${mailaddr}\E\|/) {
# spent 35.8s making 9240188 calls to Mail::SpamAssassin::DBBasedAddrList::CORE:regcomp, avg 4µs/call # spent 20.0s making 9240188 calls to Mail::SpamAssassin::DBBasedAddrList::CORE:match, avg 2µs/call
171 delete $self->{accum}->{$key};
172 }
173 }
174 }
175}
176
177###########################################################################
178
179110µs1;
 
# spent 20.0s within Mail::SpamAssassin::DBBasedAddrList::CORE:match which was called 9240363 times, avg 2µs/call: # 9240188 times (20.0s+0s) by Mail::SpamAssassin::DBBasedAddrList::remove_entry at line 170, avg 2µs/call # 175 times (1.39ms+0s) by Mail::SpamAssassin::DBBasedAddrList::remove_entry at line 162, avg 8µs/call
sub Mail::SpamAssassin::DBBasedAddrList::CORE:match; # opcode
# spent 35.8s within Mail::SpamAssassin::DBBasedAddrList::CORE:regcomp which was called 9240188 times, avg 4µs/call: # 9240188 times (35.8s+0s) by Mail::SpamAssassin::DBBasedAddrList::remove_entry at line 170, avg 4µs/call
sub Mail::SpamAssassin::DBBasedAddrList::CORE:regcomp; # opcode
# spent 61µs within Mail::SpamAssassin::DBBasedAddrList::CORE:umask which was called 2 times, avg 30µs/call: # once (56µs+0s) by Mail::SpamAssassin::DBBasedAddrList::new_checker at line 64 # once (5µs+0s) by Mail::SpamAssassin::DBBasedAddrList::new_checker at line 99
sub Mail::SpamAssassin::DBBasedAddrList::CORE:umask; # opcode