Filename | /2home/ss5/local/projects/Tapper/src/Tapper-MCP/lib/Tapper/MCP/Scheduler/Controller.pm |
Statements | Executed 7851 statements in 146ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
180 | 1 | 1 | 73.3ms | 100s | get_next_job | Tapper::MCP::Scheduler::Controller::
330 | 1 | 1 | 20.7ms | 2.60s | toggle_bandwith_color | Tapper::MCP::Scheduler::Controller::
147 | 1 | 1 | 14.8ms | 54.4s | mark_job_as_running | Tapper::MCP::Scheduler::Controller::
1 | 1 | 1 | 2.19ms | 352ms | BEGIN@6 | Tapper::MCP::Scheduler::Controller::
1 | 1 | 1 | 1.55ms | 41.0ms | BEGIN@11 | Tapper::MCP::Scheduler::Controller::
1 | 1 | 1 | 686µs | 24.0ms | BEGIN@8 | Tapper::MCP::Scheduler::Controller::
1 | 1 | 1 | 506µs | 558µs | BEGIN@5.1 | Tapper::MCP::Scheduler::Controller::
1 | 1 | 1 | 47µs | 605µs | BEGIN@5 | Tapper::MCP::Scheduler::Controller::
1 | 1 | 1 | 21µs | 138ms | BEGIN@10 | Tapper::MCP::Scheduler::Controller::
1 | 1 | 1 | 17µs | 65.1ms | BEGIN@9 | Tapper::MCP::Scheduler::Controller::
1 | 1 | 1 | 12µs | 249µs | __ANON__[lib/Tapper/MCP/Scheduler/Controller.pm:14] | Tapper::MCP::Scheduler::Controller::
1 | 1 | 1 | 12µs | 53.9ms | BEGIN@7 | Tapper::MCP::Scheduler::Controller::
1 | 1 | 1 | 2µs | 2µs | __ANON__[lib/Tapper/MCP/Scheduler/Controller.pm:26] | Tapper::MCP::Scheduler::Controller::
0 | 0 | 0 | 0s | 0s | __ANON__[lib/Tapper/MCP/Scheduler/Controller.pm:22] | Tapper::MCP::Scheduler::Controller::
0 | 0 | 0 | 0s | 0s | mark_job_as_finished | Tapper::MCP::Scheduler::Controller::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | ## no critic (RequireUseStrict) | ||||
2 | package Tapper::MCP::Scheduler::Controller; | ||||
3 | # ABSTRACT: Main class of the scheduler | ||||
4 | |||||
5 | 6 | 539µs | 3 | 1.21ms | # spent 558µs (506+51) within Tapper::MCP::Scheduler::Controller::BEGIN@5.1 which was called:
# once (506µs+51µs) by Tapper::MCP::Scheduler::Controller::BEGIN@5 at line 5
# spent 605µs (47+558) within Tapper::MCP::Scheduler::Controller::BEGIN@5 which was called:
# once (47µs+558µs) by main::BEGIN@1 at line 5 # spent 605µs making 1 call to Tapper::MCP::Scheduler::Controller::BEGIN@5
# spent 558µs making 1 call to Tapper::MCP::Scheduler::Controller::BEGIN@5.1
# spent 51µs making 1 call to feature::import |
6 | 3 | 116µs | 2 | 357ms | # spent 352ms (2.19+350) within Tapper::MCP::Scheduler::Controller::BEGIN@6 which was called:
# once (2.19ms+350ms) by main::BEGIN@1 at line 6 # spent 352ms making 1 call to Tapper::MCP::Scheduler::Controller::BEGIN@6
# spent 4.89ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:492] |
7 | 3 | 50µs | 2 | 108ms | # spent 53.9ms (12µs+53.8) within Tapper::MCP::Scheduler::Controller::BEGIN@7 which was called:
# once (12µs+53.8ms) by main::BEGIN@1 at line 7 # spent 53.9ms making 1 call to Tapper::MCP::Scheduler::Controller::BEGIN@7
# spent 53.8ms making 1 call to base::import |
8 | 3 | 146µs | 2 | 24.0ms | # spent 24.0ms (686µs+23.3) within Tapper::MCP::Scheduler::Controller::BEGIN@8 which was called:
# once (686µs+23.3ms) by main::BEGIN@1 at line 8 # spent 24.0ms making 1 call to Tapper::MCP::Scheduler::Controller::BEGIN@8
# spent 37µs making 1 call to Exporter::import |
9 | 3 | 806µs | 2 | 65.1ms | # spent 65.1ms (17µs+65.1) within Tapper::MCP::Scheduler::Controller::BEGIN@9 which was called:
# once (17µs+65.1ms) by main::BEGIN@1 at line 9 # spent 65.1ms making 1 call to Tapper::MCP::Scheduler::Controller::BEGIN@9
# spent 65.1ms making 1 call to aliased::import, recursion: max depth 1, sum of overlapping time 65.1ms |
10 | 3 | 31µs | 2 | 138ms | # spent 138ms (21µs+138) within Tapper::MCP::Scheduler::Controller::BEGIN@10 which was called:
# once (21µs+138ms) by main::BEGIN@1 at line 10 # spent 138ms making 1 call to Tapper::MCP::Scheduler::Controller::BEGIN@10
# spent 138ms making 1 call to aliased::import, recursion: max depth 1, sum of overlapping time 138ms |
11 | 3 | 826µs | 1 | 41.0ms | # spent 41.0ms (1.55+39.4) within Tapper::MCP::Scheduler::Controller::BEGIN@11 which was called:
# once (1.55ms+39.4ms) by main::BEGIN@1 at line 11 # spent 41.0ms making 1 call to Tapper::MCP::Scheduler::Controller::BEGIN@11 |
12 | |||||
13 | 1 | 3µs | 1 | 2.68ms | has hostlist => (is => 'rw', isa => 'ArrayRef'); # spent 2.68ms making 1 call to Moose::has |
14 | 2 | 19µs | 2 | 2.46ms | # spent 249µs (12+237) within Tapper::MCP::Scheduler::Controller::__ANON__[lib/Tapper/MCP/Scheduler/Controller.pm:14] which was called:
# once (12µs+237µs) by Class::MOP::Mixin::AttributeCore::default at line 45 of Class/MOP/Mixin/AttributeCore.pm # spent 2.46ms making 1 call to Moose::has
# spent 237µs making 1 call to Moose::Object::new, recursion: max depth 1, sum of overlapping time 237µs |
15 | has algorithm => (is => 'rw', | ||||
16 | isa => 'Tapper::MCP::Scheduler::Algorithm', | ||||
17 | default => sub { | ||||
18 | Algorithm->new_with_traits | ||||
19 | ( | ||||
20 | traits => ['Tapper::MCP::Scheduler::Algorithm::WFQ'] | ||||
21 | ); | ||||
22 | } | ||||
23 | 1 | 6µs | 1 | 2.43ms | ); # spent 2.43ms making 1 call to Moose::has |
24 | |||||
25 | 1 | 2µs | 1 | 1.89ms | has testrun => (is => 'rw'); # spent 1.89ms making 1 call to Moose::has |
26 | 2 | 12µs | 1 | 2.10ms | # spent 2µs within Tapper::MCP::Scheduler::Controller::__ANON__[lib/Tapper/MCP/Scheduler/Controller.pm:26] which was called:
# once (2µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 45 of Class/MOP/Mixin/AttributeCore.pm # spent 2.10ms making 1 call to Moose::has |
27 | |||||
28 | 1 | 4µs | 1 | 7.45ms | with "Tapper::MCP::Net::TAP"; # spent 7.45ms making 1 call to Moose::with |
29 | |||||
30 | =head2 | ||||
31 | |||||
32 | Check whether we need to change from scheduling white bandwidth to black bandwidth. | ||||
33 | |||||
34 | @return black - 1 | ||||
35 | @return white - 0 | ||||
36 | |||||
37 | =cut | ||||
38 | |||||
39 | # spent 2.60s (20.7ms+2.58) within Tapper::MCP::Scheduler::Controller::toggle_bandwith_color which was called 330 times, avg 7.88ms/call:
# 330 times (20.7ms+2.58s) by Tapper::MCP::Scheduler::Controller::get_next_job at line 111, avg 7.88ms/call | ||||
40 | 960 | 6.18ms | my ($self, $free_hosts, $queue) = @_; | ||
41 | |||||
42 | 1 | 5.92ms | 990 | 1.15s | return 0 if $queue->queued_testruns->count == 0; # spent 1.01s making 330 calls to DBIx::Class::ResultSet::count, avg 3.05ms/call
# spent 132ms making 330 calls to Tapper::Schema::TestrunDB::Result::Queue::queued_testruns, avg 400µs/call
# spent 11.9ms making 330 calls to DBIx::Class::Storage::DBI::Cursor::DESTROY, avg 36µs/call |
43 | foreach my $free_host( map {$_->{host} } @$free_hosts) { | ||||
44 | 402 | 11.9ms | 804 | 543ms | if ($free_host->queuehosts->count){ # spent 487ms making 201 calls to DBIx::Class::ResultSet::count, avg 2.42ms/call
# spent 49.0ms making 201 calls to Tapper::Schema::TestrunDB::Result::Host::queuehosts, avg 244µs/call
# spent 7.82ms making 402 calls to DBIx::Class::Storage::DBI::Cursor::DESTROY, avg 19µs/call |
45 | QUEUE_CHECK: | ||||
46 | { | ||||
47 | 201 | 1.51ms | 402 | 349ms | foreach my $queuehost($free_host->queuehosts->all) { # spent 301ms making 201 calls to DBIx::Class::ResultSet::all, avg 1.50ms/call
# spent 48.3ms making 201 calls to Tapper::Schema::TestrunDB::Result::Host::queuehosts, avg 240µs/call |
48 | 201 | 1.76ms | 603 | 555ms | return 0 if $queuehost->queue->id == $queue->id; # spent 552ms making 201 calls to Tapper::Schema::TestrunDB::Result::QueueHost::queue, avg 2.75ms/call
# spent 3.16ms making 402 calls to Tapper::Schema::TestrunDB::Result::Queue::id, avg 8µs/call |
49 | } | ||||
50 | } | ||||
51 | } else { | ||||
52 | return 0; | ||||
53 | } | ||||
54 | } | ||||
55 | return 1; | ||||
56 | } | ||||
57 | |||||
58 | |||||
59 | =head2 get_next_job | ||||
60 | |||||
61 | Pick a testrequest and prepare it for execution. Returns 0 if not testrequest | ||||
62 | fits any of the free hosts. | ||||
63 | |||||
64 | @param ArrayRef - array of host objects associated to hosts with no current test | ||||
65 | |||||
66 | @return success - job object | ||||
67 | @return no job - 0 | ||||
68 | |||||
69 | =cut | ||||
70 | |||||
71 | # spent 100s (73.3ms+100) within Tapper::MCP::Scheduler::Controller::get_next_job which was called 180 times, avg 557ms/call:
# 180 times (73.3ms+100s) by main::RUNTIME at line 73 of xt/tapper-mcp-scheduler-with-db-longrun.t, avg 557ms/call | ||||
72 | 720 | 2.39ms | my ($self, %args) = @_; | ||
73 | |||||
74 | my ($queue, $job); | ||||
75 | |||||
76 | 180 | 593µs | do {{ | ||
77 | |||||
78 | 1080 | 17.1ms | 360 | 2.77s | my $free_hosts = Tapper::Model::free_hosts_with_features(); # spent 2.77s making 180 calls to Tapper::Model::free_hosts_with_features, avg 15.4ms/call
# spent 445µs making 180 calls to DBIx::Class::Storage::DBI::Cursor::DESTROY, avg 2µs/call |
79 | return if not ($free_hosts and @$free_hosts); | ||||
80 | |||||
81 | |||||
82 | 540 | 396ms | my $queues = model('TestrunDB')->resultset('Queue')->official_queuelist(); # spent 355ms making 180 calls to Tapper::Schema::TestrunDB::ResultSet::Queue::official_queuelist, avg 1.97ms/call
# spent 40.2ms making 180 calls to DBIx::Class::Schema::resultset, avg 224µs/call
# spent 1.05ms making 180 calls to Memoize::__ANON__[(eval 256)[Memoize.pm:71]:1], avg 6µs/call | ||
83 | |||||
84 | 1 | 2.14ms | 180 | 481µs | my $white_bandwith=1; # chosen queue was first choice # spent 481µs making 180 calls to DBIx::Class::Storage::DBI::Cursor::DESTROY, avg 3µs/call |
85 | |||||
86 | QUEUE: | ||||
87 | while (1) { | ||||
88 | # ask prioqueue everytime when in loop because new priority jobs | ||||
89 | # that got into DB between to loop runs still have highest priority | ||||
90 | 2238 | 24.7ms | 1431 | 1.26s | last QUEUE if $job = $self->prioqueue->get_first_fitting($free_hosts); # spent 1.25s making 477 calls to Tapper::MCP::Scheduler::PrioQueue::get_first_fitting, avg 2.63ms/call
# spent 1.90ms making 477 calls to Tapper::MCP::Scheduler::Controller::prioqueue, avg 4µs/call
# spent 1.83ms making 477 calls to DBIx::Class::Storage::DBI::Cursor::DESTROY, avg 4µs/call |
91 | |||||
92 | |||||
93 | 954 | 50.4ms | my $queue = $self->algorithm->lookup_next_queue($queues); # spent 48.1ms making 477 calls to Tapper::MCP::Scheduler::Algorithm::WFQ::lookup_next_queue, avg 101µs/call
# spent 2.33ms making 477 calls to Tapper::MCP::Scheduler::Controller::algorithm, avg 5µs/call | ||
94 | return () unless $queue; | ||||
95 | 1248 | 29.3ms | 954 | 8.32s | if ($job = $queue->get_first_fitting($free_hosts)) { # spent 8.31s making 477 calls to Tapper::Schema::TestrunDB::Result::Queue::get_first_fitting, avg 17.4ms/call
# spent 1.91ms making 477 calls to DBIx::Class::Storage::DBI::Cursor::DESTROY, avg 4µs/call |
96 | 1 | 18.3ms | 588 | 71.4s | if ($job->auto_rerun) { # spent 71.4s making 147 calls to Tapper::Schema::TestrunDB::Result::Testrun::rerun, avg 486ms/call
# spent 1.98ms making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::auto_rerun, avg 13µs/call
# spent 1.77ms making 147 calls to DBIx::Class::Storage::DBI::Cursor::DESTROY, avg 12µs/call
# spent 642µs making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::testrun, avg 4µs/call |
97 | $job->testrun->rerun; | ||||
98 | } | ||||
99 | 294 | 647ms | if ($job->testrun->scenario_element) { # spent 645ms making 147 calls to Tapper::Schema::TestrunDB::Result::Testrun::scenario_element, avg 4.39ms/call
# spent 1.67ms making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::testrun, avg 11µs/call | ||
100 | ELEMENT: | ||||
101 | foreach my $element ($job->testrun->scenario_element->peer_elements) { | ||||
102 | my $peer_job = $element->testrun->testrun_scheduling; | ||||
103 | next ELEMENT if $peer_job->id == $job->id; | ||||
104 | $self->prioqueue->add($peer_job); | ||||
105 | } | ||||
106 | } | ||||
107 | 327 | 12.0s | $self->algorithm->update_queue($job->queue) if $white_bandwith; # spent 12.0s making 109 calls to Tapper::MCP::Scheduler::Algorithm::WFQ::update_queue, avg 110ms/call
# spent 965µs making 109 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::queue, avg 9µs/call
# spent 893µs making 109 calls to Tapper::MCP::Scheduler::Controller::algorithm, avg 8µs/call | ||
108 | last QUEUE; | ||||
109 | } else { | ||||
110 | 330 | 3.71ms | delete $queues->{$queue->name}; # spent 3.71ms making 330 calls to Tapper::Schema::TestrunDB::Result::Queue::name, avg 11µs/call | ||
111 | 330 | 2.60s | $white_bandwith=0 if $self->toggle_bandwith_color($free_hosts, $queue); # spent 2.60s making 330 calls to Tapper::MCP::Scheduler::Controller::toggle_bandwith_color, avg 7.88ms/call | ||
112 | |||||
113 | } | ||||
114 | last QUEUE if not %$queues; | ||||
115 | } | ||||
116 | |||||
117 | 1 | 7.06ms | 366 | 619ms | if ($job and $job->testrun->scenario_element) { # spent 616ms making 147 calls to Tapper::Schema::TestrunDB::Result::Testrun::scenario_element, avg 4.19ms/call
# spent 1.74ms making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::testrun, avg 12µs/call
# spent 606µs making 72 calls to DBIx::Class::Storage::DBI::Cursor::DESTROY, avg 8µs/call |
118 | $self->mark_job_as_running($job); | ||||
119 | if ($job->testrun->scenario_element->peers_need_fitting > 0) { | ||||
120 | # do not return this job already | ||||
121 | $job = undef; | ||||
122 | next; | ||||
123 | } else { | ||||
124 | return map{$_->testrun->testrun_scheduling} $job->testrun->scenario_element->peer_elements->all; | ||||
125 | } | ||||
126 | } | ||||
127 | }} while (not $job and $args{try_until_found}); | ||||
128 | |||||
129 | return $job || () ; | ||||
130 | } | ||||
131 | |||||
132 | # spent 54.4s (14.8ms+54.4) within Tapper::MCP::Scheduler::Controller::mark_job_as_running which was called 147 times, avg 370ms/call:
# 147 times (14.8ms+54.4s) by main::RUNTIME at line 78 of xt/tapper-mcp-scheduler-with-db-longrun.t, avg 370ms/call | ||||
133 | 588 | 10.7ms | my ($self, $job) = @_; | ||
134 | |||||
135 | 1029 | 202ms | $job->testrun->starttime_testrun(model('TestrunDB')->storage->datetime_parser->format_datetime(DateTime->now)); # spent 110ms making 147 calls to DateTime::now, avg 749µs/call
# spent 41.8ms making 147 calls to Tapper::Schema::TestrunDB::Result::Testrun::starttime_testrun, avg 285µs/call
# spent 41.1ms making 147 calls to DateTime::Format::SQLite::format_datetime, avg 280µs/call
# spent 5.92ms making 147 calls to DBIx::Class::Schema::storage, avg 40µs/call
# spent 1.51ms making 147 calls to Memoize::__ANON__[(eval 256)[Memoize.pm:71]:1], avg 10µs/call
# spent 967µs making 147 calls to DBIx::Class::Storage::DBI::datetime_parser, avg 7µs/call
# spent 752µs making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::testrun, avg 5µs/call | ||
136 | 1 | 4.33ms | 441 | 18.1s | $job->testrun->update(); # spent 18.1s making 147 calls to DBIx::Class::Relationship::CascadeActions::update, avg 123ms/call
# spent 2.44ms making 147 calls to DBIx::Class::Storage::TxnScopeGuard::DESTROY, avg 17µs/call
# spent 907µs making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::testrun, avg 6µs/call |
137 | 147 | 36.1s | $job->mark_as_running; # spent 36.1s making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::mark_as_running, avg 245ms/call | ||
138 | } | ||||
139 | |||||
140 | sub mark_job_as_finished { | ||||
141 | my ($self, $job) = @_; | ||||
142 | |||||
143 | $job->testrun->endtime_test_program(model('TestrunDB')->storage->datetime_parser->format_datetime(DateTime->now)); | ||||
144 | $job->testrun->update(); | ||||
145 | $job->mark_as_finished; | ||||
146 | } | ||||
147 | |||||
148 | 1 | 24µs | 1; # End of Tapper::MCP::Scheduler::Controller |