← 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:39 2012

Filename/2home/ss5/local/projects/Tapper/src/Tapper-MCP/lib/Tapper/MCP/Scheduler/Controller.pm
StatementsExecuted 7851 statements in 146ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1801173.3ms100sTapper::MCP::Scheduler::Controller::::get_next_jobTapper::MCP::Scheduler::Controller::get_next_job
3301120.7ms2.60sTapper::MCP::Scheduler::Controller::::toggle_bandwith_colorTapper::MCP::Scheduler::Controller::toggle_bandwith_color
1471114.8ms54.4sTapper::MCP::Scheduler::Controller::::mark_job_as_runningTapper::MCP::Scheduler::Controller::mark_job_as_running
1112.19ms352msTapper::MCP::Scheduler::Controller::::BEGIN@6Tapper::MCP::Scheduler::Controller::BEGIN@6
1111.55ms41.0msTapper::MCP::Scheduler::Controller::::BEGIN@11Tapper::MCP::Scheduler::Controller::BEGIN@11
111686µs24.0msTapper::MCP::Scheduler::Controller::::BEGIN@8Tapper::MCP::Scheduler::Controller::BEGIN@8
111506µs558µsTapper::MCP::Scheduler::Controller::::BEGIN@5.1Tapper::MCP::Scheduler::Controller::BEGIN@5.1
11147µs605µsTapper::MCP::Scheduler::Controller::::BEGIN@5Tapper::MCP::Scheduler::Controller::BEGIN@5
11121µs138msTapper::MCP::Scheduler::Controller::::BEGIN@10Tapper::MCP::Scheduler::Controller::BEGIN@10
11117µs65.1msTapper::MCP::Scheduler::Controller::::BEGIN@9Tapper::MCP::Scheduler::Controller::BEGIN@9
11112µs249µsTapper::MCP::Scheduler::Controller::::__ANON__[lib/Tapper/MCP/Scheduler/Controller.pm:14]Tapper::MCP::Scheduler::Controller::__ANON__[lib/Tapper/MCP/Scheduler/Controller.pm:14]
11112µs53.9msTapper::MCP::Scheduler::Controller::::BEGIN@7Tapper::MCP::Scheduler::Controller::BEGIN@7
1112µs2µsTapper::MCP::Scheduler::Controller::::__ANON__[lib/Tapper/MCP/Scheduler/Controller.pm:26]Tapper::MCP::Scheduler::Controller::__ANON__[lib/Tapper/MCP/Scheduler/Controller.pm:26]
0000s0sTapper::MCP::Scheduler::Controller::::__ANON__[lib/Tapper/MCP/Scheduler/Controller.pm:22]Tapper::MCP::Scheduler::Controller::__ANON__[lib/Tapper/MCP/Scheduler/Controller.pm:22]
0000s0sTapper::MCP::Scheduler::Controller::::mark_job_as_finishedTapper::MCP::Scheduler::Controller::mark_job_as_finished
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1## no critic (RequireUseStrict)
2package Tapper::MCP::Scheduler::Controller;
3# ABSTRACT: Main class of the scheduler
4
56539µs31.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
use 5.010;
# 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
63116µs2357ms
# 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
use Moose;
# 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]
7350µs2108ms
# 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
use base "Tapper::Base";
# spent 53.9ms making 1 call to Tapper::MCP::Scheduler::Controller::BEGIN@7 # spent 53.8ms making 1 call to base::import
83146µs224.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
use Tapper::Model 'model';
# spent 24.0ms making 1 call to Tapper::MCP::Scheduler::Controller::BEGIN@8 # spent 37µs making 1 call to Exporter::import
93806µs265.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
use aliased 'Tapper::MCP::Scheduler::Algorithm';
# 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
10331µs2138ms
# 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
use aliased 'Tapper::MCP::Scheduler::PrioQueue';
# 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
113826µs141.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
use Tapper::MCP::Net;
# spent 41.0ms making 1 call to Tapper::MCP::Scheduler::Controller::BEGIN@11
12
1313µs12.68ms has hostlist => (is => 'rw', isa => 'ArrayRef');
# spent 2.68ms making 1 call to Moose::has
14219µs22.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
has prioqueue => (is => 'rw', isa => PrioQueue, default => sub { PrioQueue->new });
# 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 }
2316µs12.43ms );
# spent 2.43ms making 1 call to Moose::has
24
2512µs11.89ms has testrun => (is => 'rw');
# spent 1.89ms making 1 call to Moose::has
26212µs12.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
has cfg => (is => 'ro', default => sub {{}});
# spent 2.10ms making 1 call to Moose::has
27
2814µs17.45ms with "Tapper::MCP::Net::TAP";
# spent 7.45ms making 1 call to Moose::with
29
30=head2
31
32Check 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
sub toggle_bandwith_color {
409606.18ms my ($self, $free_hosts, $queue) = @_;
41
4215.92ms9901.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) {
4440211.9ms804543ms 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 {
472011.51ms402349ms 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
482011.76ms603555ms 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
61Pick a testrequest and prepare it for execution. Returns 0 if not testrequest
62fits 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
sub get_next_job {
727202.39ms my ($self, %args) = @_;
73
74 my ($queue, $job);
75
76180593µs do {{
77
78108017.1ms3602.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
82540396ms 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
8412.14ms180481µ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
90223824.7ms14311.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
9395450.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;
95124829.3ms9548.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
96118.3ms58871.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 }
99294647ms 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 }
10732712.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 {
1103303.71ms delete $queues->{$queue->name};
# spent 3.71ms making 330 calls to Tapper::Schema::TestrunDB::Result::Queue::name, avg 11µs/call
1113302.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
11717.06ms366619ms 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
sub mark_job_as_running {
13358810.7ms my ($self, $job) = @_;
134
1351029202ms $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
13614.33ms44118.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
13714736.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
148124µs1; # End of Tapper::MCP::Scheduler::Controller