← 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/Cxn.pm
StatementsExecuted 97144 statements in 286ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
10011182.2ms376msSearch::Elasticsearch::Role::Cxn::::BUILDARGSSearch::Elasticsearch::Role::Cxn::BUILDARGS
40044347.2ms53.4msSearch::Elasticsearch::Role::Cxn::::stringifySearch::Elasticsearch::Role::Cxn::stringify
20021146.7ms142msSearch::Elasticsearch::Role::Cxn::::process_responseSearch::Elasticsearch::Role::Cxn::process_response
20021136.1ms198msSearch::Elasticsearch::Role::Cxn::::build_uriSearch::Elasticsearch::Role::Cxn::build_uri
10011131.6ms1.44sSearch::Elasticsearch::Role::Cxn::::try {...} Search::Elasticsearch::Role::Cxn::try {...}
10011116.8ms1.55sSearch::Elasticsearch::Role::Cxn::::pings_okSearch::Elasticsearch::Role::Cxn::pings_ok
20021112.5ms16.0msSearch::Elasticsearch::Role::Cxn::::__ANON__[:243]Search::Elasticsearch::Role::Cxn::__ANON__[:243]
2002228.57ms8.57msSearch::Elasticsearch::Role::Cxn::::mark_liveSearch::Elasticsearch::Role::Cxn::mark_live
2002117.71ms7.71msSearch::Elasticsearch::Role::Cxn::::__ANON__[:134]Search::Elasticsearch::Role::Cxn::__ANON__[:134]
2002115.34ms5.34msSearch::Elasticsearch::Role::Cxn::::_decompress_bodySearch::Elasticsearch::Role::Cxn::_decompress_body
1000113.49ms3.49msSearch::Elasticsearch::Role::Cxn::::_compress_bodySearch::Elasticsearch::Role::Cxn::_compress_body
1001113.11ms3.11msSearch::Elasticsearch::Role::Cxn::::force_pingSearch::Elasticsearch::Role::Cxn::force_ping
2002213.07ms3.07msSearch::Elasticsearch::Role::Cxn::::CORE:substSearch::Elasticsearch::Role::Cxn::CORE:subst (opcode)
1001112.65ms2.65msSearch::Elasticsearch::Role::Cxn::::is_liveSearch::Elasticsearch::Role::Cxn::is_live
1001112.36ms2.36msSearch::Elasticsearch::Role::Cxn::::is_deadSearch::Elasticsearch::Role::Cxn::is_dead
1001112.33ms2.33msSearch::Elasticsearch::Role::Cxn::::CORE:matchSearch::Elasticsearch::Role::Cxn::CORE:match (opcode)
1001112.04ms2.04msSearch::Elasticsearch::Role::Cxn::::__ANON__[:31]Search::Elasticsearch::Role::Cxn::__ANON__[:31]
1001111.68ms1.68msSearch::Elasticsearch::Role::Cxn::::__ANON__[:30]Search::Elasticsearch::Role::Cxn::__ANON__[:30]
111834µs3.01msSearch::Elasticsearch::Role::Cxn::::BEGIN@10Search::Elasticsearch::Role::Cxn::BEGIN@10
111742µs1.06msSearch::Elasticsearch::Role::Cxn::::BEGIN@11Search::Elasticsearch::Role::Cxn::BEGIN@11
111540µs6.37msSearch::Elasticsearch::Role::Cxn::::BEGIN@9Search::Elasticsearch::Role::Cxn::BEGIN@9
111538µs14.3msSearch::Elasticsearch::Role::Cxn::::BEGIN@8Search::Elasticsearch::Role::Cxn::BEGIN@8
11111µs34µsSearch::Elasticsearch::Role::Cxn::::BEGIN@5Search::Elasticsearch::Role::Cxn::BEGIN@5
1119µs152µsSearch::Elasticsearch::Role::Cxn::::BEGIN@12Search::Elasticsearch::Role::Cxn::BEGIN@12
1118µs664µsSearch::Elasticsearch::Role::Cxn::::BEGIN@3Search::Elasticsearch::Role::Cxn::BEGIN@3
1118µs186µsSearch::Elasticsearch::Role::Cxn::::BEGIN@13Search::Elasticsearch::Role::Cxn::BEGIN@13
1117µs213µsSearch::Elasticsearch::Role::Cxn::::BEGIN@4Search::Elasticsearch::Role::Cxn::BEGIN@4
1115µs26µsSearch::Elasticsearch::Role::Cxn::::BEGIN@6Search::Elasticsearch::Role::Cxn::BEGIN@6
5523µs3µsSearch::Elasticsearch::Role::Cxn::::next_pingSearch::Elasticsearch::Role::Cxn::next_ping (xsub)
1112µs2µsSearch::Elasticsearch::Role::Cxn::::BEGIN@7Search::Elasticsearch::Role::Cxn::BEGIN@7
2212µs2µsSearch::Elasticsearch::Role::Cxn::::uriSearch::Elasticsearch::Role::Cxn::uri (xsub)
2212µs2µsSearch::Elasticsearch::Role::Cxn::::ping_failuresSearch::Elasticsearch::Role::Cxn::ping_failures (xsub)
1112µs2µsSearch::Elasticsearch::Role::Cxn::::ping_timeoutSearch::Elasticsearch::Role::Cxn::ping_timeout (xsub)
1112µs2µsSearch::Elasticsearch::Role::Cxn::::_pidSearch::Elasticsearch::Role::Cxn::_pid (xsub)
1112µs2µsSearch::Elasticsearch::Role::Cxn::::serializerSearch::Elasticsearch::Role::Cxn::serializer (xsub)
2212µs2µsSearch::Elasticsearch::Role::Cxn::::loggerSearch::Elasticsearch::Role::Cxn::logger (xsub)
111800ns800nsSearch::Elasticsearch::Role::Cxn::::default_headersSearch::Elasticsearch::Role::Cxn::default_headers (xsub)
111800ns800nsSearch::Elasticsearch::Role::Cxn::::default_qs_paramsSearch::Elasticsearch::Role::Cxn::default_qs_params (xsub)
111800ns800nsSearch::Elasticsearch::Role::Cxn::::gzipSearch::Elasticsearch::Role::Cxn::gzip (xsub)
111800ns800nsSearch::Elasticsearch::Role::Cxn::::is_httpsSearch::Elasticsearch::Role::Cxn::is_https (xsub)
111800ns800nsSearch::Elasticsearch::Role::Cxn::::request_timeoutSearch::Elasticsearch::Role::Cxn::request_timeout (xsub)
111600ns600nsSearch::Elasticsearch::Role::Cxn::::deflateSearch::Elasticsearch::Role::Cxn::deflate (xsub)
111600ns600nsSearch::Elasticsearch::Role::Cxn::::handle_argsSearch::Elasticsearch::Role::Cxn::handle_args (xsub)
111600ns600nsSearch::Elasticsearch::Role::Cxn::::max_content_lengthSearch::Elasticsearch::Role::Cxn::max_content_length (xsub)
0000s0sSearch::Elasticsearch::Role::Cxn::::__ANON__[:188]Search::Elasticsearch::Role::Cxn::__ANON__[:188]
0000s0sSearch::Elasticsearch::Role::Cxn::::__ANON__[:193]Search::Elasticsearch::Role::Cxn::__ANON__[:193]
0000s0sSearch::Elasticsearch::Role::Cxn::::__ANON__[:209]Search::Elasticsearch::Role::Cxn::__ANON__[:209]
0000s0sSearch::Elasticsearch::Role::Cxn::::__ANON__[:213]Search::Elasticsearch::Role::Cxn::__ANON__[:213]
0000s0sSearch::Elasticsearch::Role::Cxn::::_munge_elasticsearch_exceptionSearch::Elasticsearch::Role::Cxn::_munge_elasticsearch_exception
0000s0sSearch::Elasticsearch::Role::Cxn::::catch {...} Search::Elasticsearch::Role::Cxn::catch {...}
0000s0sSearch::Elasticsearch::Role::Cxn::::mark_deadSearch::Elasticsearch::Role::Cxn::mark_dead
0000s0sSearch::Elasticsearch::Role::Cxn::::sniffSearch::Elasticsearch::Role::Cxn::sniff
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::Cxn;
21400ns$Search::Elasticsearch::Role::Cxn::VERSION = '5.01';
3225µs21.32ms
# spent 664µs (8+656) within Search::Elasticsearch::Role::Cxn::BEGIN@3 which was called: # once (8µs+656µs) by Module::Runtime::require_module at line 3
use Moo::Role;
# spent 664µs making 1 call to Search::Elasticsearch::Role::Cxn::BEGIN@3 # spent 656µs making 1 call to Moo::Role::import
4224µs2419µs
# spent 213µs (7+206) within Search::Elasticsearch::Role::Cxn::BEGIN@4 which was called: # once (7µs+206µs) by Module::Runtime::require_module at line 4
use Search::Elasticsearch::Util qw(parse_params throw to_list);
# spent 213µs making 1 call to Search::Elasticsearch::Role::Cxn::BEGIN@4 # spent 206µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
5217µs241µs
# spent 34µs (11+23) within Search::Elasticsearch::Role::Cxn::BEGIN@5 which was called: # once (11µs+23µs) by Module::Runtime::require_module at line 5
use List::Util qw(min);
# spent 34µs making 1 call to Search::Elasticsearch::Role::Cxn::BEGIN@5 # spent 8µs making 1 call to List::Util::import
6214µs248µs
# spent 26µs (5+21) within Search::Elasticsearch::Role::Cxn::BEGIN@6 which was called: # once (5µs+21µs) by Module::Runtime::require_module at line 6
use Try::Tiny;
# spent 26µs making 1 call to Search::Elasticsearch::Role::Cxn::BEGIN@6 # spent 21µs making 1 call to Exporter::import
7212µs12µs
# spent 2µs within Search::Elasticsearch::Role::Cxn::BEGIN@7 which was called: # once (2µs+0s) by Module::Runtime::require_module at line 7
use URI();
# spent 2µs making 1 call to Search::Elasticsearch::Role::Cxn::BEGIN@7
8276µs114.3ms
# spent 14.3ms (538µs+13.8) within Search::Elasticsearch::Role::Cxn::BEGIN@8 which was called: # once (538µs+13.8ms) by Module::Runtime::require_module at line 8
use IO::Compress::Deflate();
# spent 14.3ms making 1 call to Search::Elasticsearch::Role::Cxn::BEGIN@8
9270µs16.37ms
# spent 6.37ms (540µs+5.83) within Search::Elasticsearch::Role::Cxn::BEGIN@9 which was called: # once (540µs+5.83ms) by Module::Runtime::require_module at line 9
use IO::Uncompress::Inflate();
# spent 6.37ms making 1 call to Search::Elasticsearch::Role::Cxn::BEGIN@9
10269µs13.01ms
# spent 3.01ms (834µs+2.17) within Search::Elasticsearch::Role::Cxn::BEGIN@10 which was called: # once (834µs+2.17ms) by Module::Runtime::require_module at line 10
use IO::Compress::Gzip();
# spent 3.01ms making 1 call to Search::Elasticsearch::Role::Cxn::BEGIN@10
11270µs21.11ms
# spent 1.06ms (742µs+317µs) within Search::Elasticsearch::Role::Cxn::BEGIN@11 which was called: # once (742µs+317µs) by Module::Runtime::require_module at line 11
use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
# spent 1.06ms making 1 call to Search::Elasticsearch::Role::Cxn::BEGIN@11 # spent 52µs making 1 call to Exporter::import
12222µs2296µs
# spent 152µs (9+143) within Search::Elasticsearch::Role::Cxn::BEGIN@12 which was called: # once (9µs+143µs) by Module::Runtime::require_module at line 12
use Search::Elasticsearch::Util qw(to_list);
# spent 152µs making 1 call to Search::Elasticsearch::Role::Cxn::BEGIN@12 # spent 143µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
1321.12ms2364µs
# spent 186µs (8+178) within Search::Elasticsearch::Role::Cxn::BEGIN@13 which was called: # once (8µs+178µs) by Module::Runtime::require_module at line 13
use namespace::clean;
# spent 186µs making 1 call to Search::Elasticsearch::Role::Cxn::BEGIN@13 # spent 178µs making 1 call to namespace::clean::import
14
1512µs116µsrequires qw(perform_request error_from_text handle);
# spent 16µs making 1 call to Moo::Role::requires
16
171900ns1122µshas 'host' => ( is => 'ro', required => 1 );
# spent 122µs making 1 call to Moo::Role::has
181600ns152µshas 'port' => ( is => 'ro', required => 1 );
# spent 52µs making 1 call to Moo::Role::has
191500ns147µshas 'uri' => ( is => 'ro', required => 1 );
# spent 47µs making 1 call to Moo::Role::has
201400ns146µshas 'request_timeout' => ( is => 'ro', default => 30 );
# spent 46µs making 1 call to Moo::Role::has
211500ns147µshas 'ping_timeout' => ( is => 'ro', default => 2 );
# spent 47µs making 1 call to Moo::Role::has
221600ns146µshas 'sniff_timeout' => ( is => 'ro', default => 1 );
# spent 46µs making 1 call to Moo::Role::has
231500ns144µshas 'sniff_request_timeout' => ( is => 'ro', default => 2 );
# spent 44µs making 1 call to Moo::Role::has
241500ns195µshas 'next_ping' => ( is => 'rw', default => 0 );
# spent 95µs making 1 call to Moo::Role::has
251500ns148µshas 'ping_failures' => ( is => 'rw', default => 0 );
# spent 48µs making 1 call to Moo::Role::has
261600ns157µshas 'dead_timeout' => ( is => 'ro', default => 60 );
# spent 57µs making 1 call to Moo::Role::has
271500ns145µshas 'max_dead_timeout' => ( is => 'ro', default => 3600 );
# spent 45µs making 1 call to Moo::Role::has
281500ns144µshas 'serializer' => ( is => 'ro', required => 1 );
# spent 44µs making 1 call to Moo::Role::has
291500ns150µshas 'logger' => ( is => 'ro', required => 1 );
# spent 50µs making 1 call to Moo::Role::has
3010021.91ms159µs
# spent 1.68ms within Search::Elasticsearch::Role::Cxn::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Search/Elasticsearch/Role/Cxn.pm:30] which was called 1001 times, avg 2µs/call: # 1001 times (1.68ms+0s) by Search::Elasticsearch::Cxn::HTTPTiny::new at line 70 of (eval 283)[Sub/Quote.pm:3], avg 2µs/call
has 'handle_args' => ( is => 'ro', default => sub { {} } );
# spent 59µs making 1 call to Moo::Role::has
3110022.44ms152µs
# spent 2.04ms within Search::Elasticsearch::Role::Cxn::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Search/Elasticsearch/Role/Cxn.pm:31] which was called 1001 times, avg 2µs/call: # 1001 times (2.04ms+0s) by Search::Elasticsearch::Cxn::HTTPTiny::new at line 56 of (eval 283)[Sub/Quote.pm:3], avg 2µs/call
has 'default_qs_params' => ( is => 'ro', default => sub { {} } );
# spent 52µs making 1 call to Moo::Role::has
321500ns147µshas 'scheme' => ( is => 'ro' );
# spent 47µs making 1 call to Moo::Role::has
331500ns145µshas 'is_https' => ( is => 'ro' );
# spent 45µs making 1 call to Moo::Role::has
341500ns144µshas 'userinfo' => ( is => 'ro' );
# spent 44µs making 1 call to Moo::Role::has
351400ns145µshas 'max_content_length' => ( is => 'ro' );
# spent 45µs making 1 call to Moo::Role::has
361500ns145µshas 'default_headers' => ( is => 'ro' );
# spent 45µs making 1 call to Moo::Role::has
371400ns144µshas 'deflate' => ( is => 'ro' );
# spent 44µs making 1 call to Moo::Role::has
381500ns144µshas 'gzip' => ( is => 'ro' );
# spent 44µs making 1 call to Moo::Role::has
391500ns184µshas 'ssl_options' => ( is => 'ro', predicate => 'has_ssl_options' );
# spent 84µs making 1 call to Moo::Role::has
401500ns1213µshas 'handle' => ( is => 'lazy', clearer => 1 );
# spent 213µs making 1 call to Moo::Role::has
411700ns169µshas '_pid' => ( is => 'rw', default => $$ );
# spent 69µs making 1 call to Moo::Role::has
42
4315µsmy %Code_To_Error = (
44 400 => 'Request',
45 401 => 'Unauthorized',
46 403 => 'Forbidden',
47 404 => 'Missing',
48 408 => 'RequestTimeout',
49 409 => 'Conflict',
50 502 => 'BadGateway',
51 503 => 'Unavailable',
52 504 => 'GatewayTimeout'
53);
54
55#===================================
56400428.5ms40056.22ms
# spent 53.4ms (47.2+6.22) within Search::Elasticsearch::Role::Cxn::stringify which was called 4004 times, avg 13µs/call: # 1001 times (17.9ms+1.60ms) by Search::Elasticsearch::Role::Cxn::pings_ok at line 177, avg 20µs/call # 1001 times (13.5ms+1.71ms) by Search::Elasticsearch::Role::Cxn::try {...} at line 185, avg 15µs/call # 1001 times (8.65ms+770µs) by Search::Elasticsearch::Role::CxnPool::Static::schedule_check at line 24 of Search/Elasticsearch/Role/CxnPool/Static.pm, avg 9µs/call # 1001 times (7.08ms+2.14ms) by Search::Elasticsearch::Role::CxnPool::set_cxns at line 57 of Search/Elasticsearch/Role/CxnPool.pm, avg 9µs/call
sub stringify { shift->uri . '' }
# spent 6.22ms making 4004 calls to URI::__ANON__[URI.pm:24], avg 2µs/call # spent 2µs making 1 call to Search::Elasticsearch::Role::Cxn::uri
57#===================================
58
59#===================================
60
# spent 376ms (82.2+294) within Search::Elasticsearch::Role::Cxn::BUILDARGS which was called 1001 times, avg 376µs/call: # 1001 times (82.2ms+294ms) by Search::Elasticsearch::Cxn::HTTPTiny::new at line 35 of (eval 283)[Sub/Quote.pm:3], avg 376µs/call
sub BUILDARGS {
61#===================================
6210012.22ms10014.29ms my ( $class, $params ) = parse_params(@_);
# spent 4.29ms making 1001 calls to Search::Elasticsearch::Util::parse_params, avg 4µs/call
63
64 my $node = $params->{node}
651001816µs || { host => 'localhost', port => '9200' };
66
6710011.05ms unless ( ref $node eq 'HASH' ) {
6810014.54ms10012.33ms unless ( $node =~ m{^http(s)?://} ) {
# spent 2.33ms making 1001 calls to Search::Elasticsearch::Role::Cxn::CORE:match, avg 2µs/call
69 $node = ( $params->{use_https} ? 'https://' : 'http://' ) . $node;
70 }
711001668µs if ( $params->{port} && $node !~ m{//[^/]+:\d+} ) {
72 $node =~ s{(//[^/]+)}{$1:$params->{port}};
73 }
7410015.69ms1001105ms my $uri = URI->new($node);
# spent 105ms making 1001 calls to URI::new, avg 105µs/call
75100113.4ms5005105ms $node = {
# spent 32.9ms making 1001 calls to URI::_server::port, avg 33µs/call # spent 26.3ms making 1001 calls to URI::_server::host, avg 26µs/call # spent 21.4ms making 1001 calls to URI::_server::userinfo, avg 21µs/call # spent 18.1ms making 1001 calls to URI::scheme, avg 18µs/call # spent 5.81ms making 1001 calls to URI::_generic::path, avg 6µs/call
76 scheme => $uri->scheme,
77 host => $uri->host,
78 port => $uri->port,
79 path => $uri->path,
80 userinfo => $uri->userinfo
81 };
82 }
83
841001909µs my $host = $node->{host} || 'localhost';
8510011.30ms my $userinfo = $node->{userinfo} || $params->{userinfo} || '';
86 my $scheme
871001552µs = $node->{scheme} || ( $params->{use_https} ? 'https' : 'http' );
88 my $port
89 = $node->{port}
90 || $params->{port}
911001565µs || ( $scheme eq 'http' ? 80 : 443 );
921001931µs my $path = $node->{path} || $params->{path_prefix} || '';
9310014.15ms10011.78ms $path =~ s{^/?}{/}g;
# spent 1.78ms making 1001 calls to Search::Elasticsearch::Role::Cxn::CORE:subst, avg 2µs/call
9410012.70ms10011.29ms $path =~ s{/+$}{};
# spent 1.29ms making 1001 calls to Search::Elasticsearch::Role::Cxn::CORE:subst, avg 1µs/call
95
9610012.47ms my %default_headers = %{ $params->{default_headers} || {} };
97
981001441µs if ($userinfo) {
99 require MIME::Base64;
100 my $auth = MIME::Base64::encode_base64($userinfo);
101 chomp $auth;
102 $default_headers{Authorization} = "Basic $auth";
103 }
104
1051001899µs if ( $params->{gzip} ) {
106 $default_headers{'Accept-Encoding'} = "gzip";
107 }
108
109 elsif ( $params->{deflate} ) {
110 $default_headers{'Accept-Encoding'} = "deflate";
111 }
112
1131001964µs $params->{scheme} = $scheme;
11410011.10ms $params->{is_https} = $scheme eq 'https';
11510011.15ms $params->{host} = $host;
1161001553µs $params->{port} = $port;
1171001566µs $params->{path} = $path;
1181001537µs $params->{userinfo} = $userinfo;
11910013.12ms100174.6ms $params->{uri} = URI->new("$scheme://$host:$port$path");
# spent 74.6ms making 1001 calls to URI::new, avg 75µs/call
1201001856µs $params->{default_headers} = \%default_headers;
121
122100110.6ms return $params;
123
124}
125
126#===================================
127
# spent 7.71ms (7.71+2µs) within Search::Elasticsearch::Role::Cxn::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Search/Elasticsearch/Role/Cxn.pm:134] which was called 2002 times, avg 4µs/call: # 2002 times (7.71ms+2µs) by Search::Elasticsearch::Cxn::HTTPTiny::handle at line 4 of (eval 268)[Class/Method/Modifiers.pm:152], avg 4µs/call
before 'handle' => sub {
128#===================================
1292002623µs my $self = shift;
130200220.1ms12µs if ( $$ != $self->_pid ) {
# spent 2µs making 1 call to Search::Elasticsearch::Role::Cxn::_pid
131 $self->clear_handle;
132 $self->_pid($$);
133 }
13412µs1872µs};
# spent 872µs making 1 call to Moo::Role::before
135
136#===================================
13710012.91ms1900ns
# spent 2.65ms (2.65+900ns) within Search::Elasticsearch::Role::Cxn::is_live which was called 1001 times, avg 3µs/call: # 1001 times (2.65ms+900ns) by Search::Elasticsearch::CxnPool::Static::next_cxn at line 22 of Search/Elasticsearch/CxnPool/Static.pm, avg 3µs/call
sub is_live { !shift->next_ping }
# spent 900ns making 1 call to Search::Elasticsearch::Role::Cxn::next_ping
13810013.32ms1800ns
# spent 2.36ms (2.36+800ns) within Search::Elasticsearch::Role::Cxn::is_dead which was called 1001 times, avg 2µs/call: # 1001 times (2.36ms+800ns) by Search::Elasticsearch::Role::CxnPool::Static::schedule_check at line 23 of Search/Elasticsearch/Role/CxnPool/Static.pm, avg 2µs/call
sub is_dead { !!shift->next_ping }
# spent 800ns making 1 call to Search::Elasticsearch::Role::Cxn::next_ping
139#===================================
140
141#===================================
142
# spent 8.57ms (8.57+1µs) within Search::Elasticsearch::Role::Cxn::mark_live which was called 2002 times, avg 4µs/call: # 1001 times (5.00ms+0s) by Search::Elasticsearch::Role::CxnPool::request_ok at line 66 of Search/Elasticsearch/Role/CxnPool.pm, avg 5µs/call # 1001 times (3.57ms+1µs) by Search::Elasticsearch::Role::Cxn::try {...} at line 186, avg 4µs/call
sub mark_live {
143#===================================
14420021.06ms my $self = shift;
14520022.89ms1900ns $self->ping_failures(0);
# spent 900ns making 1 call to Search::Elasticsearch::Role::Cxn::ping_failures
146200211.7ms1600ns $self->next_ping(0);
# spent 600ns making 1 call to Search::Elasticsearch::Role::Cxn::next_ping
147}
148
149#===================================
150sub mark_dead {
151#===================================
152 my $self = shift;
153 my $fails = $self->ping_failures;
154 $self->ping_failures( $fails + 1 );
155
156 my $timeout
157 = min( $self->dead_timeout * 2**$fails, $self->max_dead_timeout );
158 my $next = $self->next_ping( time() + $timeout );
159
160 $self->logger->infof( 'Marking [%s] as dead. Next ping at: %s',
161 $self->stringify, scalar localtime($next) );
162
163}
164
165#===================================
166
# spent 3.11ms (3.11+1µs) within Search::Elasticsearch::Role::Cxn::force_ping which was called 1001 times, avg 3µs/call: # 1001 times (3.11ms+1µs) by Search::Elasticsearch::Role::CxnPool::Static::schedule_check at line 26 of Search/Elasticsearch/Role/CxnPool/Static.pm, avg 3µs/call
sub force_ping {
167#===================================
1681001402µs my $self = shift;
16910011.28ms11µs $self->ping_failures(0);
17010012.10ms1400ns $self->next_ping(-1);
# spent 400ns making 1 call to Search::Elasticsearch::Role::Cxn::next_ping
171}
172
173#===================================
174
# spent 1.55s (16.8ms+1.54) within Search::Elasticsearch::Role::Cxn::pings_ok which was called 1001 times, avg 1.55ms/call: # 1001 times (16.8ms+1.54s) by Search::Elasticsearch::CxnPool::Static::next_cxn at line 24 of Search/Elasticsearch/CxnPool/Static.pm, avg 1.55ms/call
sub pings_ok {
175#===================================
1761001487µs my $self = shift;
17710014.17ms200321.9ms $self->logger->infof( 'Pinging [%s]', $self->stringify );
# spent 19.5ms making 1001 calls to Search::Elasticsearch::Role::Cxn::stringify, avg 20µs/call # spent 2.32ms making 1001 calls to Search::Elasticsearch::Role::Logger::infof, avg 2µs/call # spent 700ns making 1 call to Search::Elasticsearch::Role::Cxn::logger
178
# spent 1.44s (31.6ms+1.41) within Search::Elasticsearch::Role::Cxn::try {...} which was called 1001 times, avg 1.44ms/call: # 1001 times (31.6ms+1.41s) by Try::Tiny::try at line 87 of Try/Tiny.pm, avg 1.44ms/call
return try {
17910016.81ms10021.37s $self->perform_request(
# spent 1.37s making 1001 calls to Search::Elasticsearch::Cxn::HTTPTiny::perform_request, avg 1.37ms/call # spent 2µs making 1 call to Search::Elasticsearch::Role::Cxn::ping_timeout
180 { method => 'HEAD',
181 path => '/',
182 timeout => $self->ping_timeout,
183 }
184 );
18510014.95ms200317.6ms $self->logger->infof( 'Marking [%s] as live', $self->stringify );
# spent 15.2ms making 1001 calls to Search::Elasticsearch::Role::Cxn::stringify, avg 15µs/call # spent 2.36ms making 1001 calls to Search::Elasticsearch::Role::Logger::infof, avg 2µs/call # spent 900ns making 1 call to Search::Elasticsearch::Role::Cxn::logger
18610012.03ms10013.57ms $self->mark_live;
# spent 3.57ms making 1001 calls to Search::Elasticsearch::Role::Cxn::mark_live, avg 4µs/call
18710018.17ms 1;
188 }
189 catch {
190 $self->logger->debug("$_");
191 $self->mark_dead;
192 0;
193100113.7ms20027.25ms };
# spent 7.25ms making 1001 calls to Try::Tiny::catch, avg 7µs/call # spent 1.47s making 1001 calls to Try::Tiny::try, avg 1.47ms/call, recursion: max depth 1, sum of overlapping time 1.47s
194}
195
196#===================================
197sub sniff {
198#===================================
199 my $self = shift;
200 $self->logger->infof( 'Sniffing [%s]', $self->stringify );
201 return try {
202 $self->perform_request(
203 { method => 'GET',
204 path => '/_nodes/http',
205 qs => { timeout => $self->sniff_timeout . 's' },
206 timeout => $self->sniff_request_timeout,
207 }
208 )->{nodes};
209 }
210 catch {
211 $self->logger->debug($_);
212 return;
213 };
214}
215
216#===================================
217
# spent 198ms (36.1+162) within Search::Elasticsearch::Role::Cxn::build_uri which was called 2002 times, avg 99µs/call: # 2002 times (36.1ms+162ms) by Search::Elasticsearch::Cxn::HTTPTiny::perform_request at line 20 of Search/Elasticsearch/Cxn/HTTPTiny.pm, avg 99µs/call
sub build_uri {
218#===================================
2192002581µs my ( $self, $params ) = @_;
22020024.62ms20036.75ms my $uri = $self->uri->clone;
# spent 6.75ms making 2002 calls to URI::clone, avg 3µs/call # spent 500ns making 1 call to Search::Elasticsearch::Role::Cxn::uri
22120027.41ms400495.8ms $uri->path( $uri->path . $params->{path} );
# spent 95.8ms making 4004 calls to URI::_generic::path, avg 24µs/call
22220026.14ms1800ns my %qs = ( %{ $self->default_qs_params }, %{ $params->{qs} || {} } );
22320024.55ms200259.8ms $uri->query_form( \%qs );
# spent 59.8ms making 2002 calls to URI::_query::query_form, avg 30µs/call
224200210.3ms return $uri;
225}
226
227#===================================
228
# spent 16.0ms (12.5+3.49) within Search::Elasticsearch::Role::Cxn::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Search/Elasticsearch/Role/Cxn.pm:243] which was called 2002 times, avg 8µs/call: # 2002 times (12.5ms+3.49ms) by Search::Elasticsearch::Cxn::HTTPTiny::perform_request at line 4 of (eval 270)[Class/Method/Modifiers.pm:152], avg 8µs/call
before 'perform_request' => sub {
229#===================================
23020021.02ms my ( $self, $params ) = @_;
23120023.45ms return unless defined $params->{data};
232
23310001.77ms10003.49ms $self->_compress_body($params);
# spent 3.49ms making 1000 calls to Search::Elasticsearch::Role::Cxn::_compress_body, avg 3µs/call
234
23510001.51ms1600ns my $max = $self->max_content_length
236 or return;
237
23810004.70ms return if length( $params->{data} ) < $max;
239
240 $self->logger->throw_error( 'ContentLength',
241 "Body is longer than max_content_length ($max)",
242 );
24312µs15µs};
# spent 5µs making 1 call to Moo::Role::before
244
245#===================================
246
# spent 3.49ms (3.49+1µs) within Search::Elasticsearch::Role::Cxn::_compress_body which was called 1000 times, avg 3µs/call: # 1000 times (3.49ms+1µs) by Search::Elasticsearch::Role::Cxn::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Search/Elasticsearch/Role/Cxn.pm:243] at line 233, avg 3µs/call
sub _compress_body {
247#===================================
2481000366µs my ( $self, $params ) = @_;
2491000308µs my $output;
25010003.85ms21µs if ( $self->gzip ) {
# spent 800ns making 1 call to Search::Elasticsearch::Role::Cxn::gzip # spent 600ns making 1 call to Search::Elasticsearch::Role::Cxn::deflate
251 IO::Compress::Gzip::gzip( \( $params->{data} ), \$output )
252 or throw( 'Request',
253 "Couldn't gzip request: $IO::Compress::Gzip::GzipError" );
254 $params->{data} = $output;
255 $params->{encoding} = 'gzip';
256 }
257 elsif ( $self->deflate ) {
258 IO::Compress::Deflate::deflate( \( $params->{data} ), \$output )
259 or throw( 'Request',
260 "Couldn't deflate request: $IO::Compress::Deflate::DeflateError" );
261 $params->{data} = $output;
262 $params->{encoding} = 'deflate';
263 }
264}
265
266#===================================
267
# spent 5.34ms within Search::Elasticsearch::Role::Cxn::_decompress_body which was called 2002 times, avg 3µs/call: # 2002 times (5.34ms+0s) by Search::Elasticsearch::Role::Cxn::process_response at line 298, avg 3µs/call
sub _decompress_body {
268#===================================
26920021.08ms my ( $self, $body_ref, $headers ) = @_;
270200211.4ms if ( my $encoding = $headers->{'content-encoding'} ) {
271 my $output;
272 if ( $encoding eq 'gzip' ) {
273 IO::Uncompress::Gunzip::gunzip( $body_ref, \$output )
274 or throw(
275 'Request',
276 "Couldn't gunzip response: $IO::Uncompress::Gunzip::GunzipError"
277 );
278 }
279 elsif ( $encoding eq 'deflate' ) {
280 IO::Uncompress::Inflate::inflate( $body_ref, \$output,
281 Transparent => 0 )
282 or throw(
283 'Request',
284 "Couldn't inflate response: $IO::Uncompress::Inflate::InflateError"
285 );
286 }
287 else {
288 throw( 'Request', "Unknown content-encoding: $encoding" );
289 }
290 ${$body_ref} = $output;
291 }
292}
293
294#===================================
295
# spent 142ms (46.7+95.7) within Search::Elasticsearch::Role::Cxn::process_response which was called 2002 times, avg 71µs/call: # 2002 times (46.7ms+95.7ms) by Search::Elasticsearch::Cxn::HTTPTiny::perform_request at line 42 of Search/Elasticsearch/Cxn/HTTPTiny.pm, avg 71µs/call
sub process_response {
296#===================================
29720022.22ms my ( $self, $params, $code, $msg, $body, $headers ) = @_;
29820025.14ms20025.34ms $self->_decompress_body( \$body, $headers );
# spent 5.34ms making 2002 calls to Search::Elasticsearch::Role::Cxn::_decompress_body, avg 3µs/call
299
30020029.10ms my ($mime_type) = split /\s*;\s*/, ( $headers->{'content-type'} || '' );
301
30220021.48ms my $is_encoded = $mime_type && $mime_type ne 'text/plain';
303
304 # Deprecation warnings
30520021.33ms if (my $warnings = $headers->{warning}) {
306 $warnings = join ("; ",@$warnings) if ref $warnings eq 'ARRAY';
307 $self->logger->deprecation($warnings,$params);
308 }
309
310 # Request is successful
311
31220022.45ms if ( $code >= 200 and $code <= 209 ) {
31320021.00ms if ( defined $body and length $body ) {
314100110.2ms100290.3ms $body = $self->serializer->decode($body)
# spent 90.3ms making 1001 calls to Search::Elasticsearch::Role::Serializer::JSON::decode, avg 90µs/call # spent 2µs making 1 call to Search::Elasticsearch::Role::Cxn::serializer
315 if $is_encoded;
31610013.28ms return $code, $body;
317 }
31810013.02ms return ( $code, 1 ) if $params->{method} eq 'HEAD';
319 return ( $code, '' );
320 }
321
322 # Check if the error should be ignored
323 my @ignore = to_list( $params->{ignore} );
324 push @ignore, 404 if $params->{method} eq 'HEAD';
325 return ($code) if grep { $_ eq $code } @ignore;
326
327 # Determine error type
328 my $error_type = $Code_To_Error{$code};
329 unless ($error_type) {
330 if ( defined $body and length $body ) {
331 $msg = $body;
332 $body = undef;
333 }
334 $error_type = $self->error_from_text( $code, $msg );
335 }
336
337 delete $params->{data} if $params->{body};
338 my %error_args = ( status_code => $code, request => $params );
339
340 # Extract error message from the body, if present
341
342 if ( $body = $self->serializer->decode($body) ) {
343 $error_args{body} = $body;
344 $msg = $self->_munge_elasticsearch_exception($body) || $msg;
345
346 $error_args{current_version} = $1
347 if $error_type eq 'Conflict'
348 and $msg
349 =~ /: version conflict, current (?:version )?\[(\d+)\]/;
350 }
351 $msg ||= $error_type;
352
353 chomp $msg;
354 throw( $error_type, "[" . $self->stringify . "]-[$code] $msg",
355 \%error_args );
356}
357
358#===================================
359sub _munge_elasticsearch_exception {
360#===================================
361 my ( $self, $body ) = @_;
362 return $body unless ref $body eq 'HASH';
363 my $error = $body->{error} || return;
364 return $error unless ref $error eq 'HASH';
365
366 my $root_causes = $error->{root_cause} || [];
367 unless (@$root_causes) {
368 my $msg = "[" . $error->{type} . "] " if $error->{type};
369 $msg .= $error->{reason} if $error->{reason};
370 return $msg;
371 }
372
373 my $json = $self->serializer;
374 my @msgs;
375 for (@$root_causes) {
376 my %cause = (%$_);
377 my $msg
378 = "[" . ( delete $cause{type} ) . "] " . ( delete $cause{reason} );
379 if ( keys %cause ) {
380 $msg .= ", with: " . $json->encode( \%cause );
381 }
382 push @msgs, $msg;
383 }
384 return ( join ", ", @msgs );
385}
386
387112µs1;
388
389# ABSTRACT: Provides common functionality to HTTP Cxn implementations
390
391118µs1284µs__END__
 
# spent 2.33ms within Search::Elasticsearch::Role::Cxn::CORE:match which was called 1001 times, avg 2µs/call: # 1001 times (2.33ms+0s) by Search::Elasticsearch::Role::Cxn::BUILDARGS at line 68, avg 2µs/call
sub Search::Elasticsearch::Role::Cxn::CORE:match; # opcode
# spent 3.07ms within Search::Elasticsearch::Role::Cxn::CORE:subst which was called 2002 times, avg 2µs/call: # 1001 times (1.78ms+0s) by Search::Elasticsearch::Role::Cxn::BUILDARGS at line 93, avg 2µs/call # 1001 times (1.29ms+0s) by Search::Elasticsearch::Role::Cxn::BUILDARGS at line 94, avg 1µs/call
sub Search::Elasticsearch::Role::Cxn::CORE:subst; # opcode
# spent 2µs within Search::Elasticsearch::Role::Cxn::_pid which was called: # once (2µs+0s) by Search::Elasticsearch::Role::Cxn::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Search/Elasticsearch/Role/Cxn.pm:134] at line 130
sub Search::Elasticsearch::Role::Cxn::_pid; # xsub
# spent 800ns within Search::Elasticsearch::Role::Cxn::default_headers which was called: # once (800ns+0s) by Search::Elasticsearch::Cxn::HTTPTiny::_build_handle at line 61 of Search/Elasticsearch/Cxn/HTTPTiny.pm
sub Search::Elasticsearch::Role::Cxn::default_headers; # xsub
# spent 800ns within Search::Elasticsearch::Role::Cxn::default_qs_params which was called: # once (800ns+0s) by Search::Elasticsearch::Role::Cxn::build_uri at line 222
sub Search::Elasticsearch::Role::Cxn::default_qs_params; # xsub
# spent 600ns within Search::Elasticsearch::Role::Cxn::deflate which was called: # once (600ns+0s) by Search::Elasticsearch::Role::Cxn::_compress_body at line 250
sub Search::Elasticsearch::Role::Cxn::deflate; # xsub
# spent 800ns within Search::Elasticsearch::Role::Cxn::gzip which was called: # once (800ns+0s) by Search::Elasticsearch::Role::Cxn::_compress_body at line 250
sub Search::Elasticsearch::Role::Cxn::gzip; # xsub
# spent 600ns within Search::Elasticsearch::Role::Cxn::handle_args which was called: # once (600ns+0s) by Search::Elasticsearch::Cxn::HTTPTiny::_build_handle at line 69 of Search/Elasticsearch/Cxn/HTTPTiny.pm
sub Search::Elasticsearch::Role::Cxn::handle_args; # xsub
# spent 800ns within Search::Elasticsearch::Role::Cxn::is_https which was called: # once (800ns+0s) by Search::Elasticsearch::Cxn::HTTPTiny::_build_handle at line 62 of Search/Elasticsearch/Cxn/HTTPTiny.pm
sub Search::Elasticsearch::Role::Cxn::is_https; # xsub
# spent 2µs within Search::Elasticsearch::Role::Cxn::logger which was called 2 times, avg 800ns/call: # once (900ns+0s) by Search::Elasticsearch::Role::Cxn::try {...} at line 185 # once (700ns+0s) by Search::Elasticsearch::Role::Cxn::pings_ok at line 177
sub Search::Elasticsearch::Role::Cxn::logger; # xsub
# spent 600ns within Search::Elasticsearch::Role::Cxn::max_content_length which was called: # once (600ns+0s) by Search::Elasticsearch::Role::Cxn::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Search/Elasticsearch/Role/Cxn.pm:243] at line 235
sub Search::Elasticsearch::Role::Cxn::max_content_length; # xsub
# spent 3µs within Search::Elasticsearch::Role::Cxn::next_ping which was called 5 times, avg 600ns/call: # once (900ns+0s) by Search::Elasticsearch::Role::Cxn::is_live at line 137 # once (800ns+0s) by Search::Elasticsearch::Role::Cxn::is_dead at line 138 # once (600ns+0s) by Search::Elasticsearch::Role::Cxn::mark_live at line 146 # once (400ns+0s) by Search::Elasticsearch::Role::Cxn::force_ping at line 170 # once (300ns+0s) by Search::Elasticsearch::CxnPool::Static::next_cxn at line 24 of Search/Elasticsearch/CxnPool/Static.pm
sub Search::Elasticsearch::Role::Cxn::next_ping; # xsub
# spent 2µs within Search::Elasticsearch::Role::Cxn::ping_failures which was called 2 times, avg 950ns/call: # once (1µs+0s) by Search::Elasticsearch::Role::Cxn::force_ping at line 169 # once (900ns+0s) by Search::Elasticsearch::Role::Cxn::mark_live at line 145
sub Search::Elasticsearch::Role::Cxn::ping_failures; # xsub
# spent 2µs within Search::Elasticsearch::Role::Cxn::ping_timeout which was called: # once (2µs+0s) by Search::Elasticsearch::Role::Cxn::try {...} at line 179
sub Search::Elasticsearch::Role::Cxn::ping_timeout; # xsub
# spent 800ns within Search::Elasticsearch::Role::Cxn::request_timeout which was called: # once (800ns+0s) by Search::Elasticsearch::Cxn::HTTPTiny::perform_request at line 32 of Search/Elasticsearch/Cxn/HTTPTiny.pm
sub Search::Elasticsearch::Role::Cxn::request_timeout; # xsub
# spent 2µs within Search::Elasticsearch::Role::Cxn::serializer which was called: # once (2µs+0s) by Search::Elasticsearch::Role::Cxn::process_response at line 314
sub Search::Elasticsearch::Role::Cxn::serializer; # xsub
# spent 2µs within Search::Elasticsearch::Role::Cxn::uri which was called 2 times, avg 1µs/call: # once (2µs+0s) by Search::Elasticsearch::Role::Cxn::stringify at line 56 # once (500ns+0s) by Search::Elasticsearch::Role::Cxn::build_uri at line 220
sub Search::Elasticsearch::Role::Cxn::uri; # xsub