← 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/CxnPool/Static.pm
StatementsExecuted 9018 statements in 14.5ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
10011126.9ms1.59sSearch::Elasticsearch::CxnPool::Static::::next_cxnSearch::Elasticsearch::CxnPool::Static::next_cxn
11114µs5.29msSearch::Elasticsearch::CxnPool::Static::::BEGIN@3Search::Elasticsearch::CxnPool::Static::BEGIN@3
11112µs234µsSearch::Elasticsearch::CxnPool::Static::::BEGIN@6Search::Elasticsearch::CxnPool::Static::BEGIN@6
11111µs208µsSearch::Elasticsearch::CxnPool::Static::::BEGIN@7Search::Elasticsearch::CxnPool::Static::BEGIN@7
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::CxnPool::Static;
21300ns$Search::Elasticsearch::CxnPool::Static::VERSION = '5.01';
3251µs210.6ms
# spent 5.29ms (14µs+5.28) within Search::Elasticsearch::CxnPool::Static::BEGIN@3 which was called: # once (14µs+5.28ms) by Module::Runtime::require_module at line 3
use Moo;
# spent 5.29ms making 1 call to Search::Elasticsearch::CxnPool::Static::BEGIN@3 # spent 5.28ms making 1 call to Moo::import
411µs17.92mswith 'Search::Elasticsearch::Role::CxnPool::Static',
# spent 7.92ms making 1 call to Moo::with
5 'Search::Elasticsearch::Role::Is_Sync';
6237µs2456µs
# spent 234µs (12+222) within Search::Elasticsearch::CxnPool::Static::BEGIN@6 which was called: # once (12µs+222µs) by Module::Runtime::require_module at line 6
use Search::Elasticsearch::Util qw(throw);
# spent 234µs making 1 call to Search::Elasticsearch::CxnPool::Static::BEGIN@6 # spent 222µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
72207µs2406µs
# spent 208µs (11+198) within Search::Elasticsearch::CxnPool::Static::BEGIN@7 which was called: # once (11µs+198µs) by Module::Runtime::require_module at line 7
use namespace::clean;
# spent 208µs making 1 call to Search::Elasticsearch::CxnPool::Static::BEGIN@7 # spent 198µs making 1 call to namespace::clean::import
8
9#===================================
10
# spent 1.59s (26.9ms+1.56) within Search::Elasticsearch::CxnPool::Static::next_cxn which was called 1001 times, avg 1.59ms/call: # 1001 times (26.9ms+1.56s) by Search::Elasticsearch::Transport::try {...} at line 25 of Search/Elasticsearch/Transport.pm, avg 1.59ms/call
sub next_cxn {
11#===================================
121001473µs my ($self) = @_;
13
1410011.09ms11µs my $cxns = $self->cxns;
# spent 1µs making 1 call to Search::Elasticsearch::Role::CxnPool::cxns
151001525µs my $total = @$cxns;
16
171001667µs my $now = time();
181001291µs my @skipped;
19
201001898µs while ( $total-- ) {
2110012.64ms10016.26ms my $cxn = $cxns->[ $self->next_cxn_num ];
# spent 6.26ms making 1001 calls to Search::Elasticsearch::Role::CxnPool::next_cxn_num, avg 6µs/call
2210012.36ms10012.65ms return $cxn if $cxn->is_live;
# spent 2.65ms making 1001 calls to Search::Elasticsearch::Role::Cxn::is_live, avg 3µs/call
23
2410015.28ms10021.55s if ( $cxn->next_ping < $now ) {
# spent 1.55s making 1001 calls to Search::Elasticsearch::Role::Cxn::pings_ok, avg 1.55ms/call # spent 300ns making 1 call to Search::Elasticsearch::Role::Cxn::next_ping
25 return $cxn if $cxn->pings_ok;
26 }
27 else {
28 push @skipped, $cxn;
29 }
30 }
31
32 for my $cxn (@skipped) {
33 return $cxn if $cxn->pings_ok;
34 }
35
36 $_->force_ping for @$cxns;
37
38 throw( "NoNodes", "No nodes are available: [" . $self->cxns_str . ']' );
39}
40
4114µs1;
42
43=pod
44
45=encoding UTF-8
46
47=head1 NAME
48
49Search::Elasticsearch::CxnPool::Static - A CxnPool for connecting to a remote cluster with a static list of nodes.
50
51=head1 VERSION
52
53version 5.01
54
55=head1 SYNOPSIS
56
57 $e = Search::Elasticsearch->new(
58 cxn_pool => 'Static' # default
59 nodes => [
60 'search1:9200',
61 'search2:9200'
62 ],
63 );
64
65=head1 DESCRIPTION
66
67The L<Static|Search::Elasticsearch::CxnPool::Static> connection pool, which is the
68default, should be used when you don't have direct access to the Elasticsearch
69cluster, eg when you are accessing the cluster through a proxy. It
70round-robins through the nodes that you specified, and pings each node
71before it is used for the first time, to ensure that it is responding.
72
73If any node fails, then all nodes are pinged before the next request to
74ensure that they are still alive and responding. Failed nodes will be
75pinged regularly to check if they have recovered.
76
77This class does L<Search::Elasticsearch::Role::CxnPool::Static> and
78L<Search::Elasticsearch::Role::Is_Sync>.
79
80=head1 CONFIGURATION
81
82=head2 C<nodes>
83
84The list of nodes to use to serve requests. Can accept a single node,
85multiple nodes, and defaults to C<localhost:9200> if no C<nodes> are
86specified. See L<Search::Elasticsearch::Role::Cxn/node> for details of the node
87specification.
88
89=head2 See also
90
91=over
92
93=item *
94
95L<Search::Elasticsearch::Role::Cxn/request_timeout>
96
97=item *
98
99L<Search::Elasticsearch::Role::Cxn/ping_timeout>
100
101=item *
102
103L<Search::Elasticsearch::Role::Cxn/dead_timeout>
104
105=item *
106
107L<Search::Elasticsearch::Role::Cxn/max_dead_timeout>
108
109=back
110
111=head2 Inherited configuration
112
113From L<Search::Elasticsearch::Role::CxnPool>
114
115=over
116
117=item * L<randomize_cxns|Search::Elasticsearch::Role::CxnPool/"randomize_cxns">
118
119=back
120
121=head1 METHODS
122
123=head2 C<next_cxn()>
124
125 $cxn = $cxn_pool->next_cxn
126
127Returns the next available live node (in round robin fashion), or
128throws a C<NoNodes> error if no nodes respond to ping requests.
129
130=head2 Inherited methods
131
132From L<Search::Elasticsearch::Role::CxnPool::Static>
133
134=over
135
136=item * L<schedule_check()|Search::Elasticsearch::Role::CxnPool::Static/"schedule_check()">
137
138=back
139
140From L<Search::Elasticsearch::Role::CxnPool>
141
142=over
143
144=item * L<cxn_factory()|Search::Elasticsearch::Role::CxnPool/"cxn_factory()">
145
146=item * L<logger()|Search::Elasticsearch::Role::CxnPool/"logger()">
147
148=item * L<serializer()|Search::Elasticsearch::Role::CxnPool/"serializer()">
149
150=item * L<current_cxn_num()|Search::Elasticsearch::Role::CxnPool/"current_cxn_num()">
151
152=item * L<cxns()|Search::Elasticsearch::Role::CxnPool/"cxns()">
153
154=item * L<seed_nodes()|Search::Elasticsearch::Role::CxnPool/"seed_nodes()">
155
156=item * L<next_cxn_num()|Search::Elasticsearch::Role::CxnPool/"next_cxn_num()">
157
158=item * L<set_cxns()|Search::Elasticsearch::Role::CxnPool/"set_cxns()">
159
160=item * L<request_ok()|Search::Elasticsearch::Role::CxnPool/"request_ok()">
161
162=item * L<request_failed()|Search::Elasticsearch::Role::CxnPool/"request_failed()">
163
164=item * L<should_retry()|Search::Elasticsearch::Role::CxnPool/"should_retry()">
165
166=item * L<should_mark_dead()|Search::Elasticsearch::Role::CxnPool/"should_mark_dead()">
167
168=item * L<cxns_str()|Search::Elasticsearch::Role::CxnPool/"cxns_str()">
169
170=item * L<cxns_seeds_str()|Search::Elasticsearch::Role::CxnPool/"cxns_seeds_str()">
171
172=item * L<retries()|Search::Elasticsearch::Role::CxnPool/"retries()">
173
174=item * L<reset_retries()|Search::Elasticsearch::Role::CxnPool/"reset_retries()">
175
176=back
177
178=head1 AUTHOR
179
180Clinton Gormley <drtech@cpan.org>
181
182=head1 COPYRIGHT AND LICENSE
183
184This software is Copyright (c) 2016 by Elasticsearch BV.
185
186This is free software, licensed under:
187
188 The Apache License, Version 2.0, January 2004
189
190=cut
191
19218µs1226µs__END__