Filename | /usr/local/lib/perl5/site_perl/Mail/SpamAssassin/DBBasedAddrList.pm |
Statements | Executed 46644972 statements in 1470s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
438 | 3 | 1 | 963s | 1469s | remove_entry | Mail::SpamAssassin::DBBasedAddrList::
23298310 | 1 | 1 | 88.1s | 88.1s | CORE:regcomp (opcode) | Mail::SpamAssassin::DBBasedAddrList::
23298748 | 2 | 1 | 46.4s | 46.4s | CORE:match (opcode) | Mail::SpamAssassin::DBBasedAddrList::
3118 | 3 | 1 | 254ms | 764ms | get_addr_entry | Mail::SpamAssassin::DBBasedAddrList::
2898 | 3 | 1 | 210ms | 315ms | add_score | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 1.03ms | 1.38ms | BEGIN@26 | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 242µs | 708ms | new_checker | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 147µs | 5.48s | finish | Mail::SpamAssassin::DBBasedAddrList::
2 | 2 | 1 | 66µs | 66µs | CORE:umask (opcode) | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 56µs | 68µs | BEGIN@20 | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 52µs | 69µs | new | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 48µs | 114µs | BEGIN@23 | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 34µs | 196µs | BEGIN@27 | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 34µs | 263µs | BEGIN@28 | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 33µs | 2.30ms | BEGIN@24 | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 27µs | 34µs | BEGIN@22 | Mail::SpamAssassin::DBBasedAddrList::
1 | 1 | 1 | 24µs | 64µ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 68µs (56+12) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@20 which was called:
# once (56µs+12µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 20 # spent 68µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@20
# spent 12µs making 1 call to strict::import |
21 | 2 | 82µs | 2 | 104µs | # spent 64µs (24+40) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@21 which was called:
# once (24µs+40µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 21 # spent 64µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@21
# spent 40µs making 1 call to warnings::import |
22 | 2 | 85µs | 2 | 41µs | # spent 34µs (27+7) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@22 which was called:
# once (27µs+7µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 22 # spent 34µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@22
# spent 7µs making 1 call to bytes::import |
23 | 2 | 87µs | 2 | 179µs | # spent 114µs (48+66) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@23 which was called:
# once (48µs+66µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 23 # spent 114µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@23
# spent 66µs making 1 call to re::import |
24 | 2 | 83µs | 2 | 4.56ms | # spent 2.30ms (33µs+2.26) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@24 which was called:
# once (33µs+2.26ms) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 24 # spent 2.30ms making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@24
# spent 2.26ms making 1 call to Exporter::import |
25 | |||||
26 | 2 | 381µs | 1 | 1.38ms | # spent 1.38ms (1.03+347µs) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@26 which was called:
# once (1.03ms+347µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 26 # spent 1.38ms making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@26 |
27 | 2 | 81µs | 2 | 357µs | # spent 196µs (34+162) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@27 which was called:
# once (34µs+162µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 27 # spent 196µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@27
# spent 162µs making 1 call to Exporter::import |
28 | 2 | 1.56ms | 2 | 491µs | # spent 263µs (34+229) within Mail::SpamAssassin::DBBasedAddrList::BEGIN@28 which was called:
# once (34µs+229µs) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 28 # spent 263µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::BEGIN@28
# spent 229µs making 1 call to Exporter::import |
29 | |||||
30 | 1 | 13µs | our @ISA = qw(Mail::SpamAssassin::PersistentAddrList); | ||
31 | |||||
32 | ########################################################################### | ||||
33 | |||||
34 | # spent 69µs (52+17) within Mail::SpamAssassin::DBBasedAddrList::new which was called:
# once (52µs+17µ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 | 18µs | 1 | 17µs | my $self = $class->SUPER::new(@_); # spent 17µs making 1 call to Mail::SpamAssassin::PersistentAddrList::new |
38 | 1 | 13µs | $self->{class} = $class; | ||
39 | 1 | 2µs | bless ($self, $class); | ||
40 | 1 | 14µs | $self; | ||
41 | } | ||||
42 | |||||
43 | ########################################################################### | ||||
44 | |||||
45 | # spent 708ms (242µs+707) within Mail::SpamAssassin::DBBasedAddrList::new_checker which was called:
# once (242µs+707ms) by Mail::SpamAssassin::Plugin::TxRep::open_storages at line 1654 of Mail/SpamAssassin/Plugin/TxRep.pm | ||||
46 | 1 | 2µs | my ($factory, $main) = @_; | ||
47 | 1 | 2µs | my $class = $factory->{class}; | ||
48 | |||||
49 | 1 | 12µs | my $self = { | ||
50 | 'main' => $main, | ||||
51 | 'accum' => { }, | ||||
52 | 'is_locked' => 0, | ||||
53 | 'locked_file' => '' | ||||
54 | }; | ||||
55 | |||||
56 | 1 | 10µs | my @order = split (' ', $main->{conf}->{auto_whitelist_db_modules}); | ||
57 | 1 | 7µs | 1 | 195µs | untaint_var(\@order); # spent 195µs making 1 call to Mail::SpamAssassin::Util::untaint_var |
58 | 1 | 16µs | 1 | 80µs | my $dbm_module = Mail::SpamAssassin::Util::first_available_module (@order); # spent 80µ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 | 90µs | 1 | 62µs | my $umask = umask ~ (oct($main->{conf}->{auto_whitelist_file_mode})); # spent 62µ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 | 10µs | 1 | 582µs | my $path = $main->sed_path($main->{conf}->{auto_whitelist_path}); # spent 582µs making 1 call to Mail::SpamAssassin::sed_path |
69 | 1 | 2µs | my ($mod1, $mod2); | ||
70 | |||||
71 | 1 | 16µs | 1 | 705ms | if ($main->{locker}->safe_lock # spent 705ms making 1 call to Mail::SpamAssassin::Locker::UnixNFSSafe::safe_lock |
72 | ($path, 30, $main->{conf}->{auto_whitelist_file_mode})) | ||||
73 | { | ||||
74 | 1 | 6µs | $self->{locked_file} = $path; | ||
75 | 1 | 4µ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 | 11µs | 1 | 7µs | dbg("auto-whitelist: tie-ing to DB file of type $dbm_module $mod1 in $path"); # spent 7µs making 1 call to Mail::SpamAssassin::Logger::dbg |
84 | |||||
85 | 1 | 14µs | 1 | 1.05ms | ($self->{is_locked} && $dbm_module eq 'DB_File') and # spent 1.05ms 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 | 49µs | 1 | 242µs | if (! tie %{ $self->{accum} }, $dbm_module, $path, $mod2, # spent 242µ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 | 13µs | 1 | 4µs | umask $umask; # spent 4µs making 1 call to Mail::SpamAssassin::DBBasedAddrList::CORE:umask |
100 | |||||
101 | 1 | 3µs | bless ($self, $class); | ||
102 | 1 | 15µs | return $self; | ||
103 | } | ||||
104 | |||||
105 | ########################################################################### | ||||
106 | |||||
107 | # spent 5.48s (147µs+5.48) within Mail::SpamAssassin::DBBasedAddrList::finish which was called:
# once (147µs+5.48s) by Mail::SpamAssassin::Plugin::TxRep::finish at line 1722 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 | 3.88ms | 1 | 3.82ms | untie %{$self->{accum}}; # spent 3.82ms making 1 call to DB_File::DESTROY |
111 | 1 | 22µs | if ($self->{is_locked}) { | ||
112 | 1 | 13µs | 1 | 14µs | dbg("auto-whitelist: DB addr list: file locked, breaking lock"); # spent 14µs making 1 call to Mail::SpamAssassin::Logger::dbg |
113 | 1 | 17µs | 1 | 5.47s | $self->{main}->{locker}->safe_unlock ($self->{locked_file}); # spent 5.47s making 1 call to Mail::SpamAssassin::Locker::UnixNFSSafe::safe_unlock |
114 | 1 | 8µs | $self->{is_locked} = 0; | ||
115 | } | ||||
116 | # TODO: untrap signals to unlock the db file here | ||||
117 | } | ||||
118 | |||||
119 | ########################################################################### | ||||
120 | |||||
121 | # spent 764ms (254+510) within Mail::SpamAssassin::DBBasedAddrList::get_addr_entry which was called 3118 times, avg 245µs/call:
# 3114 times (253ms+510ms) by Mail::SpamAssassin::Plugin::TxRep::get_sender at line 1539 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 245µs/call
# 2 times (178µs+229µs) by Mail::SpamAssassin::Plugin::TxRep::modify_reputation at line 1608 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 204µs/call
# 2 times (155µs+242µs) by Mail::SpamAssassin::Plugin::TxRep::modify_reputation at line 1618 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 198µs/call | ||||
122 | 3118 | 13.9ms | my ($self, $addr, $signedby) = @_; | ||
123 | |||||
124 | 3118 | 21.1ms | my $entry = { | ||
125 | addr => $addr, | ||||
126 | }; | ||||
127 | |||||
128 | 3118 | 309ms | 3118 | 248ms | $entry->{count} = $self->{accum}->{$addr} || 0; # spent 248ms making 3118 calls to DB_File::FETCH, avg 79µs/call |
129 | 3118 | 298ms | 3118 | 232ms | $entry->{totscore} = $self->{accum}->{$addr.'|totscore'} || 0; # spent 232ms making 3118 calls to DB_File::FETCH, avg 74µs/call |
130 | |||||
131 | 3118 | 45.2ms | 3118 | 30.9ms | dbg("auto-whitelist: db-based $addr scores ".$entry->{count}.'/'.$entry->{totscore}); # spent 30.9ms making 3118 calls to Mail::SpamAssassin::Logger::dbg, avg 10µs/call |
132 | 3118 | 36.6ms | return $entry; | ||
133 | } | ||||
134 | |||||
135 | ########################################################################### | ||||
136 | |||||
137 | # spent 315ms (210+105) within Mail::SpamAssassin::DBBasedAddrList::add_score which was called 2898 times, avg 109µs/call:
# 1615 times (112ms+58.6ms) by Mail::SpamAssassin::Plugin::TxRep::add_score at line 1573 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 106µs/call
# 1281 times (98.4ms+46.1ms) by Mail::SpamAssassin::Plugin::TxRep::remove_score at line 1596 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 113µs/call
# 2 times (154µs+55µs) by Mail::SpamAssassin::Plugin::TxRep::modify_reputation at line 1619 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 105µs/call | ||||
138 | 2898 | 9.39ms | my($self, $entry, $score) = @_; | ||
139 | |||||
140 | 2898 | 8.71ms | $entry->{count} ||= 0; | ||
141 | 2898 | 5.97ms | $entry->{addr} ||= ''; | ||
142 | |||||
143 | 2898 | 6.19ms | $entry->{count}++; | ||
144 | 2898 | 10.5ms | $entry->{totscore} += $score; | ||
145 | |||||
146 | 2898 | 39.8ms | 2898 | 24.5ms | dbg("auto-whitelist: add_score: new count: ".$entry->{count}.", new totscore: ".$entry->{totscore}); # spent 24.5ms making 2898 calls to Mail::SpamAssassin::Logger::dbg, avg 8µs/call |
147 | |||||
148 | 2898 | 95.6ms | 2898 | 42.8ms | $self->{accum}->{$entry->{addr}} = $entry->{count}; # spent 42.8ms making 2898 calls to DB_File::STORE, avg 15µs/call |
149 | 2898 | 82.7ms | 2898 | 37.4ms | $self->{accum}->{$entry->{addr}.'|totscore'} = $entry->{totscore}; # spent 37.4ms making 2898 calls to DB_File::STORE, avg 13µs/call |
150 | 2898 | 37.0ms | return $entry; | ||
151 | } | ||||
152 | |||||
153 | ########################################################################### | ||||
154 | |||||
155 | # spent 1469s (963+506) within Mail::SpamAssassin::DBBasedAddrList::remove_entry which was called 438 times, avg 3.35s/call:
# 218 times (483s+275s) by Mail::SpamAssassin::Plugin::TxRep::check_reputation at line 1509 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 3.48s/call
# 218 times (476s+228s) by Mail::SpamAssassin::Plugin::TxRep::check_reputation at line 1500 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 3.23s/call
# 2 times (4.31s+1.91s) by Mail::SpamAssassin::Plugin::TxRep::modify_reputation at line 1613 of Mail/SpamAssassin/Plugin/TxRep.pm, avg 3.11s/call | ||||
156 | 438 | 968µs | my ($self, $entry) = @_; | ||
157 | |||||
158 | 438 | 1.59ms | my $addr = $entry->{addr}; | ||
159 | 438 | 15.7ms | 438 | 8.46ms | delete $self->{accum}->{$addr}; # spent 8.46ms making 438 calls to DB_File::DELETE, avg 19µs/call |
160 | 438 | 22.0ms | 438 | 6.67ms | delete $self->{accum}->{$addr.'|totscore'}; # spent 6.67ms making 438 calls to DB_File::DELETE, avg 15µs/call |
161 | |||||
162 | 438 | 13.0ms | 438 | 3.33ms | if ($addr =~ /^(.*)\|ip=none$/) { # spent 3.33ms making 438 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 | 438 | 1.72ms | my $mailaddr = $1; | ||
167 | |||||
168 | 23299186 | 999s | 46597058 | 371s | while (my ($key, $value) = each %{$self->{accum}}) { # spent 213s making 23298310 calls to DB_File::FETCH, avg 9µs/call
# spent 158s making 23298310 calls to DB_File::NEXTKEY, avg 7µs/call
# spent 37.4ms making 438 calls to DB_File::FIRSTKEY, avg 85µs/call |
169 | # regex will catch both key and key|totscore entries and delete them | ||||
170 | 23298310 | 470s | 46596620 | 134s | if ($key =~ /^\Q${mailaddr}\E\|/) { # spent 88.1s making 23298310 calls to Mail::SpamAssassin::DBBasedAddrList::CORE:regcomp, avg 4µs/call
# spent 46.4s making 23298310 calls to Mail::SpamAssassin::DBBasedAddrList::CORE:match, avg 2µs/call |
171 | 4 | 112µs | 4 | 37µs | delete $self->{accum}->{$key}; # spent 37µs making 4 calls to DB_File::DELETE, avg 9µs/call |
172 | } | ||||
173 | } | ||||
174 | } | ||||
175 | } | ||||
176 | |||||
177 | ########################################################################### | ||||
178 | |||||
179 | 1 | 10µs | 1; | ||
# spent 46.4s within Mail::SpamAssassin::DBBasedAddrList::CORE:match which was called 23298748 times, avg 2µs/call:
# 23298310 times (46.4s+0s) by Mail::SpamAssassin::DBBasedAddrList::remove_entry at line 170, avg 2µs/call
# 438 times (3.33ms+0s) by Mail::SpamAssassin::DBBasedAddrList::remove_entry at line 162, avg 8µs/call | |||||
# spent 88.1s within Mail::SpamAssassin::DBBasedAddrList::CORE:regcomp which was called 23298310 times, avg 4µs/call:
# 23298310 times (88.1s+0s) by Mail::SpamAssassin::DBBasedAddrList::remove_entry at line 170, avg 4µs/call | |||||
sub Mail::SpamAssassin::DBBasedAddrList::CORE:umask; # opcode |