← Index
NYTProf Performance Profile   « line view »
For /usr/local/libexec/sympa/task_manager-debug.pl
  Run on Tue Jun 1 22:32:51 2021
Reported on Tue Jun 1 22:35:02 2021

Filename/usr/local/libexec/sympa/task_manager-debug.pl
StatementsExecuted 479 statements in 1.45ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
275521372ms372msDBI::st::::execute DBI::st::execute (xsub)
121633212.3ms12.3msUNIVERSAL::::can UNIVERSAL::can (xsub)
2754216.74ms6.74msDBI::st::::fetchrow_array DBI::st::fetchrow_array (xsub)
221155µs155µsDBI::db::::do DBI::db::do (xsub)
331146µs146µsmain::::CORE:gpwnam main::CORE:gpwnam (opcode)
33154µs54µsmain::::CORE:ggrnam main::CORE:ggrnam (opcode)
11126µs26µsmain::::CORE:chdir main::CORE:chdir (opcode)
32124µs163µsDBI::db::::prepare DBI::db::prepare (xsub)
76418µs18µsDBI::common::::STORE DBI::common::STORE (xsub)
53116µs16µsDBI::common::::FETCH DBI::common::FETCH (xsub)
11113µs264µsmain::::sigterm main::sigterm
32112µs12µsDBI::common::::DESTROY DBI::common::DESTROY (xsub)
11110µs10µsmain::::CORE:umask main::CORE:umask (opcode)
11110µs10µsDBI::dr::::disconnect_all DBI::dr::disconnect_all (xsub)
1118µs8µsUNIVERSAL::::isa UNIVERSAL::isa (xsub)
2118µs132µsDBI::db::::ping DBI::db::ping (xsub)
2117µs7µsDBI::common::::can DBI::common::can (xsub)
1116µs6.67msDBI::dr::::connect DBI::dr::connect (xsub)
4114µs4µsInternals::::SvREADONLY Internals::SvREADONLY (xsub)
1112µs2µsDBI::db::::connected DBI::db::connected (xsub)
1111µs1µsDBD::_mem::common::::DESTROYDBD::_mem::common::DESTROY (xsub)
0000s0smain::::BEGIN@29 main::BEGIN@29
0000s0smain::::BEGIN@30 main::BEGIN@30
0000s0smain::::BEGIN@31 main::BEGIN@31
0000s0smain::::BEGIN@32 main::BEGIN@32
0000s0smain::::BEGIN@33 main::BEGIN@33
0000s0smain::::BEGIN@34 main::BEGIN@34
0000s0smain::::BEGIN@35 main::BEGIN@35
0000s0smain::::BEGIN@37 main::BEGIN@37
0000s0smain::::BEGIN@38 main::BEGIN@38
0000s0smain::::BEGIN@39 main::BEGIN@39
0000s0smain::::BEGIN@40 main::BEGIN@40
0000s0smain::::BEGIN@41 main::BEGIN@41
0000s0smain::::BEGIN@42 main::BEGIN@42
0000s0smain::::BEGIN@43 main::BEGIN@43
0000s0smain::::CORE:pack main::CORE:pack (opcode)
0000s0smain::::RUNTIME main::RUNTIME
0000s0smain::::__ANON__ main::__ANON__ (xsub)
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
05249µsProfile data that couldn't be associated with a specific line:
# spent 76µs making 1 call to File::Temp::END # spent 75µs making 1 call to XML::LibXML::END # spent 59µs making 1 call to DBI::END # spent 20µs making 1 call to Crypt::OpenSSL::X509::END # spent 19µs making 1 call to Class::Singleton::END
1193µs#! /usr/local/bin/perl
2# -*- indent-tabs-mode: nil; -*-
3# vim:ft=perl:et:sw=4
4# $Id$
5
6# Sympa - SYsteme de Multi-Postage Automatique
7#
8# Copyright (c) 1997, 1998, 1999 Institut Pasteur & Christophe Wolfhugel
9# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
10# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
11# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER
12# Copyright 2017, 2018, 2019 The Sympa Community. See the AUTHORS.md file at
13# the top-level directory of this distribution and at
14# <https://github.com/sympa-community/sympa.git>.
15#
16# This program is free software; you can redistribute it and/or modify
17# it under the terms of the GNU General Public License as published by
18# the Free Software Foundation; either version 2 of the License, or
19# (at your option) any later version.
20#
21# This program is distributed in the hope that it will be useful,
22# but WITHOUT ANY WARRANTY; without even the implied warranty of
23# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24# GNU General Public License for more details.
25#
26# You should have received a copy of the GNU General Public License
27# along with this program. If not, see <http://www.gnu.org/licenses/>.
28
29use lib split(/:/, $ENV{SYMPALIB} || ''), '/usr/local/libexec/sympa';
30use strict;
31use warnings;
32use English qw(-no_match_vars);
33use Getopt::Long;
34use Pod::Usage;
35use POSIX qw();
36
37use Conf;
38use Sympa::Constants;
39use Sympa::Crash; # Show traceback.
40use Sympa::Log;
41use Sympa::Process;
42use Sympa::Spindle::ProcessTask;
43use Sympa::Spool::Listmaster;
44
45my $process = Sympa::Process->instance;
46$process->init(pidname => 'task_manager');
47
48my %options;
49unless (
50 GetOptions(
51 \%main::options, 'config|f=s', 'debug|d', 'help|h',
52 'version|v', 'log_level=s', 'foreground|F'
53 )
54) {
55 pod2usage(-exitval => 1, -output => \*STDERR);
56}
57if ($main::options{'help'}) {
58 pod2usage(0);
59} elsif ($main::options{'version'}) {
60 printf "Sympa %s\n", Sympa::Constants::VERSION;
61 exit 0;
62}
63$Conf::sympa_config = $main::options{config};
64
65if ($main::options{'debug'}) {
66 $main::options{'log_level'} = 2 unless $main::options{'log_level'};
67 $main::options{'foreground'} = 1;
68}
69
70my $log = Sympa::Log->instance;
71$log->{log_to_stderr} = 'all' if $main::options{'foreground'};
72
73my $adrlist = {};
74
75# Load sympa.conf
76unless (Conf::load()) {
77 die sprintf
78 "Unable to load Sympa configuration, file %s or one of the virtual host robot.conf files contain errors. Exiting.\n",
79 Conf::get_sympa_conf();
80}
81
82$log->openlog($Conf::Conf{'log_facility'}, $Conf::Conf{'log_socket_type'});
83
84# setting log_level using conf unless it is set by calling option
85if ($main::options{'log_level'}) {
86 $log->{level} = $main::options{'log_level'};
87 $log->syslog(
88 'info',
89 'Configuration file read, log level set using options: %s',
90 $main::options{'log_level'}
91 );
92} else {
93 $log->{level} = $Conf::Conf{'log_level'};
94 $log->syslog(
95 'info',
96 'Configuration file read, default log level %s',
97 $Conf::Conf{'log_level'}
98 );
99}
100
101# Put ourselves in background if not in debug mode.
1021700ns118.2msunless ($main::options{'foreground'}) {
# spent 18.2ms making 1 call to Sympa::Process::daemonize
103 $process->daemonize;
104}
105
106# Create and write the PID file.
107133µs12.53ms$process->write_pid(initial => 1);
# spent 2.53ms making 1 call to Sympa::Process::write_pid
108# If process is running in foreground, don't write STDERR to a dedicated file.
10917µs1219µsunless ($main::options{foreground}) {
# spent 219µs making 1 call to Sympa::Process::direct_stderr_to_file
110 $process->direct_stderr_to_file;
111}
112
113## Set the UserID & GroupID for the process
114186µs118µs$GID = $EGID = (getgrnam(Sympa::Constants::GROUP))[2];
# spent 18µs making 1 call to main::CORE:ggrnam
115182µs149µs$UID = $EUID = (getpwnam(Sympa::Constants::USER))[2];
# spent 49µs making 1 call to main::CORE:gpwnam
116
117## Required on FreeBSD to change ALL IDs(effective UID + real UID + saved UID)
118187µs272µsPOSIX::setuid((getpwnam(Sympa::Constants::USER))[2]);
# spent 51µs making 1 call to main::CORE:gpwnam # spent 21µs making 1 call to POSIX::setuid
119144µs224µsPOSIX::setgid((getgrnam(Sympa::Constants::GROUP))[2]);
# spent 19µs making 1 call to main::CORE:ggrnam # spent 5µs making 1 call to POSIX::setgid
120
121# Check if the UID has correctly been set (useful on OS X)
122176µs262µsunless (($GID == (getgrnam(Sympa::Constants::GROUP))[2])
# spent 45µs making 1 call to main::CORE:gpwnam # spent 16µs making 1 call to main::CORE:ggrnam
123 && ($UID == (getpwnam(Sympa::Constants::USER))[2])) {
124 die
125 "Failed to change process user ID and group ID. Note that on some OS Perl scripts can't change their real UID. In such circumstances Sympa should be run via sudo.\n";
126}
127
128## Sets the UMASK
129122µs110µsumask(oct($Conf::Conf{'umask'}));
# spent 10µs making 1 call to main::CORE:umask
130
131## Change to list root
132138µs126µsunless (chdir($Conf::Conf{'home'})) {
# spent 26µs making 1 call to main::CORE:chdir
133 die sprintf 'Unable to change to directory %s', $Conf::Conf{'home'};
134}
135
136# Most initializations have now been done.
137131µs1690µs$log->syslog('notice', 'Task_Manager %s Started',
# spent 690µs making 1 call to Sympa::Log::syslog
138 Sympa::Constants::VERSION());
139
140154µs12.87msmy $spindle = Sympa::Spindle::ProcessTask->new;
# spent 2.87ms making 1 call to Sympa::Spindle::new
141
142## Catch signals, in order to exit cleanly, whenever possible.
143112µs$SIG{'TERM'} = \&sigterm;
14414µs$SIG{'INT'} = \&sigterm;
145
146# Infinite loop scanning the spool (unless a sig TERM is received).
14712µswhile (not $spindle->{finish}) {
148229436µs22934.5s $spindle->spin;
# spent 34.5s making 229 calls to Sympa::Spindle::spin, avg 151ms/call
149
150229236µs last if $spindle->{finish};
151
152 # If the spool was empty, sleep for a while.
153 # sleep 60;
154}
155
156# Purge grouped notifications
15719µs217µsSympa::Spool::Listmaster->instance->flush(purge => 1);
# spent 13µs making 1 call to Sympa::Spool::Listmaster::flush # spent 4µs making 1 call to Class::Singleton::instance
158
15912µs1179µs$log->syslog('notice', 'Task_Manager exited normally due to signal');
# spent 179µs making 1 call to Sympa::Log::syslog
16013µs1487µs$process->remove_pid(final => 1);
# spent 487µs making 1 call to Sympa::Process::remove_pid
161
162185µsexit(0);
163
164## task creations
165# Obsoleted. Use Sympa::Task::new() and Sympa::Spool::Task::store().
166#sub create;
167
168## check the syntax of a task
169# Moved: Use Sympa::Task::_check().
170#sub check;
171
172## check a task line
173# Moved: Use Sympa::Task::_chk_line().
174#sub chk_line;
175
176## check the arguments of a command
177# Moved: Use Sympa::Task::_chk_cmd().
178#sub chk_cmd;
179
180### TASK EXECUTION SUBROUTINES ###
181
182# Moved to Sympa::Spinlde::ProcessTask module.
183#sub execute;
184#sub cmd_process;
185#sub rm_file;
186#sub stop;
187#sub send_msg;
188#sub next_cmd;
189#sub select_subs;
190#sub delete_subs_cmd;
191#sub create_cmd;
192#sub exec_cmd;
193#sub purge_logs_table;
194#sub _db_log_del;
195#sub purge_session_table;
196#sub purge_spools;
197#sub _clean_spool;
198#sub purge_tables;
199#sub purge_one_time_ticket_table;
200#sub purge_user_table;
201#sub purge_orphan_bounces;
202#sub expire_bounce;
203
204# Removed because not yet fully implemented. See r11771.
205#sub chk_cert_expiration;
206
207# Removed becuase not yet fully implemented. See r11771.
208#sub update_crl;
209
210# Moved to Sympa::Spindle::ProcessTask module.
211#sub eval_bouncers;
212#sub none;
213#sub process_bouncers;
214#sub get_score;
215
216### MISCELLANEOUS SUBROUTINES ###
217
218## when we catch signal, just change the value of the loop variable.
219
# spent 264µs (13+251) within main::sigterm which was called: # once (13µs+251µs) by Sympa::List::__ANON__[/usr/local/libexec/sympa/Sympa/List.pm:4267] at line 4267 of /usr/local/libexec/sympa/Sympa/List.pm
sub sigterm {
2201700ns my ($sig) = @_;
22113µs1251µs $log->syslog('notice',
# spent 251µs making 1 call to Sympa::Log::syslog
222 'Signal %s received, still processing current task', $sig);
22318µs $spindle->{finish} = 'term';
224}
225
226## sort task name by their epoch date
227# No longer used.
228#sub epoch_sort;
229
230# Moved to Sympa::Spindle::ProcessTask::_change_label().
231#sub change_label;
232
233# Moved to Sympa::Spindle::ProcessTask::error().
234#sub error;
235
236# Moved to Sympa::Spindle::ProcessTask module.
237#sub sync_include;
238
239__END__
 
# spent 1µs within DBD::_mem::common::DESTROY which was called: # once (1µs+0s) by Sympa::Database::do_prepared_query at line 380 of /usr/local/libexec/sympa/Sympa/Database.pm
sub DBD::_mem::common::DESTROY; # xsub
# spent 12µs within DBI::common::DESTROY which was called 3 times, avg 4µs/call: # 2 times (10µs+0s) by Sympa::Database::do_prepared_query at line 380 of /usr/local/libexec/sympa/Sympa/Database.pm, avg 5µs/call # once (1µs+0s) by Sympa::Database::connect at line 153 of /usr/local/libexec/sympa/Sympa/Database.pm
sub DBI::common::DESTROY; # xsub
# spent 16µs within DBI::common::FETCH which was called 5 times, avg 3µs/call: # 2 times (8µs+0s) by DBD::Pg::db::ping at line 459 of DBD/Pg.pm, avg 4µs/call # 2 times (2µs+0s) by DBD::Pg::dr::connect at line 270 of DBD/Pg.pm, avg 1µs/call # once (6µs+0s) by DBD::Pg::dr::connect at line 269 of DBD/Pg.pm
sub DBI::common::FETCH; # xsub
# spent 18µs within DBI::common::STORE which was called 7 times, avg 2µs/call: # 2 times (3µs+0s) by DBI::__ANON__[/usr/local/lib/perl5/site_perl/mach/5.32/DBI.pm:746] at line 731 of DBI.pm, avg 2µs/call # once (6µs+0s) by DBD::Pg::dr::connect at line 270 of DBD/Pg.pm # once (3µs+0s) by Sympa::DatabaseDriver::PostgreSQL::connect at line 66 of /usr/local/libexec/sympa/Sympa/DatabaseDriver/PostgreSQL.pm # once (2µs+0s) by DBI::connect at line 750 of DBI.pm # once (2µs+0s) by DBI::__ANON__[/usr/local/lib/perl5/site_perl/mach/5.32/DBI.pm:746] at line 734 of DBI.pm # once (1µs+0s) by Sympa::Database::_connect at line 203 of /usr/local/libexec/sympa/Sympa/Database.pm
sub DBI::common::STORE; # xsub
# spent 7µs within DBI::common::can which was called 2 times, avg 3µs/call: # 2 times (7µs+0s) by Sympa::Database::ping at line 453 of /usr/local/libexec/sympa/Sympa/Database.pm, avg 3µs/call
sub DBI::common::can; # xsub
# spent 2µs within DBI::db::connected which was called: # once (2µs+0s) by DBI::__ANON__[/usr/local/lib/perl5/site_perl/mach/5.32/DBI.pm:746] at line 741 of DBI.pm
sub DBI::db::connected; # xsub
# spent 155µs within DBI::db::do which was called 2 times, avg 78µs/call: # once (109µs+0s) by Sympa::DatabaseDriver::PostgreSQL::connect at line 67 of /usr/local/libexec/sympa/Sympa/DatabaseDriver/PostgreSQL.pm # once (46µs+0s) by Sympa::DatabaseDriver::PostgreSQL::connect at line 68 of /usr/local/libexec/sympa/Sympa/DatabaseDriver/PostgreSQL.pm
sub DBI::db::do; # xsub
# spent 132µs (8+124) within DBI::db::ping which was called 2 times, avg 66µs/call: # 2 times (8µs+124µs) by Sympa::Database::ping at line 454 of /usr/local/libexec/sympa/Sympa/Database.pm, avg 66µs/call
sub DBI::db::ping; # xsub
# spent 163µs (24+140) within DBI::db::prepare which was called 3 times, avg 54µs/call: # 2 times (20µs+101µs) by Sympa::Database::do_prepared_query at line 327 of /usr/local/libexec/sympa/Sympa/Database.pm, avg 60µs/call # once (4µs+39µs) by Sympa::Database::do_prepared_query at line 358 of /usr/local/libexec/sympa/Sympa/Database.pm
sub DBI::db::prepare; # xsub
# spent 6.67ms (6µs+6.67) within DBI::dr::connect which was called: # once (6µs+6.67ms) by DBI::__ANON__[/usr/local/lib/perl5/site_perl/mach/5.32/DBI.pm:746] at line 679 of DBI.pm
sub DBI::dr::connect; # xsub
# spent 10µs within DBI::dr::disconnect_all which was called: # once (10µs+0s) by DBI::disconnect_all at line 758 of DBI.pm
sub DBI::dr::disconnect_all; # xsub
# spent 372ms within DBI::st::execute which was called 2755 times, avg 135µs/call: # 2754 times (371ms+0s) by Sympa::Database::do_prepared_query at line 350 of /usr/local/libexec/sympa/Sympa/Database.pm, avg 135µs/call # once (1.17ms+0s) by Sympa::Database::do_prepared_query at line 381 of /usr/local/libexec/sympa/Sympa/Database.pm
sub DBI::st::execute; # xsub
# spent 6.74ms within DBI::st::fetchrow_array which was called 2754 times, avg 2µs/call: # 1377 times (3.84ms+0s) by Sympa::List::has_included_users at line 5800 of /usr/local/libexec/sympa/Sympa/List.pm, avg 3µs/call # 1377 times (2.90ms+0s) by Sympa::List::has_included_users at line 5817 of /usr/local/libexec/sympa/Sympa/List.pm, avg 2µs/call
sub DBI::st::fetchrow_array; # xsub
# spent 4µs within Internals::SvREADONLY which was called 4 times, avg 875ns/call: # 4 times (4µs+0s) by constant::import at line 164 of constant.pm, avg 875ns/call
sub Internals::SvREADONLY; # xsub
# spent 12.3ms within UNIVERSAL::can which was called 12163 times, avg 1µs/call: # 12161 times (12.3ms+0s) by Sympa::Log::syslog at line 112 of /usr/local/libexec/sympa/Sympa/Log.pm, avg 1µs/call # once (11µs+0s) by Sympa::Spindle::new at line 40 of /usr/local/libexec/sympa/Sympa/Spindle.pm # once (6µs+0s) by Sympa::Spindle::new at line 47 of /usr/local/libexec/sympa/Sympa/Spindle.pm
sub UNIVERSAL::can; # xsub
# spent 8µs within UNIVERSAL::isa which was called: # once (8µs+0s) by base::import at line 96 of base.pm
sub UNIVERSAL::isa; # xsub
# spent 26µs within main::CORE:chdir which was called: # once (26µs+0s) by main::RUNTIME at line 132
sub main::CORE:chdir; # opcode
# spent 54µs within main::CORE:ggrnam which was called 3 times, avg 18µs/call: # once (19µs+0s) by main::RUNTIME at line 119 # once (18µs+0s) by main::RUNTIME at line 114 # once (16µs+0s) by main::RUNTIME at line 122
sub main::CORE:ggrnam; # opcode
# spent 146µs within main::CORE:gpwnam which was called 3 times, avg 49µs/call: # once (51µs+0s) by main::RUNTIME at line 118 # once (49µs+0s) by main::RUNTIME at line 115 # once (45µs+0s) by main::RUNTIME at line 122
sub main::CORE:gpwnam; # opcode
# spent 10µs within main::CORE:umask which was called: # once (10µs+0s) by main::RUNTIME at line 129
sub main::CORE:umask; # opcode