← Index
NYTProf Performance Profile   « line view »
For /home/ss5/perl5/perlbrew/perls/perl-5.22.0/bin/benchmarkanything-storage
  Run on Mon Jan 29 16:55:34 2018
Reported on Mon Jan 29 16:57:07 2018

Filename/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Search/Elasticsearch/Role/CxnPool.pm
StatementsExecuted 27053 statements in 95.3ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
10011141.4ms636msSearch::Elasticsearch::Role::CxnPool::::set_cxnsSearch::Elasticsearch::Role::CxnPool::set_cxns
10011121.3ms31.2msSearch::Elasticsearch::Role::CxnPool::::__ANON__[:33]Search::Elasticsearch::Role::CxnPool::__ANON__[:33]
1001118.35ms16.4msSearch::Elasticsearch::Role::CxnPool::::request_okSearch::Elasticsearch::Role::CxnPool::request_ok
1001116.26ms6.26msSearch::Elasticsearch::Role::CxnPool::::next_cxn_numSearch::Elasticsearch::Role::CxnPool::next_cxn_num
1001113.05ms3.05msSearch::Elasticsearch::Role::CxnPool::::reset_retriesSearch::Elasticsearch::Role::CxnPool::reset_retries
1001112.03ms2.03msSearch::Elasticsearch::Role::CxnPool::::__ANON__[:17]Search::Elasticsearch::Role::CxnPool::__ANON__[:17]
111920µs1.04msSearch::Elasticsearch::Role::CxnPool::::BEGIN@6Search::Elasticsearch::Role::CxnPool::BEGIN@6
111589µs1.34msSearch::Elasticsearch::Role::CxnPool::::BEGIN@7Search::Elasticsearch::Role::CxnPool::BEGIN@7
11123µs69µsSearch::Elasticsearch::Role::CxnPool::::BEGIN@5Search::Elasticsearch::Role::CxnPool::BEGIN@5
11110µs681µsSearch::Elasticsearch::Role::CxnPool::::BEGIN@3Search::Elasticsearch::Role::CxnPool::BEGIN@3
1119µs268µsSearch::Elasticsearch::Role::CxnPool::::BEGIN@4Search::Elasticsearch::Role::CxnPool::BEGIN@4
1117µs171µsSearch::Elasticsearch::Role::CxnPool::::BEGIN@9Search::Elasticsearch::Role::CxnPool::BEGIN@9
1116µs120µsSearch::Elasticsearch::Role::CxnPool::::BEGIN@8Search::Elasticsearch::Role::CxnPool::BEGIN@8
1113µs3µsSearch::Elasticsearch::Role::CxnPool::::_set_cxnsSearch::Elasticsearch::Role::CxnPool::_set_cxns (xsub)
2213µs3µsSearch::Elasticsearch::Role::CxnPool::::_set_current_cxn_numSearch::Elasticsearch::Role::CxnPool::_set_current_cxn_num (xsub)
3332µs2µsSearch::Elasticsearch::Role::CxnPool::::cxnsSearch::Elasticsearch::Role::CxnPool::cxns (xsub)
1112µs2µsSearch::Elasticsearch::Role::CxnPool::::randomize_cxnsSearch::Elasticsearch::Role::CxnPool::randomize_cxns (xsub)
3322µs2µsSearch::Elasticsearch::Role::CxnPool::::loggerSearch::Elasticsearch::Role::CxnPool::logger (xsub)
1111µs1µsSearch::Elasticsearch::Role::CxnPool::::retriesSearch::Elasticsearch::Role::CxnPool::retries (xsub)
2221µs1µsSearch::Elasticsearch::Role::CxnPool::::cxn_factorySearch::Elasticsearch::Role::CxnPool::cxn_factory (xsub)
111600ns600nsSearch::Elasticsearch::Role::CxnPool::::current_cxn_numSearch::Elasticsearch::Role::CxnPool::current_cxn_num (xsub)
111400ns400nsSearch::Elasticsearch::Role::CxnPool::::seed_nodesSearch::Elasticsearch::Role::CxnPool::seed_nodes (xsub)
0000s0sSearch::Elasticsearch::Role::CxnPool::::_max_retriesSearch::Elasticsearch::Role::CxnPool::_max_retries
0000s0sSearch::Elasticsearch::Role::CxnPool::::cxns_seeds_strSearch::Elasticsearch::Role::CxnPool::cxns_seeds_str
0000s0sSearch::Elasticsearch::Role::CxnPool::::cxns_strSearch::Elasticsearch::Role::CxnPool::cxns_str
0000s0sSearch::Elasticsearch::Role::CxnPool::::request_failedSearch::Elasticsearch::Role::CxnPool::request_failed
0000s0sSearch::Elasticsearch::Role::CxnPool::::should_mark_deadSearch::Elasticsearch::Role::CxnPool::should_mark_dead
0000s0sSearch::Elasticsearch::Role::CxnPool::::should_retrySearch::Elasticsearch::Role::CxnPool::should_retry
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Search::Elasticsearch::Role::CxnPool;
21400ns$Search::Elasticsearch::Role::CxnPool::VERSION = '5.01';
3227µs21.35ms
# spent 681µs (10+671) within Search::Elasticsearch::Role::CxnPool::BEGIN@3 which was called: # once (10µs+671µs) by Module::Runtime::require_module at line 3
use Moo::Role;
# spent 681µs making 1 call to Search::Elasticsearch::Role::CxnPool::BEGIN@3 # spent 671µs making 1 call to Moo::Role::import
4229µs2527µs
# spent 268µs (9+259) within Search::Elasticsearch::Role::CxnPool::BEGIN@4 which was called: # once (9µs+259µs) by Module::Runtime::require_module at line 4
use Search::Elasticsearch::Util qw(parse_params);
# spent 268µs making 1 call to Search::Elasticsearch::Role::CxnPool::BEGIN@4 # spent 259µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
5223µs281µs
# spent 69µs (23+46) within Search::Elasticsearch::Role::CxnPool::BEGIN@5 which was called: # once (23µs+46µs) by Module::Runtime::require_module at line 5
use List::Util qw(shuffle);
# spent 69µs making 1 call to Search::Elasticsearch::Role::CxnPool::BEGIN@5 # spent 12µs making 1 call to List::Util::import
62127µs11.04ms
# spent 1.04ms (920µs+121µs) within Search::Elasticsearch::Role::CxnPool::BEGIN@6 which was called: # once (920µs+121µs) by Module::Runtime::require_module at line 6
use IO::Select();
# spent 1.04ms making 1 call to Search::Elasticsearch::Role::CxnPool::BEGIN@6
7298µs21.52ms
# spent 1.34ms (589µs+752µs) within Search::Elasticsearch::Role::CxnPool::BEGIN@7 which was called: # once (589µs+752µs) by Module::Runtime::require_module at line 7
use Time::HiRes qw(time sleep);
# spent 1.34ms making 1 call to Search::Elasticsearch::Role::CxnPool::BEGIN@7 # spent 179µs making 1 call to Time::HiRes::import
8225µs2234µs
# spent 120µs (6+114) within Search::Elasticsearch::Role::CxnPool::BEGIN@8 which was called: # once (6µs+114µs) by Module::Runtime::require_module at line 8
use Search::Elasticsearch::Util qw(to_list);
# spent 120µs making 1 call to Search::Elasticsearch::Role::CxnPool::BEGIN@8 # spent 114µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
92422µs2335µs
# spent 171µs (7+164) within Search::Elasticsearch::Role::CxnPool::BEGIN@9 which was called: # once (7µs+164µs) by Module::Runtime::require_module at line 9
use namespace::clean;
# spent 171µs making 1 call to Search::Elasticsearch::Role::CxnPool::BEGIN@9 # spent 164µs making 1 call to namespace::clean::import
10
1111µs114µsrequires qw(next_cxn schedule_check);
# spent 14µs making 1 call to Moo::Role::requires
12
131800ns1127µshas 'cxn_factory' => ( is => 'ro', required => 1 );
# spent 127µs making 1 call to Moo::Role::has
141500ns158µshas 'logger' => ( is => 'ro', required => 1 );
# spent 58µs making 1 call to Moo::Role::has
151500ns150µshas 'serializer' => ( is => 'ro', required => 1 );
# spent 50µs making 1 call to Moo::Role::has
161500ns198µshas 'current_cxn_num' => ( is => 'rwp', default => 0 );
# spent 98µs making 1 call to Moo::Role::has
17100214.1ms199µs
# spent 2.03ms within Search::Elasticsearch::Role::CxnPool::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Search/Elasticsearch/Role/CxnPool.pm:17] which was called 1001 times, avg 2µs/call: # 1001 times (2.03ms+0s) by Search::Elasticsearch::CxnPool::Static::new at line 50 of (eval 282)[Sub/Quote.pm:3], avg 2µs/call
has 'cxns' => ( is => 'rwp', default => sub { [] } );
# spent 99µs making 1 call to Moo::Role::has
181600ns152µshas 'seed_nodes' => ( is => 'ro', required => 1 );
# spent 52µs making 1 call to Moo::Role::has
191500ns169µshas 'retries' => ( is => 'rw', default => 0 );
# spent 69µs making 1 call to Moo::Role::has
201600ns147µshas 'randomize_cxns' => ( is => 'ro', default => 1 );
# spent 47µs making 1 call to Moo::Role::has
21
22#===================================
23
# spent 31.2ms (21.3+9.86) within Search::Elasticsearch::Role::CxnPool::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Search/Elasticsearch/Role/CxnPool.pm:33] which was called 1001 times, avg 31µs/call: # 1001 times (21.3ms+9.86ms) by Search::Elasticsearch::CxnPool::Static::__ANON__[(eval 279)[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Class/Method/Modifiers.pm:93]:1] at line 1 of (eval 279)[Class/Method/Modifiers.pm:93], avg 31µs/call
around BUILDARGS => sub {
24#===================================
251001458µs my $orig = shift;
2610012.97ms10016.56ms my $params = $orig->(@_);
# spent 6.56ms making 1001 calls to Moo::Object::BUILDARGS, avg 7µs/call
2710013.64ms10013.30ms my @seed = grep {$_} to_list( delete $params->{nodes} || ('') );
# spent 3.30ms making 1001 calls to Search::Elasticsearch::Util::to_list, avg 3µs/call
28
29 @seed = $params->{cxn_factory}->default_host
3010013.05ms12µs unless @seed;
311001822µs $params->{seed_nodes} = \@seed;
3210019.78ms return $params;
3312µs16µs};
# spent 6µs making 1 call to Moo::Role::around
34
35#===================================
36
# spent 6.26ms (6.26+2µs) within Search::Elasticsearch::Role::CxnPool::next_cxn_num which was called 1001 times, avg 6µs/call: # 1001 times (6.26ms+2µs) by Search::Elasticsearch::CxnPool::Static::next_cxn at line 21 of Search/Elasticsearch/CxnPool/Static.pm, avg 6µs/call
sub next_cxn_num {
37#===================================
381001439µs my $self = shift;
391001624µs1300ns my $cxns = $self->cxns;
# spent 300ns making 1 call to Search::Elasticsearch::Role::CxnPool::cxns
401001370µs return unless @$cxns;
4110011.27ms1600ns my $current = $self->current_cxn_num;
4210011.90ms1900ns $self->_set_current_cxn_num( ( $current + 1 ) % @$cxns );
4310017.88ms return $current;
44}
45
46#===================================
47
# spent 636ms (41.4+595) within Search::Elasticsearch::Role::CxnPool::set_cxns which was called 1001 times, avg 636µs/call: # 1001 times (41.4ms+595ms) by Search::Elasticsearch::Role::CxnPool::Static::BUILD at line 13 of Search/Elasticsearch/Role/CxnPool/Static.pm, avg 636µs/call
sub set_cxns {
48#===================================
491001413µs my $self = shift;
5010011.26ms1200ns my $factory = $self->cxn_factory;
5120024.12ms1001450ms my @cxns = map { $factory->new_cxn($_) } @_;
# spent 450ms making 1001 calls to Search::Elasticsearch::Cxn::Factory::new_cxn, avg 450µs/call
5210015.69ms10021.35ms @cxns = shuffle @cxns if $self->randomize_cxns;
# spent 1.35ms making 1001 calls to List::Util::shuffle, avg 1µs/call # spent 2µs making 1 call to Search::Elasticsearch::Role::CxnPool::randomize_cxns
5310012.00ms13µs $self->_set_cxns( \@cxns );
5410011.51ms12µs $self->_set_current_cxn_num(0);
55
56 $self->logger->infof( "Current cxns: %s",
5720027.54ms200313.6ms [ map { $_->stringify } @cxns ] );
# spent 9.22ms making 1001 calls to Search::Elasticsearch::Role::Cxn::stringify, avg 9µs/call # spent 4.34ms making 1001 calls to Search::Elasticsearch::Role::Logger::infof, avg 4µs/call # spent 1µs making 1 call to Search::Elasticsearch::Role::CxnPool::logger
58
59100113.8ms return;
60}
61
62#===================================
63
# spent 16.4ms (8.35+8.04) within Search::Elasticsearch::Role::CxnPool::request_ok which was called 1001 times, avg 16µs/call: # 1001 times (8.35ms+8.04ms) by Search::Elasticsearch::Transport::try {...} at line 30 of Search/Elasticsearch/Transport.pm, avg 16µs/call
sub request_ok {
64#===================================
651001452µs my ( $self, $cxn ) = @_;
6610012.43ms10015.00ms $cxn->mark_live;
# spent 5.00ms making 1001 calls to Search::Elasticsearch::Role::Cxn::mark_live, avg 5µs/call
6710014.26ms10013.05ms $self->reset_retries;
# spent 3.05ms making 1001 calls to Search::Elasticsearch::Role::CxnPool::reset_retries, avg 3µs/call
68}
69
70#===================================
71sub request_failed {
72#===================================
73 my ( $self, $cxn, $error ) = @_;
74
75 if ( $error->is( 'Cxn', 'Timeout' ) ) {
76 $cxn->mark_dead if $self->should_mark_dead($error);
77 $self->schedule_check;
78
79 if ( $self->should_retry($error) ) {
80 my $retries = $self->retries( $self->retries + 1 );
81 return 1 if $retries < $self->_max_retries;
82 }
83 }
84 else {
85 $cxn->mark_live if $cxn;
86 }
87 $self->reset_retries;
88 return 0;
89}
90
91#===================================
92sub should_retry {
93#===================================
94 my ( $self, $error ) = @_;
95 return $error->is('Cxn');
96}
97
98#===================================
99sub should_mark_dead {
100#===================================
101 my ( $self, $error ) = @_;
102 return $error->is('Cxn');
103}
104
105#===================================
106sub cxns_str {
107#===================================
108 my $self = shift;
109 join ", ", map { $_->stringify } @{ $self->cxns };
110}
111
112#===================================
113sub cxns_seeds_str {
114#===================================
115 my $self = shift;
116 join ", ", ( map { $_->stringify } @{ $self->cxns } ),
117 @{ $self->seed_nodes };
118}
119
120#===================================
12110013.78ms11µs
# spent 3.05ms (3.05+1µs) within Search::Elasticsearch::Role::CxnPool::reset_retries which was called 1001 times, avg 3µs/call: # 1001 times (3.05ms+1µs) by Search::Elasticsearch::Role::CxnPool::request_ok at line 67, avg 3µs/call
sub reset_retries { shift->retries(0) }
# spent 1µs making 1 call to Search::Elasticsearch::Role::CxnPool::retries
122sub _max_retries {2}
123#===================================
124
12517µs1;
126
127=pod
128
129=encoding UTF-8
130
131=head1 NAME
132
133Search::Elasticsearch::Role::CxnPool - Provides common functionality to the CxnPool implementations
134
135=head1 VERSION
136
137version 5.01
138
139=head1 DESCRIPTION
140
141See the CxnPool implementations:
142
143=over
144
145=item *
146
147L<Search::Elasticsearch::CxnPool::Static>
148
149=item *
150
151L<Search::Elasticsearch::CxnPool::Sniff>
152
153=item *
154
155L<Search::Elasticsearch::CxnPool::Static::NoPing>
156
157=back
158
159=head1 CONFIGURATION
160
161These configuration options should not be set by the user but are
162documented here for completeness.
163
164=head2 C<randomize_cxns>
165
166By default, the order of cxns passed to L</set_cxns()> is randomized
167before they are stored. Set C<randomize_cxns> to a false value to
168disable.
169
170=head1 METHODS
171
172=head2 C<cxn_factory()>
173
174 $factory = $cxn_pool->cxn_factory
175
176Returns the L<Search::Elasticsearch::Cxn::Factory> object for creating a new
177C<$cxn> instance.
178
179=head2 C<logger()>
180
181 $logger = $cxn_pool->logger
182
183Returns the L<Search::Elasticsearch::Role::Logger>-based object, which
184defaults to L<Search::Elasticsearch::Logger::LogAny>.
185
186=head2 C<serializer()>
187
188 $serializer = $cxn_pool->serializer
189
190Returns the L<Search::Elasticsearch::Role::Serializer>-based object,
191which defaults to L<Search::Elasticsearch::Serializer::JSON>.
192
193=head2 C<current_cxn_num()>
194
195 $num = $cxn_pool->current_cxn_num
196
197Returns the current cxn number, which is an offset into
198the array of cxns set by L</set_cxns()>.
199
200=head2 C<cxns()>
201
202 \@cxns = $cxn_pool->cxns;
203
204Returns the current list of L<Search::Elasticsearch::Role::Cxn>-based
205cxn objects as set by L</set_cxns()>.
206
207=head2 C<seed_nodes()>
208
209 \@seed_nodes = $cxn_pool->seed_nodes
210
211Returns the list of C<nodes> originally specified when calling
212L<Search::Elasticsearch/new()>.
213
214=head2 C<next_cxn_num()>
215
216 $num = $cxn_pool->next_cxn_num;
217
218Returns the number of the next connection, in round-robin fashion. Updates
219the L</current_cxn_num()>.
220
221=head2 C<set_cxns()>
222
223 $cxn_pool->set_cxns(@nodes);
224
225Takes a list of nodes, converts them into L<Search::Elasticsearch::Role::Cxn>-based
226objects and makes them accessible via L</cxns()>.
227
228=head2 C<request_ok()>
229
230 $cxn_pool->request_ok($cxn);
231
232Called when a request by the specified C<$cxn> object has completed successfully.
233Marks the C<$cxn> as live.
234
235=head2 C<request_failed()>
236
237 $should_retry = $cxn_pool->request_failed($cxn,$error);
238
239Called when a request by the specified C<$cxn> object has failed. Returns
240C<1> if the request should be retried or C<0> if it shouldn't.
241
242=head2 C<should_retry()>
243
244 $bool = $cxn_pool->should_retry($error);
245
246Examines the error to decide whether the request should be retried or not.
247By default, only L<Search::Elasticsearch::Error/Search::Elasticsearch::Error::Cxn> errors
248are retried.
249
250=head2 C<should_mark_dead()>
251
252 $bool = $cxn_pool->should_mark_dead($error);
253
254Examines the error to decide whether the C<$cxn> should be marked as dead or not.
255By default, only L<Search::Elasticsearch::Error/Search::Elasticsearch::Error::Cxn> errors
256cause a C<$cxn> to be marked as dead.
257
258=head2 C<cxns_str()>
259
260 $str = $cxn_pool->cxns_str
261
262Returns all L</cxns()> as a string for logging purposes.
263
264=head2 C<cxns_seeds_str()>
265
266 $str = $cxn_pool->cxns_seeeds_str
267
268Returns all L</cxns()> and L</seed_nodes()> as a string for logging purposes.
269
270=head2 C<retries()>
271
272 $retries = $cxn_pool->retries
273
274The number of times the current request has been retried.
275
276=head2 C<reset_retries()>
277
278 $cxn_pool->reset_retries;
279
280Called at the start of a new request to reset the retries count.
281
282=head1 AUTHOR
283
284Clinton Gormley <drtech@cpan.org>
285
286=head1 COPYRIGHT AND LICENSE
287
288This software is Copyright (c) 2016 by Elasticsearch BV.
289
290This is free software, licensed under:
291
292 The Apache License, Version 2.0, January 2004
293
294=cut
295
296110µs1230µs__END__
 
# spent 3µs within Search::Elasticsearch::Role::CxnPool::_set_current_cxn_num which was called 2 times, avg 1µs/call: # once (2µs+0s) by Search::Elasticsearch::Role::CxnPool::set_cxns at line 54 # once (900ns+0s) by Search::Elasticsearch::Role::CxnPool::next_cxn_num at line 42
sub Search::Elasticsearch::Role::CxnPool::_set_current_cxn_num; # xsub
# spent 3µs within Search::Elasticsearch::Role::CxnPool::_set_cxns which was called: # once (3µs+0s) by Search::Elasticsearch::Role::CxnPool::set_cxns at line 53
sub Search::Elasticsearch::Role::CxnPool::_set_cxns; # xsub
# spent 600ns within Search::Elasticsearch::Role::CxnPool::current_cxn_num which was called: # once (600ns+0s) by Search::Elasticsearch::Role::CxnPool::next_cxn_num at line 41
sub Search::Elasticsearch::Role::CxnPool::current_cxn_num; # xsub
# spent 1µs within Search::Elasticsearch::Role::CxnPool::cxn_factory which was called 2 times, avg 500ns/call: # once (800ns+0s) by Search::Elasticsearch::Role::Transport::BUILD at line 22 of Search/Elasticsearch/Role/Transport.pm # once (200ns+0s) by Search::Elasticsearch::Role::CxnPool::set_cxns at line 50
sub Search::Elasticsearch::Role::CxnPool::cxn_factory; # xsub
# spent 2µs within Search::Elasticsearch::Role::CxnPool::cxns which was called 3 times, avg 700ns/call: # once (1µs+0s) by Search::Elasticsearch::CxnPool::Static::next_cxn at line 14 of Search/Elasticsearch/CxnPool/Static.pm # once (700ns+0s) by Search::Elasticsearch::Role::CxnPool::Static::schedule_check at line 22 of Search/Elasticsearch/Role/CxnPool/Static.pm # once (300ns+0s) by Search::Elasticsearch::Role::CxnPool::next_cxn_num at line 39
sub Search::Elasticsearch::Role::CxnPool::cxns; # xsub
# spent 2µs within Search::Elasticsearch::Role::CxnPool::logger which was called 3 times, avg 600ns/call: # once (1µs+0s) by Search::Elasticsearch::Role::CxnPool::set_cxns at line 57 # once (400ns+0s) by Search::Elasticsearch::Role::CxnPool::Static::schedule_check at line 21 of Search/Elasticsearch/Role/CxnPool/Static.pm # once (300ns+0s) by Search::Elasticsearch::Role::CxnPool::Static::schedule_check at line 24 of Search/Elasticsearch/Role/CxnPool/Static.pm
sub Search::Elasticsearch::Role::CxnPool::logger; # xsub
# spent 2µs within Search::Elasticsearch::Role::CxnPool::randomize_cxns which was called: # once (2µs+0s) by Search::Elasticsearch::Role::CxnPool::set_cxns at line 52
sub Search::Elasticsearch::Role::CxnPool::randomize_cxns; # xsub
# spent 1µs within Search::Elasticsearch::Role::CxnPool::retries which was called: # once (1µs+0s) by Search::Elasticsearch::Role::CxnPool::reset_retries at line 121
sub Search::Elasticsearch::Role::CxnPool::retries; # xsub
# spent 400ns within Search::Elasticsearch::Role::CxnPool::seed_nodes which was called: # once (400ns+0s) by Search::Elasticsearch::Role::CxnPool::Static::BUILD at line 13 of Search/Elasticsearch/Role/CxnPool/Static.pm
sub Search::Elasticsearch::Role::CxnPool::seed_nodes; # xsub