← 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:07 2021

Filename/usr/local/libexec/sympa/Sympa/Spindle.pm
StatementsExecuted 1846 statements in 1.94ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
229111.96ms34.5sSympa::Spindle::::spinSympa::Spindle::spin
1111.74ms2.87msSympa::Spindle::::newSympa::Spindle::new
111300ns300nsSympa::Spindle::::CORE:sortSympa::Spindle::CORE:sort (opcode)
0000s0sSympa::Spindle::::BEGIN@30Sympa::Spindle::BEGIN@30
0000s0sSympa::Spindle::::BEGIN@31Sympa::Spindle::BEGIN@31
0000s0sSympa::Spindle::::BEGIN@32Sympa::Spindle::BEGIN@32
0000s0sSympa::Spindle::::BEGIN@33Sympa::Spindle::BEGIN@33
0000s0sSympa::Spindle::::_initSympa::Spindle::_init
0000s0sSympa::Spindle::::_on_failureSympa::Spindle::_on_failure
0000s0sSympa::Spindle::::_on_garbageSympa::Spindle::_on_garbage
0000s0sSympa::Spindle::::_on_skipSympa::Spindle::_on_skip
0000s0sSympa::Spindle::::_on_successSympa::Spindle::_on_success
0000s0sSympa::Spindle::::_twistSympa::Spindle::_twist
0000s0sSympa::Spindle::::add_stashSympa::Spindle::add_stash
0000s0sSympa::Spindle::::successSympa::Spindle::success
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# -*- indent-tabs-mode: nil; -*-
2# vim:ft=perl:et:sw=4
3# $Id$
4
5# Sympa - SYsteme de Multi-Postage Automatique
6#
7# Copyright (c) 1997, 1998, 1999 Institut Pasteur & Christophe Wolfhugel
8# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
9# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
10# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER
11# Copyright 2017 The Sympa Community. See the AUTHORS.md file at the top-level
12# directory of this distribution and at
13# <https://github.com/sympa-community/sympa.git>.
14#
15# This program is free software; you can redistribute it and/or modify
16# it under the terms of the GNU General Public License as published by
17# the Free Software Foundation; either version 2 of the License, or
18# (at your option) any later version.
19#
20# This program is distributed in the hope that it will be useful,
21# but WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23# GNU General Public License for more details.
24#
25# You should have received a copy of the GNU General Public License
26# along with this program. If not, see <http://www.gnu.org/licenses/>.
27
28package Sympa::Spindle;
29
30use strict;
31use warnings;
32use English qw(-no_match_vars);
33use Time::HiRes qw();
34
35
# spent 2.87ms (1.74+1.13) within Sympa::Spindle::new which was called: # once (1.74ms+1.13ms) by main::RUNTIME at line 140 of /usr/local/libexec/sympa/task_manager-debug.pl
sub new {
3611µs my $class = shift;
371700ns my %options = @_;
38
391900ns my $distaff;
40131µs111µs if ($class->can('_distaff')) {
# spent 11µs making 1 call to UNIVERSAL::can
411152µs1600ns die $EVAL_ERROR unless eval sprintf 'require %s', $class->_distaff;
# spent 600ns making 1 call to Sympa::Spindle::ProcessTask::_distaff
# spent 248µs executing statements in string eval
42125µs2352µs $distaff = $class->_distaff->new(%options);
# spent 351µs making 1 call to Sympa::Spool::new # spent 1µs making 1 call to Sympa::Spindle::ProcessTask::_distaff
431700ns return undef unless $distaff;
44 }
45
461300ns my %spools;
47111µs16µs my $spools = $class->_spools if $class->can('_spools');
# spent 6µs making 1 call to UNIVERSAL::can
48121µs1300ns foreach my $key (sort keys %{$spools || {}}) {
# spent 300ns making 1 call to Sympa::Spindle::CORE:sort
49 die $EVAL_ERROR unless eval sprintf 'require %s', $spools->{$key};
50 my $spool = $spools->{$key}->new;
51 return undef unless $spool;
52
53 $spools{$key} = $spool;
54 }
55
5613µs my $self = bless {%options, %spools, distaff => $distaff} => $class;
5718µs $self->{stash} ||= [];
58
5914µs16µs $self->_init(0) or return undef;
# spent 6µs making 1 call to Sympa::Spindle::ProcessTask::_init
6015µs $self;
61}
62
63sub add_stash {
64 my $self = shift;
65 my @params = @_;
66
67 $self->{stash} ||= [];
68 push @{$self->{stash}}, [@params];
69}
70
71
# spent 34.5s (1.96ms+34.5) within Sympa::Spindle::spin which was called 229 times, avg 151ms/call: # 229 times (1.96ms+34.5s) by main::RUNTIME at line 148 of /usr/local/libexec/sympa/task_manager-debug.pl, avg 151ms/call
sub spin {
7222962µs my $self = shift;
73
7422962µs my $processed = 0;
75
7622934µs while (1) {
77229358µs2294.24ms $self->_init(1);
# spent 4.24ms making 229 calls to Sympa::Spindle::ProcessTask::_init, avg 19µs/call
78229483µs22934.5s my ($message, $handle) = $self->{distaff}->next;
# spent 34.5s making 229 calls to Sympa::Spool::next, avg 150ms/call
79
80229121µs if ($message and $handle) {
81 $self->{start_time} = Time::HiRes::time();
82
83 my $status = $self->_twist($message);
84 # If the result is arrayref, splice to the classes in it.
85 while (ref $status eq 'ARRAY' and @$status) {
86 foreach my $class (@$status) {
87 die sprintf 'Illegal package name "%s"', $class
88 unless $class =~ /\A(?:\w+::)*\w+\z/;
89 die $EVAL_ERROR unless eval sprintf 'require %s', $class;
90 my $twist = $class->can('_twist')
91 or die sprintf
92 'Can\'t locate object method "_twist" via package "%s"',
93 $class;
94
95 $status = $self->$twist($message);
96 last unless $status;
97 }
98 }
99
100 unless (defined $status) {
101 $self->_on_failure($message, $handle);
102 } elsif ($status) {
103 $self->_on_success($message, $handle);
104 } else {
105 $self->_on_skip($message, $handle);
106 }
107
108 $processed++;
109 $self->_init(2);
110 } elsif ($handle) {
111 $self->_on_garbage($handle);
112 } else {
113229126µs last;
114 }
115
116 last if $self->{finish};
117 }
118
119229426µs return $processed;
120}
121
122sub _init {1}
123
124sub _on_failure {
125 my $self = shift;
126 my $message = shift;
127 my $handle = shift;
128
129 $self->{distaff}->quarantine($handle);
130}
131
132sub _on_success {
133 my $self = shift;
134 my $message = shift;
135 my $handle = shift;
136
137 $self->{distaff}->remove($handle);
138}
139
140sub _on_skip {
141 my $self = shift;
142 my $message = shift;
143 my $handle = shift;
144
145 $handle->close if ref $handle;
146}
147
148sub _on_garbage {
149 my $self = shift;
150 my $handle = shift;
151
152 $self->{distaff}->quarantine($handle);
153}
154
155sub success {
156 my $self = shift;
157
158 my $stash = $self->{stash} || [];
159 return (
160 grep { $_->[1] eq 'intern' or $_->[1] eq 'auth' or $_->[1] eq 'user' }
161 @$stash
162 ) ? 0 : 1;
163}
164
165sub _twist {0}
166
1671;
168__END__
 
# spent 300ns within Sympa::Spindle::CORE:sort which was called: # once (300ns+0s) by Sympa::Spindle::new at line 48
sub Sympa::Spindle::CORE:sort; # opcode