Filename | /usr/local/lib/perl5/site_perl/Mail/SpamAssassin/DBBasedAddrList.pm |
Statements | Executed 50062270 statements in 1763s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
470 | 3 | 1 | 1125s | 1761s | remove_entry | Mail::SpamAssassin::DBBasedAddrList::
24972836 | 1 | 1 | 97.1s | 97.1s | CORE:regcomp (opcode) | Mail::SpamAssassin::DBBasedAddrList::
24973306 | 2 | 1 | 53.8s | 53.8s | CORE:match (opcode) | Mail::SpamAssassin::DBBasedAddrList::
3216 | 1 | 1 | 678ms | 94562s | new_checker | Mail::SpamAssassin::DBBasedAddrList::
3220 | 3 | 1 | 300ms | 813ms | get_addr_entry | Mail::SpamAssassin::DBBasedAddrList::
2766 | 3 | 1 | 244ms | 303ms | add_score | Mail::SpamAssassin::DBBasedAddrList::
6432 | 2 | 1 | 24.0ms | 24.0ms | CORE:umask (opcode) | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 1.10ms | 1.44ms | BEGIN@26 | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 57µs | 69µs | BEGIN@20 | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 55µs | 1.02ms | finish | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 51µs | 116µs | BEGIN@23 | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 50µs | 73µs | new | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 38µs | 221µs | BEGIN@28 | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 35µs | 166µs | BEGIN@27 | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 34µs | 41µs | BEGIN@22 | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 30µs | 2.48ms | BEGIN@24 | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 30µs | 67µs | BEGIN@21 | Mail::SpamAssassin::DBBasedAddrList::
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 | |||||
18 | package Mail::SpamAssassin::DBBasedAddrList; | ||||
19 | |||||
20 | 2 | 71µs | 2 | 80µs | # spent 69µs (57+12) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@20 which was called:
# once (57µs+12µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 20 # spent 69µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@20
# spent 12µs making 1 call to strict::import |
21 | 2 | 79µs | 2 | 105µs | # spent 67µs (30+37) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@21 which was called:
# once (30µs+37µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 21 # spent 67µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@21
# spent 38µs making 1 call to warnings::import |
22 | 2 | 75µs | 2 | 48µs | # spent 41µs (34+7) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@22 which was called:
# once (34µs+7µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 22 # spent 41µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@22
# spent 7µs making 1 call to bytes::import |
23 | 2 | 74µs | 2 | 182µs | # spent 116µs (51+65) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@23 which was called:
# once (51µs+65µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 23 # spent 116µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@23
# spent 65µs making 1 call to re::import |
24 | 2 | 78µs | 2 | 4.93ms | # spent 2.48ms (30µs+2.45) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@24 which was called:
# once (30µs+2.45ms) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 24 # spent 2.48ms making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@24
# spent 2.45ms making 1 call to Exporter::import |
25 | |||||
26 | 2 | 426µs | 1 | 1.44ms | # spent 1.44ms (1.10+345µs) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@26 which was called:
# once (1.10ms+345µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 26 # spent 1.44ms making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@26 |
27 | 2 | 91µs | 2 | 296µs | # spent 166µs (35+131) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@27 which was called:
# once (35µs+131µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 27 # spent 166µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@27
# spent 131µs making 1 call to Exporter::import |
28 | 2 | 1.62ms | 2 | 403µs | # spent 221µs (38+182) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@28 which was called:
# once (38µs+182µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 28 # spent 221µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@28
# spent 182µs making 1 call to Exporter::import |
29 | |||||
30 | 1 | 14µs | our @ISA = qw(Mail::SpamAssassin::PersistentAddrList); | ||
31 | |||||
32 | ########################################################################### | ||||
33 | |||||
34 | # spent 73µs (50+23) within Mail::SpamAssassin::DBBasedAddrList::new which was called:
# once (50µs+23µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 2 of (eval 1135)[Mail/SpamAssassin/Plugin/TxRep.pm:1645] | ||||
35 | 1 | 2µs | my $class = shift; | ||
36 | 1 | 2µs | $class = ref($class) || $class; | ||
37 | 1 | 13µs | 1 | 23µs | my $self = $class->SUPER::new(@_); # spent 23µs making 1 call to Mail::SpamAssassin::PersistentAddrList::new |
38 | 1 | 14µs | $self->{class} = $class; | ||
39 | 1 | 2µs | bless ($self, $class); | ||
40 | 1 | 15µs | $self; | ||
41 | } | ||||
42 | |||||
43 | ########################################################################### | ||||
44 | |||||
45 | # spent 94562s (678ms+94561) within Mail::SpamAssassin::DBBasedAddrList::new_checker which was called 3216 times, avg 29.4s/call:
# 3216 times (678ms+94561s) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 1654 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 29.4s/call | ||||
46 | 3216 | 7.39ms | my ($factory, $main) = @_; | ||
47 | 3216 | 12.5ms | my $class = $factory->{class}; | ||
48 | |||||
49 | 3216 | 28.2ms | my $self = { | ||
50 | 'main' => $main, | ||||
51 | 'accum' => { }, | ||||
52 | 'is_locked' => 0, | ||||
53 | 'locked_file' => '' | ||||
54 | }; | ||||
55 | |||||
56 | 3216 | 35.9ms | my @order = split (' ', $main->{conf}->{auto_whitelist_db_modules}); | ||
57 | 3216 | 34.1ms | 3216 | 579ms | untaint_var(\@order); # spent 579ms making 3216 calls to Mail::SpamAssassin::Util::untaint_var, avg 180µs/call |
58 | 3216 | 32.3ms | 3216 | 368ms | my $dbm_module = Mail::SpamAssassin::Util::first_available_module (@order); # spent 368ms making 3216 calls to Mail::SpamAssassin::Util::first_available_module, avg 114µs/call |
59 | 3216 | 6.61ms | 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 | |||||
64 | 3216 | 56.4ms | 3216 | 10.9ms | my $umask = umask ~ (oct($main->{conf}->{auto_whitelist_file_mode})); # spent 10.9ms making 3216 calls to Mail::SpamAssassin::DBBasedAddrList::CORE:umask, avg 3µs/call |
65 | |||||
66 | # if undef then don't worry -- empty hash! | ||||
67 | 3216 | 17.5ms | if (defined($main->{conf}->{auto_whitelist_path})) { | ||
68 | 3216 | 36.8ms | 3216 | 62.1ms | my $path = $main->sed_path($main->{conf}->{auto_whitelist_path}); # spent 62.1ms making 3216 calls to Mail::SpamAssassin::sed_path, avg 19µs/call |
69 | 3216 | 6.57ms | my ($mod1, $mod2); | ||
70 | |||||
71 | 3216 | 47.0ms | 3216 | 94559s | if ($main->{locker}->safe_lock # spent 94559s making 3216 calls to Mail::SpamAssassin::Locker::UnixNFSSafe::safe_lock, avg 29.4s/call |
72 | ($path, 30, $main->{conf}->{auto_whitelist_file_mode})) | ||||
73 | { | ||||
74 | 161 | 981µs | $self->{locked_file} = $path; | ||
75 | 161 | 537µs | $self->{is_locked} = 1; | ||
76 | 161 | 633µs | ($mod1, $mod2) = ('R/W', O_RDWR | O_CREAT); | ||
77 | } | ||||
78 | else { | ||||
79 | 3055 | 16.0ms | $self->{is_locked} = 0; | ||
80 | 3055 | 13.5ms | ($mod1, $mod2) = ('R/O', O_RDONLY); | ||
81 | } | ||||
82 | |||||
83 | 3216 | 35.9ms | 3216 | 25.1ms | dbg("auto-whitelist: tie-ing to DB file of type $dbm_module $mod1 in $path"); # spent 25.1ms making 3216 calls to Mail::SpamAssassin::Logger::dbg, avg 8µs/call |
84 | |||||
85 | 3216 | 9.80ms | 161 | 185ms | ($self->{is_locked} && $dbm_module eq 'DB_File') and # spent 185ms making 161 calls to Mail::SpamAssassin::Util::avoid_db_file_locking_bug, avg 1.15ms/call |
86 | Mail::SpamAssassin::Util::avoid_db_file_locking_bug($path); | ||||
87 | |||||
88 | 6432 | 131ms | 3216 | 774ms | if (! tie %{ $self->{accum} }, $dbm_module, $path, $mod2, # spent 774ms making 3216 calls to DB_File::TIEHASH, avg 241µs/call |
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 | } | ||||
99 | 3216 | 48.3ms | 3216 | 13.1ms | umask $umask; # spent 13.1ms making 3216 calls to Mail::SpamAssassin::DBBasedAddrList::CORE:umask, avg 4µs/call |
100 | |||||
101 | 3216 | 13.0ms | bless ($self, $class); | ||
102 | 3216 | 54.0ms | return $self; | ||
103 | } | ||||
104 | |||||
105 | ########################################################################### | ||||
106 | |||||
107 | # spent 1.02ms (55µs+960µs) within Mail::SpamAssassin::DBBasedAddrList::finish which was called:
# once (55µs+960µs) by Mail::SpamAssassin::Plugin::TxRep::finish at line 1722 of Mail/SpamAssassin/Plugin/TxRep.pm | ||||
108 | 1 | 2µs | my $self = shift; | ||
109 | 1 | 8µs | 1 | 6µs | dbg("auto-whitelist: DB addr list: untie-ing and unlocking"); # spent 6µs making 1 call to Mail::SpamAssassin::Logger::dbg |
110 | 2 | 984µs | 1 | 954µs | untie %{$self->{accum}}; # spent 954µs making 1 call to DB_File::DESTROY |
111 | 1 | 14µs | if ($self->{is_locked}) { | ||
112 | dbg("auto-whitelist: DB addr list: file locked, breaking lock"); | ||||
113 | $self->{main}->{locker}->safe_unlock ($self->{locked_file}); | ||||
114 | $self->{is_locked} = 0; | ||||
115 | } | ||||
116 | # TODO: untrap signals to unlock the db file here | ||||
117 | } | ||||
118 | |||||
119 | ########################################################################### | ||||
120 | |||||
121 | # spent 813ms (300+513) within Mail::SpamAssassin::DBBasedAddrList::get_addr_entry which was called 3220 times, avg 252µs/call:
# 3216 times (299ms+513ms) by Mail::SpamAssassin::Plugin::TxRep::get_sender at line 1539 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 252µs/call
# 2 times (176µs+314µs) by Mail::SpamAssassin::Plugin::TxRep::modify_reputation at line 1618 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 245µs/call
# 2 times (159µs+268µs) by Mail::SpamAssassin::Plugin::TxRep::modify_reputation at line 1608 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 214µs/call | ||||
122 | 3220 | 15.2ms | my ($self, $addr, $signedby) = @_; | ||
123 | |||||
124 | 3220 | 23.7ms | my $entry = { | ||
125 | addr => $addr, | ||||
126 | }; | ||||
127 | |||||
128 | 3220 | 368ms | 3220 | 266ms | $entry->{count} = $self->{accum}->{$addr} || 0; # spent 266ms making 3220 calls to DB_File::FETCH, avg 82µs/call |
129 | 3220 | 279ms | 3220 | 211ms | $entry->{totscore} = $self->{accum}->{$addr.'|totscore'} || 0; # spent 211ms making 3220 calls to DB_File::FETCH, avg 65µs/call |
130 | |||||
131 | 3220 | 54.1ms | 3220 | 36.7ms | dbg("auto-whitelist: db-based $addr scores ".$entry->{count}.'/'.$entry->{totscore}); # spent 36.7ms making 3220 calls to Mail::SpamAssassin::Logger::dbg, avg 11µs/call |
132 | 3220 | 42.9ms | return $entry; | ||
133 | } | ||||
134 | |||||
135 | ########################################################################### | ||||
136 | |||||
137 | # spent 303ms (244+59.5) within Mail::SpamAssassin::DBBasedAddrList::add_score which was called 2766 times, avg 110µs/call:
# 1390 times (123ms+29.8ms) by Mail::SpamAssassin::Plugin::TxRep::add_score at line 1573 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 110µs/call
# 1374 times (121ms+29.6ms) by Mail::SpamAssassin::Plugin::TxRep::remove_score at line 1596 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 109µs/call
# 2 times (166µs+43µs) by Mail::SpamAssassin::Plugin::TxRep::modify_reputation at line 1619 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 105µs/call | ||||
138 | 2766 | 11.2ms | my($self, $entry, $score) = @_; | ||
139 | |||||
140 | 2766 | 8.55ms | $entry->{count} ||= 0; | ||
141 | 2766 | 6.69ms | $entry->{addr} ||= ''; | ||
142 | |||||
143 | 2766 | 7.73ms | $entry->{count}++; | ||
144 | 2766 | 10.4ms | $entry->{totscore} += $score; | ||
145 | |||||
146 | 2766 | 40.5ms | 2766 | 20.9ms | dbg("auto-whitelist: add_score: new count: ".$entry->{count}.", new totscore: ".$entry->{totscore}); # spent 20.9ms making 2766 calls to Mail::SpamAssassin::Logger::dbg, avg 8µs/call |
147 | |||||
148 | 2766 | 80.0ms | 2766 | 21.7ms | $self->{accum}->{$entry->{addr}} = $entry->{count}; # spent 21.7ms making 2766 calls to DB_File::STORE, avg 8µs/call |
149 | 2766 | 64.6ms | 2766 | 16.8ms | $self->{accum}->{$entry->{addr}.'|totscore'} = $entry->{totscore}; # spent 16.8ms making 2766 calls to DB_File::STORE, avg 6µs/call |
150 | 2766 | 32.4ms | return $entry; | ||
151 | } | ||||
152 | |||||
153 | ########################################################################### | ||||
154 | |||||
155 | # spent 1761s (1125+636) within Mail::SpamAssassin::DBBasedAddrList::remove_entry which was called 470 times, avg 3.75s/call:
# 234 times (562s+317s) by Mail::SpamAssassin::Plugin::TxRep::check_reputation at line 1509 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 3.76s/call
# 234 times (559s+317s) by Mail::SpamAssassin::Plugin::TxRep::check_reputation at line 1500 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 3.74s/call
# 2 times (4.37s+1.99s) by Mail::SpamAssassin::Plugin::TxRep::modify_reputation at line 1613 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 3.18s/call | ||||
156 | 470 | 1.10ms | my ($self, $entry) = @_; | ||
157 | |||||
158 | 470 | 1.79ms | my $addr = $entry->{addr}; | ||
159 | 470 | 21.7ms | 470 | 3.31ms | delete $self->{accum}->{$addr}; # spent 3.31ms making 470 calls to DB_File::DELETE, avg 7µs/call |
160 | 470 | 9.65ms | 470 | 2.33ms | delete $self->{accum}->{$addr.'|totscore'}; # spent 2.33ms making 470 calls to DB_File::DELETE, avg 5µs/call |
161 | |||||
162 | 470 | 17.0ms | 470 | 6.22ms | if ($addr =~ /^(.*)\|ip=none$/) { # spent 6.22ms making 470 calls to Mail::SpamAssassin::DBBasedAddrList::CORE:match, avg 13µ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... | ||||
166 | 470 | 2.74ms | my $mailaddr = $1; | ||
167 | |||||
168 | 24973776 | 1241s | 49946142 | 486s | while (my ($key, $value) = each %{$self->{accum}}) { # spent 265s making 24972836 calls to DB_File::FETCH, avg 11µs/call
# spent 221s making 24972836 calls to DB_File::NEXTKEY, avg 9µs/call
# spent 29.0ms making 470 calls to DB_File::FIRSTKEY, avg 62µs/call |
169 | # regex will catch both key and key|totscore entries and delete them | ||||
170 | 24972836 | 521s | 49945672 | 151s | if ($key =~ /^\Q${mailaddr}\E\|/) { # spent 97.1s making 24972836 calls to Mail::SpamAssassin::DBBasedAddrList::CORE:regcomp, avg 4µs/call
# spent 53.8s making 24972836 calls to Mail::SpamAssassin::DBBasedAddrList::CORE:match, avg 2µs/call |
171 | 898 | 22.5ms | 898 | 6.54ms | delete $self->{accum}->{$key}; # spent 6.54ms making 898 calls to DB_File::DELETE, avg 7µs/call |
172 | } | ||||
173 | } | ||||
174 | } | ||||
175 | } | ||||
176 | |||||
177 | ########################################################################### | ||||
178 | |||||
179 | 1 | 10µs | 1; | ||
# spent 53.8s within Mail::SpamAssassin::DBBasedAddrList::CORE:match which was called 24973306 times, avg 2µs/call:
# 24972836 times (53.8s+0s) by Mail::SpamAssassin::DBBasedAddrList::remove_entry at line 170, avg 2µs/call
# 470 times (6.22ms+0s) by Mail::SpamAssassin::DBBasedAddrList::remove_entry at line 162, avg 13µs/call | |||||
# spent 97.1s within Mail::SpamAssassin::DBBasedAddrList::CORE:regcomp which was called 24972836 times, avg 4µs/call:
# 24972836 times (97.1s+0s) by Mail::SpamAssassin::DBBasedAddrList::remove_entry at line 170, avg 4µs/call | |||||
# spent 24.0ms within Mail::SpamAssassin::DBBasedAddrList::CORE:umask which was called 6432 times, avg 4µs/call:
# 3216 times (13.1ms+0s) by Mail::SpamAssassin::DBBasedAddrList::new_checker at line 99, avg 4µs/call
# 3216 times (10.9ms+0s) by Mail::SpamAssassin::DBBasedAddrList::new_checker at line 64, avg 3µs/call |