← Index
NYTProf Performance Profile   « block view • line view • sub view »
For xt/tapper-mcp-scheduler-with-db-longrun.t
  Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:22:36 2012

Filename/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Tapper/Schema/TestrunDB/Result/TestrunScheduling.pm
StatementsExecuted 2954 statements in 64.9ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
2971143.0ms6.01sTapper::Schema::TestrunDB::Result::TestrunScheduling::::fitsTapper::Schema::TestrunDB::Result::TestrunScheduling::fits
1471110.8ms36.1sTapper::Schema::TestrunDB::Result::TestrunScheduling::::mark_as_runningTapper::Schema::TestrunDB::Result::TestrunScheduling::mark_as_running
1113.41ms4.03msTapper::Schema::TestrunDB::Result::TestrunScheduling::::BEGIN@197Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@197
1111.95ms58.0msTapper::Schema::TestrunDB::Result::TestrunScheduling::::BEGIN@12Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@12
11149µs1.91msTapper::Schema::TestrunDB::Result::TestrunScheduling::::gen_schema_functionsTapper::Schema::TestrunDB::Result::TestrunScheduling::gen_schema_functions
11117µs34µsTapper::Schema::TestrunDB::Result::TestrunScheduling::::BEGIN@13Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@13
11114µs59µsTapper::Schema::TestrunDB::Result::TestrunScheduling::::BEGIN@11Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@11
11111µs10.5msTapper::Schema::TestrunDB::Result::TestrunScheduling::::BEGIN@15Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@15
11110µs27µsTapper::Schema::TestrunDB::Result::TestrunScheduling::::BEGIN@52Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@52
11110µs10µsTapper::Schema::TestrunDB::Result::TestrunScheduling::::BEGIN@4Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@4
1119µs27µsTapper::Schema::TestrunDB::Result::TestrunScheduling::::BEGIN@214Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@214
1119µs9µsTapper::Schema::TestrunDB::Result::TestrunScheduling::::CORE:substTapper::Schema::TestrunDB::Result::TestrunScheduling::CORE:subst (opcode)
0000s0sTapper::Schema::TestrunDB::Result::TestrunScheduling::::hostnameTapper::Schema::TestrunDB::Result::TestrunScheduling::hostname
0000s0sTapper::Schema::TestrunDB::Result::TestrunScheduling::::mark_as_finishedTapper::Schema::TestrunDB::Result::TestrunScheduling::mark_as_finished
0000s0sTapper::Schema::TestrunDB::Result::TestrunScheduling::::match_featureTapper::Schema::TestrunDB::Result::TestrunScheduling::match_feature
0000s0sTapper::Schema::TestrunDB::Result::TestrunScheduling::::match_hostTapper::Schema::TestrunDB::Result::TestrunScheduling::match_host
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# TODO: rename into "(Scheduler|Result)::Job"?
2
3package Tapper::Schema::TestrunDB::Result::TestrunScheduling;
4
# spent 10µs within Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@4 which was called: # once (10µs+0s) by Tapper::MCP::Scheduler::PrioQueue::BEGIN@1 at line 6
BEGIN {
515µs $Tapper::Schema::TestrunDB::Result::TestrunScheduling::AUTHORITY = 'cpan:AMD';
6125µs110µs}
7{
821µs $Tapper::Schema::TestrunDB::Result::TestrunScheduling::VERSION = '0.001';
9}
10
11325µs2105µs
# spent 59µs (14+45) within Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@11 which was called: # once (14µs+45µs) by Tapper::MCP::Scheduler::PrioQueue::BEGIN@1 at line 11
use YAML::Syck;
# spent 59µs making 1 call to Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@11 # spent 45µs making 1 call to Exporter::import
123136µs158.0ms
# spent 58.0ms (1.95+56.0) within Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@12 which was called: # once (1.95ms+56.0ms) by Tapper::MCP::Scheduler::PrioQueue::BEGIN@1 at line 12
use Safe;
13330µs251µs
# spent 34µs (17+17) within Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@13 which was called: # once (17µs+17µs) by Tapper::MCP::Scheduler::PrioQueue::BEGIN@1 at line 13
use common::sense;
# spent 34µs making 1 call to Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@13 # spent 17µs making 1 call to common::sense::import
14## no critic (RequireUseStrict)
153237µs221.1ms
# spent 10.5ms (11µs+10.5) within Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@15 which was called: # once (11µs+10.5ms) by Tapper::MCP::Scheduler::PrioQueue::BEGIN@1 at line 15
use parent 'DBIx::Class';
# spent 10.5ms making 1 call to Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@15 # spent 10.5ms making 1 call to parent::import
16
17115µs151.7ms__PACKAGE__->load_components("InflateColumn::Object::Enum", "Core");
# spent 51.7ms making 1 call to Class::C3::Componentised::load_components
18115µs1763µs__PACKAGE__->table("testrun_scheduling");
# spent 763µs making 1 call to DBIx::Class::ResultSourceProxy::Table::table
19147µs12.14ms__PACKAGE__->add_columns
# spent 2.14ms making 1 call to DBIx::Class::ResultSourceProxy::add_columns
20 (
21 "id", { data_type => "INT", default_value => undef, is_nullable => 0, size => 11, is_auto_increment => 1, },
22 "testrun_id", { data_type => "INT", default_value => undef, is_nullable => 0, size => 11, is_foreign_key => 1, },
23 "queue_id", { data_type => "INT", default_value => 0, is_nullable => 1, size => 11, is_foreign_key => 1, },
24 "host_id", { data_type => "INT", default_value => undef, is_nullable => 1, size => 11, is_foreign_key => 1, },
25 "prioqueue_seq", { data_type => "INT", default_value => undef, is_nullable => 1, size => 11, },
26 "status", { data_type => "VARCHAR", default_value => "prepare", is_nullable => 1, size => 255, is_enum => 1, extra => { list => [qw(prepare schedule running finished)] } },
27 "auto_rerun", { data_type => "TINYINT", default_value => "0", is_nullable => 1, },
28 "created_at", { data_type => "TIMESTAMP", default_value => \'CURRENT_TIMESTAMP', is_nullable => 1, }, # '
29 "updated_at", { data_type => "DATETIME", default_value => undef, is_nullable => 1, },
30 );
31
32116µs1325µs__PACKAGE__->set_primary_key(qw/id/);
# spent 325µs making 1 call to DBIx::Class::ResultSourceProxy::set_primary_key
33
34114µs19µs(my $basepkg = __PACKAGE__) =~ s/::\w+$//;
35
36117µs1381µs__PACKAGE__->belongs_to( testrun => "${basepkg}::Testrun", { 'foreign.id' => 'self.testrun_id' });
# spent 381µs making 1 call to DBIx::Class::Relationship::BelongsTo::belongs_to
3713µs1137µs__PACKAGE__->belongs_to( queue => "${basepkg}::Queue", { 'foreign.id' => 'self.queue_id' });
# spent 137µs making 1 call to DBIx::Class::Relationship::BelongsTo::belongs_to
3813µs1125µs__PACKAGE__->belongs_to( host => "${basepkg}::Host", { 'foreign.id' => 'self.host_id' });
# spent 125µs making 1 call to DBIx::Class::Relationship::BelongsTo::belongs_to
39
40113µs1109µs__PACKAGE__->has_many ( requested_features => "${basepkg}::TestrunRequestedFeature", { 'foreign.testrun_id' => 'self.testrun_id' });
# spent 109µs making 1 call to DBIx::Class::Relationship::HasMany::has_many
4114µs199µs__PACKAGE__->has_many ( requested_hosts => "${basepkg}::TestrunRequestedHost", { 'foreign.testrun_id' => 'self.testrun_id' });
# spent 99µs making 1 call to DBIx::Class::Relationship::HasMany::has_many
42
43
44# ----- scheduler related methods -----
45
46
47sub match_host {
48 my ($self, $free_hosts) = @_;
49
50 foreach my $req_host ($self->requested_hosts->all)
51 {
523638µs244µs
# spent 27µs (10+17) within Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@52 which was called: # once (10µs+17µs) by Tapper::MCP::Scheduler::PrioQueue::BEGIN@1 at line 52
no strict 'refs'; ## no critic (ProhibitNoStrict)
# spent 27µs making 1 call to Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@52 # spent 17µs making 1 call to strict::unimport
53 FREE_HOST:
54 foreach my $free_host( map {$_->{host} } @$free_hosts) {
55 if ($free_host->queuehosts->count){
56 QUEUE_CHECK:
57 {
58 foreach my $queuehost($free_host->queuehosts->all) {
59 last QUEUE_CHECK if $queuehost->queue->id == $self->queue->id;
60 }
61 next FREE_HOST;
62 }
63 }
64 return $free_host if $free_host->name eq $req_host->host->name;
65 }
66 }
67 return;
68}
69
7011µsour @functions = ('&hostname');
71
72
73sub hostname (;$) ## no critic (ProhibitSubroutinePrototypes)
74{
75 my ($given) = @_;
76
77 if ($given) {
78 # available
79 return $given ~~ $_->{features}->{hostname};
80 } else {
81 return $_->{features}->{hostname};
82 }
83}
84
85
86sub gen_schema_functions
87
# spent 1.91ms (49µs+1.86) within Tapper::Schema::TestrunDB::Result::TestrunScheduling::gen_schema_functions which was called: # once (49µs+1.86ms) by Tapper::Model::model at line 51 of Tapper/Model.pm
{
88 # vendor("AMD"); # with optional argument the value is checked against available features and returns the matching features
89 # vendor eq "AMD"; # without argument returns the value
90 # $_ is the current context inside the while-loop (see below) where the eval happens
91328µs my ($self) = @_;
92
934400µs my $features = $self->result_source->schema->resultset('HostFeature')->search(
# spent 217µs making 1 call to DBIx::Class::Schema::resultset # spent 175µs making 1 call to DBIx::Class::ResultSet::search # spent 4µs making 1 call to DBIx::Class::ResultSource::schema # spent 4µs making 1 call to DBIx::Class::Row::result_source
94 {
95 },
96 {
97 columns => [ qw/entry/ ],
98 distinct => 1,
99 });
10011.45ms while ( my $feature = $features->next ) {
# spent 1.45ms making 1 call to DBIx::Class::ResultSet::next
101 my $entry = $feature->entry;
102 push @functions, "&".$entry;
103 my $eval_string = "sub $entry (;\$)";
104 $eval_string .= "{
105 my (\$given) = \@_;
106
107 if (\$given) {
108 # available
109 return \$given ~~ \$_->{features}->{$entry};
110 } else {
111 return \$_->{features}->{$entry} };
112 }";
113 eval $eval_string; ## no critic
114 }
115}
116
117
118sub match_feature {
119 my ($self, $free_hosts) = @_;
120 HOST:
121 foreach my $host( @$free_hosts )
122 {
123 # filter out queuebound hosts
124 if ($host->{host}->queuehosts->count){
125 QUEUE_CHECK:
126 {
127 foreach my $queuehost($host->{host}->queuehosts->all) {
128 last QUEUE_CHECK if $queuehost->queue->id == $self->queue->id;
129 }
130 next HOST;
131 }
132 }
133
134 $_ = $host;
135 my $compartment = Safe->new();
136 $compartment->permit(qw(:base_core));
137 $compartment->share(@functions);
138
139 foreach my $this_feature( $self->requested_features->all )
140 {
141 my $success = $compartment->reval($this_feature->feature);
142 print STDERR "Error in TestRequest.fits: ", $@ if $@;
143 next HOST if not $success;
144 }
145 return $host->{host};
146 }
147 return;
148}
149
150
151
# spent 6.01s (43.0ms+5.97) within Tapper::Schema::TestrunDB::Result::TestrunScheduling::fits which was called 297 times, avg 20.2ms/call: # 297 times (43.0ms+5.97s) by Tapper::Schema::TestrunDB::Result::Queue::get_first_fitting at line 56 of Tapper/Schema/TestrunDB/Result/Queue.pm, avg 20.2ms/call
sub fits {
152203328.8ms my ($self, $free_hosts) = @_;
153
154110.4ms17821.89s if (not $free_hosts)
# spent 1.44s making 594 calls to DBIx::Class::ResultSet::count, avg 2.42ms/call # spent 228ms making 297 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::requested_hosts, avg 769µs/call # spent 206ms making 297 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::requested_features, avg 692µs/call # spent 20.8ms making 594 calls to DBIx::Class::Storage::DBI::Cursor::DESTROY, avg 35µs/call
155 {
156 return;
157 }
158 elsif ($self->requested_hosts->count)
159 {
160 my $host = $self->match_host($free_hosts);
161 if ($host)
162 {
163 return $host;
164 }
165 elsif ($self->requested_features->count)
166 {
167 $host = $self->match_feature($free_hosts);
168 return $host if $host;
169 }
170 }
171 elsif ($self->requested_features->count) # but no wanted hostnames
172 {
173 my $host = $self->match_feature($free_hosts);
174 return $host if $host;
175 }
176 else # free_hosts but no wanted hostnames and no requested_features
177 {
178 foreach my $host (map {$_->{host} } @$free_hosts) {
179116.2ms26792.21s if ($host->queuehosts->count){
# spent 1.20s making 496 calls to DBIx::Class::ResultSet::count, avg 2.42ms/call # spent 629ms making 421 calls to DBIx::Class::ResultSet::all, avg 1.50ms/call # spent 365ms making 917 calls to Tapper::Schema::TestrunDB::Result::Host::queuehosts, avg 398µs/call # spent 18.7ms making 845 calls to DBIx::Class::Storage::DBI::Cursor::DESTROY, avg 22µs/call
180 foreach my $queuehost($host->queuehosts->all) {
18116841.90s return $host if $queuehost->queue->id == $self->queue->id;
# spent 1.11s making 421 calls to Tapper::Schema::TestrunDB::Result::QueueHost::queue, avg 2.65ms/call # spent 781ms making 421 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::queue, avg 1.86ms/call # spent 8.46ms making 842 calls to Tapper::Schema::TestrunDB::Result::Queue::id, avg 10µs/call
182 }
183 } else {
184 return $host;
185 }
186
187 }
188 }
189 return;
190}
191
192
193sub mark_as_running
194
# spent 36.1s (10.8ms+36.0) within Tapper::Schema::TestrunDB::Result::TestrunScheduling::mark_as_running which was called 147 times, avg 245ms/call: # 147 times (10.8ms+36.0s) by Tapper::MCP::Scheduler::Controller::mark_job_as_running at line 137 of lib/Tapper/MCP/Scheduler/Controller.pm, avg 245ms/call
{
1958827.92ms my ($self) = @_;
196
1973193µs24.07ms
# spent 4.03ms (3.41+620µs) within Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@197 which was called: # once (3.41ms+620µs) by Tapper::MCP::Scheduler::PrioQueue::BEGIN@1 at line 197
use Data::Dumper;
# spent 4.03ms making 1 call to Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@197 # spent 45µs making 1 call to Exporter::import
198
199 # set scheduling info
20014775.2ms $self->status("running");
# spent 75.2ms making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::status, avg 512µs/call
201294952ms $self->host->free(0);
# spent 906ms making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::host, avg 6.16ms/call # spent 46.1ms making 147 calls to Tapper::Schema::TestrunDB::Result::Host::free, avg 313µs/call
2021478.59ms $self->prioqueue_seq(undef);
# spent 8.59ms making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::prioqueue_seq, avg 58µs/call
203
204 # sync db
20529416.5s $self->host->update;
# spent 16.5s making 147 calls to DBIx::Class::Relationship::CascadeActions::update, avg 112ms/call # spent 823µs making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::host, avg 6µs/call
20614718.5s $self->update;
# spent 18.5s making 147 calls to DBIx::Class::Relationship::CascadeActions::update, avg 126ms/call
207}
208
209
210sub mark_as_finished
211{
212 my ($self) = @_;
213
214365µs246µs
# spent 27µs (9+18) within Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@214 which was called: # once (9µs+18µs) by Tapper::MCP::Scheduler::PrioQueue::BEGIN@1 at line 214
use Data::Dumper;
# spent 27µs making 1 call to Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@214 # spent 18µs making 1 call to Exporter::import
215
216 # set scheduling info
217 $self->status("finished");
218 $self->host->free(1);
219
220 # sync db
221 $self->host->update;
222 $self->update;
223}
224
225141µs1;
226
227__END__
 
# spent 9µs within Tapper::Schema::TestrunDB::Result::TestrunScheduling::CORE:subst which was called: # once (9µs+0s) by Tapper::MCP::Scheduler::PrioQueue::BEGIN@1 at line 34
sub Tapper::Schema::TestrunDB::Result::TestrunScheduling::CORE:subst; # opcode