Filename | /usr/local/lib/perl5/site_perl/Mail/SpamAssassin/DBBasedAddrList.pm |
Statements | Executed 18514173 statements in 616s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
175 | 3 | 1 | 413s | 616s | remove_entry | Mail::SpamAssassin::DBBasedAddrList::
9240188 | 1 | 1 | 35.8s | 35.8s | CORE:regcomp (opcode) | Mail::SpamAssassin::DBBasedAddrList::
9240363 | 2 | 1 | 20.0s | 20.0s | CORE:match (opcode) | Mail::SpamAssassin::DBBasedAddrList::
2209 | 3 | 1 | 171ms | 575ms | get_addr_entry | Mail::SpamAssassin::DBBasedAddrList::
2121 | 3 | 1 | 165ms | 245ms | add_score | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 1.08ms | 1.43ms | BEGIN@26 | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 241µs | 4.18ms | new_checker | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 185µs | 5.67s | finish | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 74µs | 98µs | new | Mail::SpamAssassin::DBBasedAddrList::
2 | 2 | 1 | 61µs | 61µs | CORE:umask (opcode) | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 49µs | 61µs | BEGIN@20 | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 48µs | 111µs | BEGIN@23 | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 43µs | 266µs | BEGIN@28 | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 33µs | 152µs | BEGIN@27 | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 30µs | 2.34ms | BEGIN@24 | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 29µs | 68µs | BEGIN@21 | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 29µs | 35µs | BEGIN@22 | 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 | 72µ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 # spent 61µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@20
# spent 12µs making 1 call to strict::import |
21 | 2 | 72µs | 2 | 106µ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 # spent 68µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@21
# spent 38µs making 1 call to warnings::import |
22 | 2 | 85µs | 2 | 42µ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 # spent 35µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@22
# spent 6µs making 1 call to bytes::import |
23 | 2 | 82µs | 2 | 174µ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 # spent 111µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@23
# spent 63µs making 1 call to re::import |
24 | 2 | 86µs | 2 | 4.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 # spent 2.34ms making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@24
# spent 2.31ms making 1 call to Exporter::import |
25 | |||||
26 | 2 | 384µs | 1 | 1.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 # spent 1.43ms making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@26 |
27 | 2 | 74µs | 2 | 272µ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 # spent 152µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@27
# spent 119µs making 1 call to Exporter::import |
28 | 2 | 1.59ms | 2 | 488µ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 # spent 266µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@28
# spent 222µs making 1 call to Exporter::import |
29 | |||||
30 | 1 | 13µs | our @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] | ||||
35 | 1 | 2µs | my $class = shift; | ||
36 | 1 | 2µs | $class = ref($class) || $class; | ||
37 | 1 | 21µ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 | 14µ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 | ||||
46 | 1 | 2µs | my ($factory, $main) = @_; | ||
47 | 1 | 2µs | my $class = $factory->{class}; | ||
48 | |||||
49 | 1 | 13µs | my $self = { | ||
50 | 'main' => $main, | ||||
51 | 'accum' => { }, | ||||
52 | 'is_locked' => 0, | ||||
53 | 'locked_file' => '' | ||||
54 | }; | ||||
55 | |||||
56 | 1 | 9µs | my @order = split (' ', $main->{conf}->{auto_whitelist_db_modules}); | ||
57 | 1 | 9µs | 1 | 191µs | untaint_var(\@order); # spent 191µs making 1 call to Mail::SpamAssassin::Util::untaint_var |
58 | 1 | 16µs | 1 | 75µs | my $dbm_module = Mail::SpamAssassin::Util::first_available_module (@order); # spent 75µs making 1 call to Mail::SpamAssassin::Util::first_available_module |
59 | 1 | 2µ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 | |||||
64 | 1 | 81µs | 1 | 56µ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! | ||||
67 | 1 | 4µs | if (defined($main->{conf}->{auto_whitelist_path})) { | ||
68 | 1 | 9µs | 1 | 559µs | my $path = $main->sed_path($main->{conf}->{auto_whitelist_path}); # spent 559µs making 1 call to Mail::SpamAssassin::sed_path |
69 | 1 | 2µs | my ($mod1, $mod2); | ||
70 | |||||
71 | 1 | 15µs | 1 | 1.65ms | if ($main->{locker}->safe_lock # spent 1.65ms making 1 call to Mail::SpamAssassin::Locker::UnixNFSSafe::safe_lock |
72 | ($path, 30, $main->{conf}->{auto_whitelist_file_mode})) | ||||
73 | { | ||||
74 | 1 | 7µs | $self->{locked_file} = $path; | ||
75 | 1 | 3µs | $self->{is_locked} = 1; | ||
76 | 1 | 4µ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 | |||||
83 | 1 | 20µs | 1 | 18µ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 | |||||
85 | 1 | 15µs | 1 | 1.12ms | ($self->{is_locked} && $dbm_module eq 'DB_File') and # spent 1.12ms making 1 call to Mail::SpamAssassin::Util::avoid_db_file_locking_bug |
86 | Mail::SpamAssassin::Util::avoid_db_file_locking_bug($path); | ||||
87 | |||||
88 | 2 | 50µs | 1 | 262µ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 | } | ||||
99 | 1 | 15µs | 1 | 5µs | umask $umask; # spent 5µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::CORE:umask |
100 | |||||
101 | 1 | 4µs | bless ($self, $class); | ||
102 | 1 | 15µ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 | ||||
108 | 1 | 2µs | my $self = shift; | ||
109 | 1 | 7µs | 1 | 7µs | dbg("auto-whitelist: DB addr list: untie-ing and unlocking"); # spent 7µs making 1 call to Mail::SpamAssassin::Logger::dbg |
110 | 2 | 24.8ms | 1 | 24.7ms | untie %{$self->{accum}}; # spent 24.7ms making 1 call to DB_File::DESTROY |
111 | 1 | 26µs | if ($self->{is_locked}) { | ||
112 | 1 | 17µs | 1 | 18µs | dbg("auto-whitelist: DB addr list: file locked, breaking lock"); # spent 18µs making 1 call to Mail::SpamAssassin::Logger::dbg |
113 | 1 | 19µs | 1 | 5.64s | $self->{main}->{locker}->safe_unlock ($self->{locked_file}); # spent 5.64s making 1 call to Mail::SpamAssassin::Locker::UnixNFSSafe::safe_unlock |
114 | 1 | 9µ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 | ||||
122 | 2209 | 14.4ms | my ($self, $addr, $signedby) = @_; | ||
123 | |||||
124 | 2209 | 13.4ms | my $entry = { | ||
125 | addr => $addr, | ||||
126 | }; | ||||
127 | |||||
128 | 2209 | 252ms | 2209 | 207ms | $entry->{count} = $self->{accum}->{$addr} || 0; # spent 207ms making 2209 calls to DB_File::FETCH, avg 94µs/call |
129 | 2209 | 219ms | 2209 | 174ms | $entry->{totscore} = $self->{accum}->{$addr.'|totscore'} || 0; # spent 174ms making 2209 calls to DB_File::FETCH, avg 79µs/call |
130 | |||||
131 | 2209 | 32.4ms | 2209 | 22.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 |
132 | 2209 | 36.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 | ||||
138 | 2121 | 9.83ms | my($self, $entry, $score) = @_; | ||
139 | |||||
140 | 2121 | 6.41ms | $entry->{count} ||= 0; | ||
141 | 2121 | 4.54ms | $entry->{addr} ||= ''; | ||
142 | |||||
143 | 2121 | 4.44ms | $entry->{count}++; | ||
144 | 2121 | 7.00ms | $entry->{totscore} += $score; | ||
145 | |||||
146 | 2121 | 26.4ms | 2121 | 16.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 | |||||
148 | 2121 | 71.8ms | 2121 | 34.1ms | $self->{accum}->{$entry->{addr}} = $entry->{count}; # spent 34.1ms making 2121 calls to DB_File::STORE, avg 16µs/call |
149 | 2121 | 73.6ms | 2121 | 29.0ms | $self->{accum}->{$entry->{addr}.'|totscore'} = $entry->{totscore}; # spent 29.0ms making 2121 calls to DB_File::STORE, avg 14µs/call |
150 | 2121 | 31.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 | ||||
156 | 175 | 367µs | my ($self, $entry) = @_; | ||
157 | |||||
158 | 175 | 622µs | my $addr = $entry->{addr}; | ||
159 | 175 | 6.36ms | 175 | 3.41ms | delete $self->{accum}->{$addr}; # spent 3.41ms making 175 calls to DB_File::DELETE, avg 19µs/call |
160 | 175 | 5.78ms | 175 | 2.70ms | delete $self->{accum}->{$addr.'|totscore'}; # spent 2.70ms making 175 calls to DB_File::DELETE, avg 15µs/call |
161 | |||||
162 | 175 | 5.17ms | 175 | 1.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... | ||||
166 | 175 | 668µs | my $mailaddr = $1; | ||
167 | |||||
168 | 9240538 | 426s | 18480551 | 147s | 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 | ||||
170 | 9240188 | 190s | 18480376 | 55.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 | |||||
179 | 1 | 10µs | 1; | ||
# 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 | |||||
# 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:umask; # opcode |