← Index
NYTProf Performance Profile   « line view »
For starman worker -M FindBin --max-requests 50 --workers 2 --user=kohadev-koha --group kohadev-koha --pid /var/run/koha/kohadev/plack.pid --daemonize --access-log /var/log/koha/kohadev/plack.log --error-log /var/log/koha/kohadev/plack-error.log -E deployment --socket /var/run/koha/kohadev/plack.sock /etc/koha/sites/kohadev/plack.psgi
  Run on Fri Jan 8 13:01:18 2016
Reported on Fri Jan 8 13:01:36 2016

Filename/usr/share/perl5/DBIx/Class/Storage/BlockRunner.pm
StatementsExecuted 138 statements in 2.78ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1118.12ms10.4msDBIx::Class::Storage::BlockRunner::::BEGIN@16DBIx::Class::Storage::BlockRunner::BEGIN@16
111367µs503µsDBIx::Class::Storage::BlockRunner::::BEGIN@9DBIx::Class::Storage::BlockRunner::BEGIN@9
41196µs2.46msDBIx::Class::Storage::BlockRunner::::runDBIx::Class::Storage::BlockRunner::run
41173µs1.65msDBIx::Class::Storage::BlockRunner::::_runDBIx::Class::Storage::BlockRunner::_run
42138µs64µsDBIx::Class::Storage::BlockRunner::::__ANON__[:233]DBIx::Class::Storage::BlockRunner::__ANON__[:233]
42137µs1.43msDBIx::Class::Storage::BlockRunner::::__ANON__[:155]DBIx::Class::Storage::BlockRunner::__ANON__[:155]
11114µs18µsDBIx::Class::Storage::BlockRunner::::BEGIN@4DBIx::Class::Storage::BlockRunner::BEGIN@4
11111µs30µsDBIx::Class::Storage::BlockRunner::::BEGIN@10DBIx::Class::Storage::BlockRunner::BEGIN@10
11111µs233µsDBIx::Class::Storage::BlockRunner::::BEGIN@34DBIx::Class::Storage::BlockRunner::BEGIN@34
11110µs28µsDBIx::Class::Storage::BlockRunner::::BEGIN@12DBIx::Class::Storage::BlockRunner::BEGIN@12
1119µs30µsDBIx::Class::Storage::BlockRunner::::BEGIN@11DBIx::Class::Storage::BlockRunner::BEGIN@11
1117µs40µsDBIx::Class::Storage::BlockRunner::::__ANON__[:29]DBIx::Class::Storage::BlockRunner::__ANON__[:29]
1117µs13µsDBIx::Class::Storage::BlockRunner::::BEGIN@5DBIx::Class::Storage::BlockRunner::BEGIN@5
1116µs35µsDBIx::Class::Storage::BlockRunner::::BEGIN@8DBIx::Class::Storage::BlockRunner::BEGIN@8
1116µs6µsDBIx::Class::Storage::BlockRunner::::BEGIN@7DBIx::Class::Storage::BlockRunner::BEGIN@7
2211µs1µsDBIx::Class::Storage::BlockRunner::::storageDBIx::Class::Storage::BlockRunner::storage (xsub)
1111µs1µsDBIx::Class::Storage::BlockRunner::::max_attemptsDBIx::Class::Storage::BlockRunner::max_attempts (xsub)
111700ns700nsDBIx::Class::Storage::BlockRunner::::wrap_txnDBIx::Class::Storage::BlockRunner::wrap_txn (xsub)
0000s0sDBIx::Class::Storage::BlockRunner::::__ANON__[:151]DBIx::Class::Storage::BlockRunner::__ANON__[:151]
0000s0sDBIx::Class::Storage::BlockRunner::::__ANON__[:154]DBIx::Class::Storage::BlockRunner::__ANON__[:154]
0000s0sDBIx::Class::Storage::BlockRunner::::catch {...} DBIx::Class::Storage::BlockRunner::catch {...}
0000s0sDBIx::Class::Storage::BlockRunner::::last_exceptionDBIx::Class::Storage::BlockRunner::last_exception
0000s0sDBIx::Class::Storage::BlockRunner::::throw_exceptionDBIx::Class::Storage::BlockRunner::throw_exception
0000s0sDBIx::Class::Storage::BlockRunner::::try {...} DBIx::Class::Storage::BlockRunner::try {...}
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package # hide from pause until we figure it all out
2 DBIx::Class::Storage::BlockRunner;
3
4232µs223µs
# spent 18µs (14+5) within DBIx::Class::Storage::BlockRunner::BEGIN@4 which was called: # once (14µs+5µs) by DBIx::Class::Storage::BEGIN@16 at line 4
use warnings;
# spent 18µs making 1 call to DBIx::Class::Storage::BlockRunner::BEGIN@4 # spent 4µs making 1 call to warnings::import
5229µs219µs
# spent 13µs (7+6) within DBIx::Class::Storage::BlockRunner::BEGIN@5 which was called: # once (7µs+6µs) by DBIx::Class::Storage::BEGIN@16 at line 5
use strict;
# spent 13µs making 1 call to DBIx::Class::Storage::BlockRunner::BEGIN@5 # spent 6µs making 1 call to strict::import
6
7221µs16µs
# spent 6µs within DBIx::Class::Storage::BlockRunner::BEGIN@7 which was called: # once (6µs+0s) by DBIx::Class::Storage::BEGIN@16 at line 7
use DBIx::Class::Exception;
# spent 6µs making 1 call to DBIx::Class::Storage::BlockRunner::BEGIN@7
8227µs264µs
# spent 35µs (6+29) within DBIx::Class::Storage::BlockRunner::BEGIN@8 which was called: # once (6µs+29µs) by DBIx::Class::Storage::BEGIN@16 at line 8
use DBIx::Class::Carp;
# spent 35µs making 1 call to DBIx::Class::Storage::BlockRunner::BEGIN@8 # spent 29µs making 1 call to DBIx::Class::Carp::import
92167µs2524µs
# spent 503µs (367+136) within DBIx::Class::Storage::BlockRunner::BEGIN@9 which was called: # once (367µs+136µs) by DBIx::Class::Storage::BEGIN@16 at line 9
use Context::Preserve 'preserve_context';
# spent 503µs making 1 call to DBIx::Class::Storage::BlockRunner::BEGIN@9 # spent 21µs making 1 call to Exporter::import
10250µs249µs
# spent 30µs (11+19) within DBIx::Class::Storage::BlockRunner::BEGIN@10 which was called: # once (11µs+19µs) by DBIx::Class::Storage::BEGIN@16 at line 10
use DBIx::Class::_Util qw(is_exception qsub);
# spent 30µs making 1 call to DBIx::Class::Storage::BlockRunner::BEGIN@10 # spent 19µs making 1 call to Exporter::import
11247µs251µs
# spent 30µs (9+21) within DBIx::Class::Storage::BlockRunner::BEGIN@11 which was called: # once (9µs+21µs) by DBIx::Class::Storage::BEGIN@16 at line 11
use Scalar::Util qw(weaken blessed reftype);
# spent 30µs making 1 call to DBIx::Class::Storage::BlockRunner::BEGIN@11 # spent 21µs making 1 call to Exporter::import
122128µs247µs
# spent 28µs (10+19) within DBIx::Class::Storage::BlockRunner::BEGIN@12 which was called: # once (10µs+19µs) by DBIx::Class::Storage::BEGIN@16 at line 12
use Try::Tiny;
# spent 28µs making 1 call to DBIx::Class::Storage::BlockRunner::BEGIN@12 # spent 19µs making 1 call to Exporter::import
13
14# DO NOT edit away without talking to riba first, he will just put it back
15# BEGIN pre-Moo2 import block
16
# spent 10.4ms (8.12+2.29) within DBIx::Class::Storage::BlockRunner::BEGIN@16 which was called: # once (8.12ms+2.29ms) by DBIx::Class::Storage::BEGIN@16 at line 31
BEGIN {
1714µs my $initial_fatal_bits = (${^WARNING_BITS}||'') & $warnings::DeadBits{all};
18
1915µs local $ENV{PERL_STRICTURES_EXTRA} = 0;
20 # load all of these now, so that lazy-loading does not escape
21 # the current PERL_STRICTURES_EXTRA setting
2212µs require Sub::Quote;
231400ns require Sub::Defer;
241100µs require Moo;
25185µs require Moo::Object;
261113µs require Method::Generate::Accessor;
271175µs require Method::Generate::Constructor;
28
29322µs3330µs
# spent 40µs (7+32) within DBIx::Class::Storage::BlockRunner::__ANON__[/usr/share/perl5/DBIx/Class/Storage/BlockRunner.pm:29] which was called: # once (7µs+32µs) by import::into at line 36 of Import/Into.pm
Moo->import;
# spent 298µs making 1 call to Moo::import # spent 22µs making 1 call to strictures::import # spent 10µs making 1 call to Module::Runtime::use_module
30110µs ${^WARNING_BITS} &= ( $initial_fatal_bits | ~ $warnings::DeadBits{all} );
31134µs110.4ms}
# spent 10.4ms making 1 call to DBIx::Class::Storage::BlockRunner::BEGIN@16
32# END pre-Moo2 import block
33
3421.36ms2456µs
# spent 233µs (11+223) within DBIx::Class::Storage::BlockRunner::BEGIN@34 which was called: # once (11µs+223µs) by DBIx::Class::Storage::BEGIN@16 at line 34
use namespace::clean;
# spent 233µs making 1 call to DBIx::Class::Storage::BlockRunner::BEGIN@34 # spent 223µs making 1 call to namespace::clean::import
35
36=head1 NAME
37
38DBIx::Class::Storage::BlockRunner - Try running a block of code until success with a configurable retry logic
39
40=head1 DESCRIPTION
41
42=head1 METHODS
43
44=cut
45
4612µs11.34mshas storage => (
# spent 1.34ms making 1 call to Moo::has
47 is => 'ro',
48 required => 1,
49);
50
5111µs1106µshas wrap_txn => (
# spent 106µs making 1 call to Moo::has
52 is => 'ro',
53 required => 1,
54);
55
56# true - retry, false - rethrow, or you can throw your own (not catching)
5713µs2137µshas retry_handler => (
# spent 134µs making 1 call to Moo::has # spent 3µs making 1 call to DBIx::Class::_Util::qsub
58 is => 'ro',
59 required => 1,
60 isa => qsub q{
61 (Scalar::Util::reftype($_[0])||'') eq 'CODE'
62 or DBIx::Class::Exception->throw('retry_handler must be a CODE reference')
63 },
64);
65
6612µs2425µshas retry_debug => (
# spent 423µs making 1 call to Moo::has # spent 2µs making 1 call to DBIx::Class::_Util::qsub
67 is => 'rw',
68 # use a sub - to be evaluated on the spot lazily
69 default => qsub '$ENV{DBIC_STORAGE_RETRY_DEBUG}',
70 lazy => 1,
71);
72
731900ns1113µshas max_attempts => (
# spent 113µs making 1 call to Moo::has
74 is => 'ro',
75 default => 20,
76);
77
7813µs2412µshas failed_attempt_count => (
# spent 410µs making 1 call to Moo::has # spent 2µs making 1 call to DBIx::Class::_Util::qsub
79 is => 'ro',
80 init_arg => undef, # ensures one can't pass the value in
81 writer => '_set_failed_attempt_count',
82 default => 0,
83 lazy => 1,
84 trigger => qsub q{
85 $_[0]->throw_exception( sprintf (
86 'Reached max_attempts amount of %d, latest exception: %s',
87 $_[0]->max_attempts, $_[0]->last_exception
88 )) if $_[0]->max_attempts <= ($_[1]||0);
89 },
90);
91
9214µs2294µshas exception_stack => (
# spent 291µs making 1 call to Moo::has # spent 3µs making 1 call to DBIx::Class::_Util::qsub
93 is => 'ro',
94 init_arg => undef,
95 clearer => '_reset_exception_stack',
96 default => qsub q{ [] },
97 lazy => 1,
98);
99
100sub last_exception { shift->exception_stack->[-1] }
101
102sub throw_exception { shift->storage->throw_exception (@_) }
103
104
# spent 2.46ms (96µs+2.37) within DBIx::Class::Storage::BlockRunner::run which was called 4 times, avg 616µs/call: # 4 times (96µs+2.37ms) by DBIx::Class::Storage::DBI::dbh_do at line 855 of DBIx/Class/Storage/DBI.pm, avg 616µs/call
sub run {
10542µs my $self = shift;
106
10748µs4279µs $self->_reset_exception_stack;
# spent 279µs making 4 calls to DBIx::Class::Storage::BlockRunner::_reset_exception_stack, avg 70µs/call
10849µs4414µs $self->_set_failed_attempt_count(0);
# spent 414µs making 4 calls to DBIx::Class::Storage::BlockRunner::_set_failed_attempt_count, avg 103µs/call
109
11042µs my $cref = shift;
111
112413µs44µs $self->throw_exception('run() requires a coderef to execute as its first argument')
# spent 4µs making 4 calls to Scalar::Util::reftype, avg 900ns/call
113 if ( reftype($cref)||'' ) ne 'CODE';
114
115410µs1800ns my $storage = $self->storage;
# spent 800ns making 1 call to DBIx::Class::Storage::BlockRunner::storage
116
117413µs return $cref->( @_ ) if (
118 $storage->{_in_do_block}
119 and
120 ! $self->wrap_txn
121 );
122
12344µs local $storage->{_in_do_block} = 1 unless $storage->{_in_do_block};
124
125417µs41.65ms return $self->_run($cref, @_);
# spent 1.65ms making 4 calls to DBIx::Class::Storage::BlockRunner::_run, avg 413µs/call
126}
127
128# this is the actual recursing worker
129
# spent 1.65ms (73µs+1.58) within DBIx::Class::Storage::BlockRunner::_run which was called 4 times, avg 413µs/call: # 4 times (73µs+1.58ms) by DBIx::Class::Storage::BlockRunner::run at line 125, avg 413µs/call
sub _run {
130 # internal method - we know that both refs are strong-held by the
131 # calling scope of run(), hence safe to weaken everything
132416µs45µs weaken( my $self = shift );
# spent 5µs making 4 calls to Scalar::Util::weaken, avg 1µs/call
133410µs42µs weaken( my $cref = shift );
# spent 2µs making 4 calls to Scalar::Util::weaken, avg 600ns/call
134
13544µs my $args = @_ ? \@_ : [];
136
137 # from this point on (defined $txn_init_depth) is an indicator for wrap_txn
138 # save a bit on method calls
13949µs1700ns my $txn_init_depth = $self->wrap_txn ? $self->storage->transaction_depth : undef;
# spent 700ns making 1 call to DBIx::Class::Storage::BlockRunner::wrap_txn
14041µs my $txn_begin_ok;
141
14241µs my $run_err = '';
143
144
# spent 1.43ms (37µs+1.39) within DBIx::Class::Storage::BlockRunner::__ANON__[/usr/share/perl5/DBIx/Class/Storage/BlockRunner.pm:155] which was called 4 times, avg 357µs/call: # 3 times (27µs+1.03ms) by Context::Preserve::preserve_context at line 32 of Context/Preserve.pm, avg 351µs/call # once (10µs+364µs) by Context::Preserve::preserve_context at line 22 of Context/Preserve.pm
return preserve_context {
145 try {
14641µs if (defined $txn_init_depth) {
147 $self->storage->txn_begin;
148 $txn_begin_ok = 1;
149 }
15046µs41.25ms $cref->( @$args );
# spent 1.25ms making 4 calls to DBIx::Class::Storage::DBI::__ANON__[DBIx/Class/Storage/DBI.pm:855], avg 312µs/call
151 } catch {
152 $run_err = $_;
153 (); # important, affects @_ below
1544134µs81.39ms };
# spent 1.36ms making 4 calls to Try::Tiny::try, avg 341µs/call # spent 27µs making 4 calls to Try::Tiny::catch, avg 7µs/call
155
# spent 64µs (38+26) within DBIx::Class::Storage::BlockRunner::__ANON__[/usr/share/perl5/DBIx/Class/Storage/BlockRunner.pm:233] which was called 4 times, avg 16µs/call: # 3 times (24µs+19µs) by Context::Preserve::preserve_context at line 37 of Context/Preserve.pm, avg 14µs/call # once (14µs+8µs) by Context::Preserve::preserve_context at line 27 of Context/Preserve.pm
} replace => sub {
15643µs my @res = @_;
157
15848µs1500ns my $storage = $self->storage;
# spent 500ns making 1 call to DBIx::Class::Storage::BlockRunner::storage
15946µs1600ns my $cur_depth = $storage->transaction_depth;
160
16142µs if (defined $txn_init_depth and ! is_exception $run_err) {
162 my $delta_txn = (1 + $txn_init_depth) - $cur_depth;
163
164 if ($delta_txn) {
165 # a rollback in a top-level txn_do is valid-ish (seen in the wild and our own tests)
166 carp (sprintf
167 'Unexpected reduction of transaction depth by %d after execution of '
168 . '%s, skipping txn_commit()',
169 $delta_txn,
170 $cref,
171 ) unless $delta_txn == 1 and $cur_depth == 0;
172 }
173 else {
174 $run_err = eval { $storage->txn_commit; 1 } ? '' : $@;
175 }
176 }
177
178 # something above threw an error (could be the begin, the code or the commit)
179410µs425µs if ( is_exception $run_err ) {
# spent 25µs making 4 calls to DBIx::Class::_Util::is_exception, avg 6µs/call
180
181 # attempt a rollback if we did begin in the first place
182 if ($txn_begin_ok) {
183 # some DBDs go crazy if there is nothing to roll back on, perform a soft-check
184 my $rollback_exception = $storage->_seems_connected
185 ? (! eval { $storage->txn_rollback; 1 }) ? $@ : ''
186 : 'lost connection to storage'
187 ;
188
189 if ( $rollback_exception and (
190 ! defined blessed $rollback_exception
191 or
192 ! $rollback_exception->isa('DBIx::Class::Storage::NESTED_ROLLBACK_EXCEPTION')
193 ) ) {
194 $run_err = "Transaction aborted: $run_err. Rollback failed: $rollback_exception";
195 }
196 }
197
198 push @{ $self->exception_stack }, $run_err;
199
200 # this will throw if max_attempts is reached
201 $self->_set_failed_attempt_count($self->failed_attempt_count + 1);
202
203 # init depth of > 0 ( > 1 with AC) implies nesting - no retry attempt queries
204 $storage->throw_exception($run_err) if (
205 (
206 defined $txn_init_depth
207 and
208 $txn_init_depth > ( $storage->{_dbh_autocommit} ? 0 : 1 )
209
210
211 ) or ! $self->retry_handler->($self)
212 );
213
214 # we got that far - let's retry
215 carp( sprintf 'Retrying %s (attempt %d) after caught exception: %s',
216 $cref,
217 $self->failed_attempt_count + 1,
218 $run_err,
219 ) if $self->retry_debug;
220
221 $storage->ensure_connected;
222 # if txn_depth is > 1 this means something was done to the
223 # original $dbh, otherwise we would not get past the preceding if()
224 $storage->throw_exception(sprintf
225 'Unexpected transaction depth of %d on freshly connected handle',
226 $storage->transaction_depth,
227 ) if (defined $txn_init_depth and $storage->transaction_depth);
228
229 return $self->_run($cref, @$args);
230 }
231
232413µs return wantarray ? @res : $res[0];
233440µs41.57ms };
# spent 1.57ms making 4 calls to Context::Preserve::preserve_context, avg 393µs/call
234}
235
236=head1 FURTHER QUESTIONS?
237
238Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
239
240=head1 COPYRIGHT AND LICENSE
241
242This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
243by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
244redistribute it and/or modify it under the same terms as the
245L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.
246
247=cut
248
249116µs1370µs1;
# spent 370µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__
 
# spent 1µs within DBIx::Class::Storage::BlockRunner::max_attempts which was called: # once (1µs+0s) by DBIx::Class::Storage::BlockRunner::_set_failed_attempt_count at line 29 of (eval 1107)[Sub/Quote.pm:5]
sub DBIx::Class::Storage::BlockRunner::max_attempts; # xsub
# spent 1µs within DBIx::Class::Storage::BlockRunner::storage which was called 2 times, avg 650ns/call: # once (800ns+0s) by DBIx::Class::Storage::BlockRunner::run at line 115 # once (500ns+0s) by DBIx::Class::Storage::BlockRunner::__ANON__[/usr/share/perl5/DBIx/Class/Storage/BlockRunner.pm:233] at line 158
sub DBIx::Class::Storage::BlockRunner::storage; # xsub
# spent 700ns within DBIx::Class::Storage::BlockRunner::wrap_txn which was called: # once (700ns+0s) by DBIx::Class::Storage::BlockRunner::_run at line 139
sub DBIx::Class::Storage::BlockRunner::wrap_txn; # xsub