Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Tapper/Schema/TestrunDB/Result/TestrunScheduling.pm |
Statements | Executed 2954 statements in 64.9ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
297 | 1 | 1 | 43.0ms | 6.01s | fits | Tapper::Schema::TestrunDB::Result::TestrunScheduling::
147 | 1 | 1 | 10.8ms | 36.1s | mark_as_running | Tapper::Schema::TestrunDB::Result::TestrunScheduling::
1 | 1 | 1 | 3.41ms | 4.03ms | BEGIN@197 | Tapper::Schema::TestrunDB::Result::TestrunScheduling::
1 | 1 | 1 | 1.95ms | 58.0ms | BEGIN@12 | Tapper::Schema::TestrunDB::Result::TestrunScheduling::
1 | 1 | 1 | 49µs | 1.91ms | gen_schema_functions | Tapper::Schema::TestrunDB::Result::TestrunScheduling::
1 | 1 | 1 | 17µs | 34µs | BEGIN@13 | Tapper::Schema::TestrunDB::Result::TestrunScheduling::
1 | 1 | 1 | 14µs | 59µs | BEGIN@11 | Tapper::Schema::TestrunDB::Result::TestrunScheduling::
1 | 1 | 1 | 11µs | 10.5ms | BEGIN@15 | Tapper::Schema::TestrunDB::Result::TestrunScheduling::
1 | 1 | 1 | 10µs | 27µs | BEGIN@52 | Tapper::Schema::TestrunDB::Result::TestrunScheduling::
1 | 1 | 1 | 10µs | 10µs | BEGIN@4 | Tapper::Schema::TestrunDB::Result::TestrunScheduling::
1 | 1 | 1 | 9µs | 27µs | BEGIN@214 | Tapper::Schema::TestrunDB::Result::TestrunScheduling::
1 | 1 | 1 | 9µs | 9µs | CORE:subst (opcode) | Tapper::Schema::TestrunDB::Result::TestrunScheduling::
0 | 0 | 0 | 0s | 0s | hostname | Tapper::Schema::TestrunDB::Result::TestrunScheduling::
0 | 0 | 0 | 0s | 0s | mark_as_finished | Tapper::Schema::TestrunDB::Result::TestrunScheduling::
0 | 0 | 0 | 0s | 0s | match_feature | Tapper::Schema::TestrunDB::Result::TestrunScheduling::
0 | 0 | 0 | 0s | 0s | match_host | Tapper::Schema::TestrunDB::Result::TestrunScheduling::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # TODO: rename into "(Scheduler|Result)::Job"? | ||||
2 | |||||
3 | package 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 | ||||
5 | 1 | 5µs | $Tapper::Schema::TestrunDB::Result::TestrunScheduling::AUTHORITY = 'cpan:AMD'; | ||
6 | 1 | 25µs | 1 | 10µs | } # spent 10µs making 1 call to Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@4 |
7 | { | ||||
8 | 2 | 1µs | $Tapper::Schema::TestrunDB::Result::TestrunScheduling::VERSION = '0.001'; | ||
9 | } | ||||
10 | |||||
11 | 3 | 25µs | 2 | 105µ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 # spent 59µs making 1 call to Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@11
# spent 45µs making 1 call to Exporter::import |
12 | 3 | 136µs | 1 | 58.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 # spent 58.0ms making 1 call to Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@12 |
13 | 3 | 30µs | 2 | 51µ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 # 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) | ||||
15 | 3 | 237µs | 2 | 21.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 # spent 10.5ms making 1 call to Tapper::Schema::TestrunDB::Result::TestrunScheduling::BEGIN@15
# spent 10.5ms making 1 call to parent::import |
16 | |||||
17 | 1 | 15µs | 1 | 51.7ms | __PACKAGE__->load_components("InflateColumn::Object::Enum", "Core"); # spent 51.7ms making 1 call to Class::C3::Componentised::load_components |
18 | 1 | 15µs | 1 | 763µs | __PACKAGE__->table("testrun_scheduling"); # spent 763µs making 1 call to DBIx::Class::ResultSourceProxy::Table::table |
19 | 1 | 47µs | 1 | 2.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 | |||||
32 | 1 | 16µs | 1 | 325µs | __PACKAGE__->set_primary_key(qw/id/); # spent 325µs making 1 call to DBIx::Class::ResultSourceProxy::set_primary_key |
33 | |||||
34 | 1 | 14µs | 1 | 9µs | (my $basepkg = __PACKAGE__) =~ s/::\w+$//; # spent 9µs making 1 call to Tapper::Schema::TestrunDB::Result::TestrunScheduling::CORE:subst |
35 | |||||
36 | 1 | 17µs | 1 | 381µ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 |
37 | 1 | 3µs | 1 | 137µ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 |
38 | 1 | 3µs | 1 | 125µ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 | |||||
40 | 1 | 13µs | 1 | 109µ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 |
41 | 1 | 4µs | 1 | 99µ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 | |||||
47 | sub match_host { | ||||
48 | my ($self, $free_hosts) = @_; | ||||
49 | |||||
50 | foreach my $req_host ($self->requested_hosts->all) | ||||
51 | { | ||||
52 | 3 | 638µs | 2 | 44µ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 # 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 | |||||
70 | 1 | 1µs | our @functions = ('&hostname'); | ||
71 | |||||
72 | |||||
73 | sub 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 | |||||
86 | sub 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 | ||||
91 | 1 | 900ns | my ($self) = @_; | ||
92 | |||||
93 | 1 | 17µs | 4 | 400µ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 | }); | ||||
100 | 1 | 10µs | 1 | 1.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 | |||||
118 | sub 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 | ||||
152 | 297 | 321µs | my ($self, $free_hosts) = @_; | ||
153 | |||||
154 | 297 | 18.1ms | 1782 | 1.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 | 297 | 1.06ms | foreach my $host (map {$_->{host} } @$free_hosts) { | ||
179 | 496 | 29.0ms | 2679 | 2.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) { | ||||
181 | 421 | 5.80ms | 1684 | 1.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 | 75 | 446µs | return $host; | ||
185 | } | ||||
186 | |||||
187 | } | ||||
188 | } | ||||
189 | 150 | 679µs | return; | ||
190 | } | ||||
191 | |||||
192 | |||||
193 | sub 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 | ||||
195 | 147 | 469µs | my ($self) = @_; | ||
196 | |||||
197 | 3 | 193µs | 2 | 4.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 # 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 | ||||
200 | 147 | 874µs | 147 | 75.2ms | $self->status("running"); # spent 75.2ms making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::status, avg 512µs/call |
201 | 147 | 1.54ms | 294 | 952ms | $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 |
202 | 147 | 837µs | 147 | 8.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 | ||||
205 | 147 | 1.36ms | 294 | 16.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 |
206 | 147 | 2.84ms | 147 | 18.5s | $self->update; # spent 18.5s making 147 calls to DBIx::Class::Relationship::CascadeActions::update, avg 126ms/call |
207 | } | ||||
208 | |||||
209 | |||||
210 | sub mark_as_finished | ||||
211 | { | ||||
212 | my ($self) = @_; | ||||
213 | |||||
214 | 3 | 65µs | 2 | 46µ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 # 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 | |||||
225 | 1 | 41µs | 1; | ||
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 |