Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Search/Elasticsearch/Role/Cxn.pm |
Statements | Executed 97144 statements in 286ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1001 | 1 | 1 | 82.2ms | 376ms | BUILDARGS | Search::Elasticsearch::Role::Cxn::
4004 | 4 | 3 | 47.2ms | 53.4ms | stringify | Search::Elasticsearch::Role::Cxn::
2002 | 1 | 1 | 46.7ms | 142ms | process_response | Search::Elasticsearch::Role::Cxn::
2002 | 1 | 1 | 36.1ms | 198ms | build_uri | Search::Elasticsearch::Role::Cxn::
1001 | 1 | 1 | 31.6ms | 1.44s | try {...} | Search::Elasticsearch::Role::Cxn::
1001 | 1 | 1 | 16.8ms | 1.55s | pings_ok | Search::Elasticsearch::Role::Cxn::
2002 | 1 | 1 | 12.5ms | 16.0ms | __ANON__[:243] | Search::Elasticsearch::Role::Cxn::
2002 | 2 | 2 | 8.57ms | 8.57ms | mark_live | Search::Elasticsearch::Role::Cxn::
2002 | 1 | 1 | 7.71ms | 7.71ms | __ANON__[:134] | Search::Elasticsearch::Role::Cxn::
2002 | 1 | 1 | 5.34ms | 5.34ms | _decompress_body | Search::Elasticsearch::Role::Cxn::
1000 | 1 | 1 | 3.49ms | 3.49ms | _compress_body | Search::Elasticsearch::Role::Cxn::
1001 | 1 | 1 | 3.11ms | 3.11ms | force_ping | Search::Elasticsearch::Role::Cxn::
2002 | 2 | 1 | 3.07ms | 3.07ms | CORE:subst (opcode) | Search::Elasticsearch::Role::Cxn::
1001 | 1 | 1 | 2.65ms | 2.65ms | is_live | Search::Elasticsearch::Role::Cxn::
1001 | 1 | 1 | 2.36ms | 2.36ms | is_dead | Search::Elasticsearch::Role::Cxn::
1001 | 1 | 1 | 2.33ms | 2.33ms | CORE:match (opcode) | Search::Elasticsearch::Role::Cxn::
1001 | 1 | 1 | 2.04ms | 2.04ms | __ANON__[:31] | Search::Elasticsearch::Role::Cxn::
1001 | 1 | 1 | 1.68ms | 1.68ms | __ANON__[:30] | Search::Elasticsearch::Role::Cxn::
1 | 1 | 1 | 834µs | 3.01ms | BEGIN@10 | Search::Elasticsearch::Role::Cxn::
1 | 1 | 1 | 742µs | 1.06ms | BEGIN@11 | Search::Elasticsearch::Role::Cxn::
1 | 1 | 1 | 540µs | 6.37ms | BEGIN@9 | Search::Elasticsearch::Role::Cxn::
1 | 1 | 1 | 538µs | 14.3ms | BEGIN@8 | Search::Elasticsearch::Role::Cxn::
1 | 1 | 1 | 11µs | 34µs | BEGIN@5 | Search::Elasticsearch::Role::Cxn::
1 | 1 | 1 | 9µs | 152µs | BEGIN@12 | Search::Elasticsearch::Role::Cxn::
1 | 1 | 1 | 8µs | 664µs | BEGIN@3 | Search::Elasticsearch::Role::Cxn::
1 | 1 | 1 | 8µs | 186µs | BEGIN@13 | Search::Elasticsearch::Role::Cxn::
1 | 1 | 1 | 7µs | 213µs | BEGIN@4 | Search::Elasticsearch::Role::Cxn::
1 | 1 | 1 | 5µs | 26µs | BEGIN@6 | Search::Elasticsearch::Role::Cxn::
5 | 5 | 2 | 3µs | 3µs | next_ping (xsub) | Search::Elasticsearch::Role::Cxn::
1 | 1 | 1 | 2µs | 2µs | BEGIN@7 | Search::Elasticsearch::Role::Cxn::
2 | 2 | 1 | 2µs | 2µs | uri (xsub) | Search::Elasticsearch::Role::Cxn::
2 | 2 | 1 | 2µs | 2µs | ping_failures (xsub) | Search::Elasticsearch::Role::Cxn::
1 | 1 | 1 | 2µs | 2µs | ping_timeout (xsub) | Search::Elasticsearch::Role::Cxn::
1 | 1 | 1 | 2µs | 2µs | _pid (xsub) | Search::Elasticsearch::Role::Cxn::
1 | 1 | 1 | 2µs | 2µs | serializer (xsub) | Search::Elasticsearch::Role::Cxn::
2 | 2 | 1 | 2µs | 2µs | logger (xsub) | Search::Elasticsearch::Role::Cxn::
1 | 1 | 1 | 800ns | 800ns | default_headers (xsub) | Search::Elasticsearch::Role::Cxn::
1 | 1 | 1 | 800ns | 800ns | default_qs_params (xsub) | Search::Elasticsearch::Role::Cxn::
1 | 1 | 1 | 800ns | 800ns | gzip (xsub) | Search::Elasticsearch::Role::Cxn::
1 | 1 | 1 | 800ns | 800ns | is_https (xsub) | Search::Elasticsearch::Role::Cxn::
1 | 1 | 1 | 800ns | 800ns | request_timeout (xsub) | Search::Elasticsearch::Role::Cxn::
1 | 1 | 1 | 600ns | 600ns | deflate (xsub) | Search::Elasticsearch::Role::Cxn::
1 | 1 | 1 | 600ns | 600ns | handle_args (xsub) | Search::Elasticsearch::Role::Cxn::
1 | 1 | 1 | 600ns | 600ns | max_content_length (xsub) | Search::Elasticsearch::Role::Cxn::
0 | 0 | 0 | 0s | 0s | __ANON__[:188] | Search::Elasticsearch::Role::Cxn::
0 | 0 | 0 | 0s | 0s | __ANON__[:193] | Search::Elasticsearch::Role::Cxn::
0 | 0 | 0 | 0s | 0s | __ANON__[:209] | Search::Elasticsearch::Role::Cxn::
0 | 0 | 0 | 0s | 0s | __ANON__[:213] | Search::Elasticsearch::Role::Cxn::
0 | 0 | 0 | 0s | 0s | _munge_elasticsearch_exception | Search::Elasticsearch::Role::Cxn::
0 | 0 | 0 | 0s | 0s | catch {...} | Search::Elasticsearch::Role::Cxn::
0 | 0 | 0 | 0s | 0s | mark_dead | Search::Elasticsearch::Role::Cxn::
0 | 0 | 0 | 0s | 0s | sniff | Search::Elasticsearch::Role::Cxn::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Search::Elasticsearch::Role::Cxn; | ||||
2 | 1 | 400ns | $Search::Elasticsearch::Role::Cxn::VERSION = '5.01'; | ||
3 | 2 | 25µs | 2 | 1.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 # spent 664µs making 1 call to Search::Elasticsearch::Role::Cxn::BEGIN@3
# spent 656µs making 1 call to Moo::Role::import |
4 | 2 | 24µs | 2 | 419µ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 # 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] |
5 | 2 | 17µs | 2 | 41µ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 # spent 34µs making 1 call to Search::Elasticsearch::Role::Cxn::BEGIN@5
# spent 8µs making 1 call to List::Util::import |
6 | 2 | 14µs | 2 | 48µ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 # spent 26µs making 1 call to Search::Elasticsearch::Role::Cxn::BEGIN@6
# spent 21µs making 1 call to Exporter::import |
7 | 2 | 12µs | 1 | 2µ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 # spent 2µs making 1 call to Search::Elasticsearch::Role::Cxn::BEGIN@7 |
8 | 2 | 76µs | 1 | 14.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 # spent 14.3ms making 1 call to Search::Elasticsearch::Role::Cxn::BEGIN@8 |
9 | 2 | 70µs | 1 | 6.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 # spent 6.37ms making 1 call to Search::Elasticsearch::Role::Cxn::BEGIN@9 |
10 | 2 | 69µs | 1 | 3.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 # spent 3.01ms making 1 call to Search::Elasticsearch::Role::Cxn::BEGIN@10 |
11 | 2 | 70µs | 2 | 1.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 # spent 1.06ms making 1 call to Search::Elasticsearch::Role::Cxn::BEGIN@11
# spent 52µs making 1 call to Exporter::import |
12 | 2 | 22µs | 2 | 296µ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 # 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] |
13 | 2 | 1.12ms | 2 | 364µ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 # spent 186µs making 1 call to Search::Elasticsearch::Role::Cxn::BEGIN@13
# spent 178µs making 1 call to namespace::clean::import |
14 | |||||
15 | 1 | 2µs | 1 | 16µs | requires qw(perform_request error_from_text handle); # spent 16µs making 1 call to Moo::Role::requires |
16 | |||||
17 | 1 | 900ns | 1 | 122µs | has 'host' => ( is => 'ro', required => 1 ); # spent 122µs making 1 call to Moo::Role::has |
18 | 1 | 600ns | 1 | 52µs | has 'port' => ( is => 'ro', required => 1 ); # spent 52µs making 1 call to Moo::Role::has |
19 | 1 | 500ns | 1 | 47µs | has 'uri' => ( is => 'ro', required => 1 ); # spent 47µs making 1 call to Moo::Role::has |
20 | 1 | 400ns | 1 | 46µs | has 'request_timeout' => ( is => 'ro', default => 30 ); # spent 46µs making 1 call to Moo::Role::has |
21 | 1 | 500ns | 1 | 47µs | has 'ping_timeout' => ( is => 'ro', default => 2 ); # spent 47µs making 1 call to Moo::Role::has |
22 | 1 | 600ns | 1 | 46µs | has 'sniff_timeout' => ( is => 'ro', default => 1 ); # spent 46µs making 1 call to Moo::Role::has |
23 | 1 | 500ns | 1 | 44µs | has 'sniff_request_timeout' => ( is => 'ro', default => 2 ); # spent 44µs making 1 call to Moo::Role::has |
24 | 1 | 500ns | 1 | 95µs | has 'next_ping' => ( is => 'rw', default => 0 ); # spent 95µs making 1 call to Moo::Role::has |
25 | 1 | 500ns | 1 | 48µs | has 'ping_failures' => ( is => 'rw', default => 0 ); # spent 48µs making 1 call to Moo::Role::has |
26 | 1 | 600ns | 1 | 57µs | has 'dead_timeout' => ( is => 'ro', default => 60 ); # spent 57µs making 1 call to Moo::Role::has |
27 | 1 | 500ns | 1 | 45µs | has 'max_dead_timeout' => ( is => 'ro', default => 3600 ); # spent 45µs making 1 call to Moo::Role::has |
28 | 1 | 500ns | 1 | 44µs | has 'serializer' => ( is => 'ro', required => 1 ); # spent 44µs making 1 call to Moo::Role::has |
29 | 1 | 500ns | 1 | 50µs | has 'logger' => ( is => 'ro', required => 1 ); # spent 50µs making 1 call to Moo::Role::has |
30 | 1002 | 1.91ms | 1 | 59µ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 # spent 59µs making 1 call to Moo::Role::has |
31 | 1002 | 2.44ms | 1 | 52µ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 # spent 52µs making 1 call to Moo::Role::has |
32 | 1 | 500ns | 1 | 47µs | has 'scheme' => ( is => 'ro' ); # spent 47µs making 1 call to Moo::Role::has |
33 | 1 | 500ns | 1 | 45µs | has 'is_https' => ( is => 'ro' ); # spent 45µs making 1 call to Moo::Role::has |
34 | 1 | 500ns | 1 | 44µs | has 'userinfo' => ( is => 'ro' ); # spent 44µs making 1 call to Moo::Role::has |
35 | 1 | 400ns | 1 | 45µs | has 'max_content_length' => ( is => 'ro' ); # spent 45µs making 1 call to Moo::Role::has |
36 | 1 | 500ns | 1 | 45µs | has 'default_headers' => ( is => 'ro' ); # spent 45µs making 1 call to Moo::Role::has |
37 | 1 | 400ns | 1 | 44µs | has 'deflate' => ( is => 'ro' ); # spent 44µs making 1 call to Moo::Role::has |
38 | 1 | 500ns | 1 | 44µs | has 'gzip' => ( is => 'ro' ); # spent 44µs making 1 call to Moo::Role::has |
39 | 1 | 500ns | 1 | 84µs | has 'ssl_options' => ( is => 'ro', predicate => 'has_ssl_options' ); # spent 84µs making 1 call to Moo::Role::has |
40 | 1 | 500ns | 1 | 213µs | has 'handle' => ( is => 'lazy', clearer => 1 ); # spent 213µs making 1 call to Moo::Role::has |
41 | 1 | 700ns | 1 | 69µs | has '_pid' => ( is => 'rw', default => $$ ); # spent 69µs making 1 call to Moo::Role::has |
42 | |||||
43 | 1 | 5µs | my %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 | #=================================== | ||||
56 | 4004 | 28.5ms | 4005 | 6.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 # 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 | ||||
61 | #=================================== | ||||
62 | 1001 | 2.22ms | 1001 | 4.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} | ||||
65 | 1001 | 816µs | || { host => 'localhost', port => '9200' }; | ||
66 | |||||
67 | 1001 | 1.05ms | unless ( ref $node eq 'HASH' ) { | ||
68 | 1001 | 4.54ms | 1001 | 2.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 | } | ||||
71 | 1001 | 668µs | if ( $params->{port} && $node !~ m{//[^/]+:\d+} ) { | ||
72 | $node =~ s{(//[^/]+)}{$1:$params->{port}}; | ||||
73 | } | ||||
74 | 1001 | 5.69ms | 1001 | 105ms | my $uri = URI->new($node); # spent 105ms making 1001 calls to URI::new, avg 105µs/call |
75 | 1001 | 13.4ms | 5005 | 105ms | $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 | |||||
84 | 1001 | 909µs | my $host = $node->{host} || 'localhost'; | ||
85 | 1001 | 1.30ms | my $userinfo = $node->{userinfo} || $params->{userinfo} || ''; | ||
86 | my $scheme | ||||
87 | 1001 | 552µs | = $node->{scheme} || ( $params->{use_https} ? 'https' : 'http' ); | ||
88 | my $port | ||||
89 | = $node->{port} | ||||
90 | || $params->{port} | ||||
91 | 1001 | 565µs | || ( $scheme eq 'http' ? 80 : 443 ); | ||
92 | 1001 | 931µs | my $path = $node->{path} || $params->{path_prefix} || ''; | ||
93 | 1001 | 4.15ms | 1001 | 1.78ms | $path =~ s{^/?}{/}g; # spent 1.78ms making 1001 calls to Search::Elasticsearch::Role::Cxn::CORE:subst, avg 2µs/call |
94 | 1001 | 2.70ms | 1001 | 1.29ms | $path =~ s{/+$}{}; # spent 1.29ms making 1001 calls to Search::Elasticsearch::Role::Cxn::CORE:subst, avg 1µs/call |
95 | |||||
96 | 1001 | 2.47ms | my %default_headers = %{ $params->{default_headers} || {} }; | ||
97 | |||||
98 | 1001 | 441µ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 | |||||
105 | 1001 | 899µs | if ( $params->{gzip} ) { | ||
106 | $default_headers{'Accept-Encoding'} = "gzip"; | ||||
107 | } | ||||
108 | |||||
109 | elsif ( $params->{deflate} ) { | ||||
110 | $default_headers{'Accept-Encoding'} = "deflate"; | ||||
111 | } | ||||
112 | |||||
113 | 1001 | 964µs | $params->{scheme} = $scheme; | ||
114 | 1001 | 1.10ms | $params->{is_https} = $scheme eq 'https'; | ||
115 | 1001 | 1.15ms | $params->{host} = $host; | ||
116 | 1001 | 553µs | $params->{port} = $port; | ||
117 | 1001 | 566µs | $params->{path} = $path; | ||
118 | 1001 | 537µs | $params->{userinfo} = $userinfo; | ||
119 | 1001 | 3.12ms | 1001 | 74.6ms | $params->{uri} = URI->new("$scheme://$host:$port$path"); # spent 74.6ms making 1001 calls to URI::new, avg 75µs/call |
120 | 1001 | 856µs | $params->{default_headers} = \%default_headers; | ||
121 | |||||
122 | 1001 | 10.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 | ||||
128 | #=================================== | ||||
129 | 2002 | 623µs | my $self = shift; | ||
130 | 2002 | 20.1ms | 1 | 2µs | if ( $$ != $self->_pid ) { # spent 2µs making 1 call to Search::Elasticsearch::Role::Cxn::_pid |
131 | $self->clear_handle; | ||||
132 | $self->_pid($$); | ||||
133 | } | ||||
134 | 1 | 2µs | 1 | 872µs | }; # spent 872µs making 1 call to Moo::Role::before |
135 | |||||
136 | #=================================== | ||||
137 | 1001 | 2.91ms | 1 | 900ns | # 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 # spent 900ns making 1 call to Search::Elasticsearch::Role::Cxn::next_ping |
138 | 1001 | 3.32ms | 1 | 800ns | # 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 # 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 | ||||
143 | #=================================== | ||||
144 | 2002 | 1.06ms | my $self = shift; | ||
145 | 2002 | 2.89ms | 1 | 900ns | $self->ping_failures(0); # spent 900ns making 1 call to Search::Elasticsearch::Role::Cxn::ping_failures |
146 | 2002 | 11.7ms | 1 | 600ns | $self->next_ping(0); # spent 600ns making 1 call to Search::Elasticsearch::Role::Cxn::next_ping |
147 | } | ||||
148 | |||||
149 | #=================================== | ||||
150 | sub 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 | ||||
167 | #=================================== | ||||
168 | 1001 | 402µs | my $self = shift; | ||
169 | 1001 | 1.28ms | 1 | 1µs | $self->ping_failures(0); # spent 1µs making 1 call to Search::Elasticsearch::Role::Cxn::ping_failures |
170 | 1001 | 2.10ms | 1 | 400ns | $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 | ||||
175 | #=================================== | ||||
176 | 1001 | 487µs | my $self = shift; | ||
177 | 1001 | 4.17ms | 2003 | 21.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 | ||||
179 | 1001 | 6.81ms | 1002 | 1.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 | ); | ||||
185 | 1001 | 4.95ms | 2003 | 17.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 |
186 | 1001 | 2.03ms | 1001 | 3.57ms | $self->mark_live; # spent 3.57ms making 1001 calls to Search::Elasticsearch::Role::Cxn::mark_live, avg 4µs/call |
187 | 1001 | 8.17ms | 1; | ||
188 | } | ||||
189 | catch { | ||||
190 | $self->logger->debug("$_"); | ||||
191 | $self->mark_dead; | ||||
192 | 0; | ||||
193 | 1001 | 13.7ms | 2002 | 7.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 | #=================================== | ||||
197 | sub 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 | ||||
218 | #=================================== | ||||
219 | 2002 | 581µs | my ( $self, $params ) = @_; | ||
220 | 2002 | 4.62ms | 2003 | 6.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 |
221 | 2002 | 7.41ms | 4004 | 95.8ms | $uri->path( $uri->path . $params->{path} ); # spent 95.8ms making 4004 calls to URI::_generic::path, avg 24µs/call |
222 | 2002 | 6.14ms | 1 | 800ns | my %qs = ( %{ $self->default_qs_params }, %{ $params->{qs} || {} } ); # spent 800ns making 1 call to Search::Elasticsearch::Role::Cxn::default_qs_params |
223 | 2002 | 4.55ms | 2002 | 59.8ms | $uri->query_form( \%qs ); # spent 59.8ms making 2002 calls to URI::_query::query_form, avg 30µs/call |
224 | 2002 | 10.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 | ||||
229 | #=================================== | ||||
230 | 2002 | 1.02ms | my ( $self, $params ) = @_; | ||
231 | 2002 | 3.45ms | return unless defined $params->{data}; | ||
232 | |||||
233 | 1000 | 1.77ms | 1000 | 3.49ms | $self->_compress_body($params); # spent 3.49ms making 1000 calls to Search::Elasticsearch::Role::Cxn::_compress_body, avg 3µs/call |
234 | |||||
235 | 1000 | 1.51ms | 1 | 600ns | my $max = $self->max_content_length # spent 600ns making 1 call to Search::Elasticsearch::Role::Cxn::max_content_length |
236 | or return; | ||||
237 | |||||
238 | 1000 | 4.70ms | return if length( $params->{data} ) < $max; | ||
239 | |||||
240 | $self->logger->throw_error( 'ContentLength', | ||||
241 | "Body is longer than max_content_length ($max)", | ||||
242 | ); | ||||
243 | 1 | 2µs | 1 | 5µ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 | ||||
247 | #=================================== | ||||
248 | 1000 | 366µs | my ( $self, $params ) = @_; | ||
249 | 1000 | 308µs | my $output; | ||
250 | 1000 | 3.85ms | 2 | 1µ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 | ||||
268 | #=================================== | ||||
269 | 2002 | 1.08ms | my ( $self, $body_ref, $headers ) = @_; | ||
270 | 2002 | 11.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 | ||||
296 | #=================================== | ||||
297 | 2002 | 2.22ms | my ( $self, $params, $code, $msg, $body, $headers ) = @_; | ||
298 | 2002 | 5.14ms | 2002 | 5.34ms | $self->_decompress_body( \$body, $headers ); # spent 5.34ms making 2002 calls to Search::Elasticsearch::Role::Cxn::_decompress_body, avg 3µs/call |
299 | |||||
300 | 2002 | 9.10ms | my ($mime_type) = split /\s*;\s*/, ( $headers->{'content-type'} || '' ); | ||
301 | |||||
302 | 2002 | 1.48ms | my $is_encoded = $mime_type && $mime_type ne 'text/plain'; | ||
303 | |||||
304 | # Deprecation warnings | ||||
305 | 2002 | 1.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 | |||||
312 | 2002 | 2.45ms | if ( $code >= 200 and $code <= 209 ) { | ||
313 | 2002 | 1.00ms | if ( defined $body and length $body ) { | ||
314 | 1001 | 10.2ms | 1002 | 90.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; | ||||
316 | 1001 | 3.28ms | return $code, $body; | ||
317 | } | ||||
318 | 1001 | 3.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 | #=================================== | ||||
359 | sub _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 | |||||
387 | 1 | 12µs | 1; | ||
388 | |||||
389 | # ABSTRACT: Provides common functionality to HTTP Cxn implementations | ||||
390 | |||||
391 | 1 | 18µs | 1 | 284µs | __END__ # spent 284µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__[B/Hooks/EndOfScope/XS.pm:17] |
# 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 | |||||
# 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 | |||||
# 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 | |||||
# 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 | |||||
# 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 | |||||
# spent 600ns within Search::Elasticsearch::Role::Cxn::deflate which was called:
# once (600ns+0s) by Search::Elasticsearch::Role::Cxn::_compress_body at line 250 | |||||
# spent 800ns within Search::Elasticsearch::Role::Cxn::gzip which was called:
# once (800ns+0s) by Search::Elasticsearch::Role::Cxn::_compress_body at line 250 | |||||
# 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 | |||||
# 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::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 | |||||
# 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::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 | |||||
# 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 | |||||
# 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::uri; # xsub |