Make "Running builds" and "Machine status" pages faster

This commit is contained in:
Eelco Dolstra 2016-03-16 15:19:18 +01:00
parent 1de5ce7a0e
commit d5cffd4bc7
3 changed files with 18 additions and 11 deletions

View file

@ -45,7 +45,7 @@ sub begin :Private {
}
if (scalar(@args) == 0 || $args[0] ne "static") {
$c->stash->{nrRunningBuilds} = $c->model('DB')->schema->storage->dbh->selectrow_array(
$c->stash->{nrRunningBuilds} = dbh($c)->selectrow_array(
"select count(distinct build) from buildsteps where busy = 1");
$c->stash->{nrQueuedBuilds} = $c->model('DB::Builds')->search({ finished => 0 })->count();
}
@ -105,7 +105,7 @@ sub queue_summary :Local :Path('queue-summary') :Args(0) {
my ($self, $c) = @_;
$c->stash->{template} = 'queue-summary.tt';
$c->stash->{queued} = $c->model('DB')->schema->storage->dbh->selectall_arrayref(
$c->stash->{queued} = dbh($c)->selectall_arrayref(
"select project, jobset, count(*) as queued, min(timestamp) as oldest, max(timestamp) as newest from Builds " .
"where finished = 0 group by project, jobset order by queued desc",
{ Slice => {} });
@ -119,7 +119,7 @@ sub status_GET {
$self->status_ok(
$c,
entity => [$c->model('DB::Builds')->search(
{ finished => 0, "buildsteps.busy" => 1 },
{ "buildsteps.busy" => 1 },
{ order_by => ["globalpriority DESC", "id"],
join => "buildsteps",
columns => [@buildListColumns]
@ -164,11 +164,11 @@ sub machines :Local Args(0) {
}
$c->stash->{machines} = $machines;
$c->stash->{steps} = [ $c->model('DB::BuildSteps')->search(
{ finished => 0, 'me.busy' => 1, },
{ join => [ 'build' ]
, order_by => [ 'machine', 'stepnr' ]
} ) ];
$c->stash->{steps} = dbh($c)->selectall_arrayref(
"select build, stepnr, s.system as system, s.drvpath as drvpath, machine, s.starttime as starttime, project, jobset, job " .
"from BuildSteps s join Builds b on s.build = b.id " .
"where busy = 1 order by machine, stepnr",
{ Slice => {} });
$c->stash->{template} = 'machine-status.tt';
}

View file

@ -26,6 +26,7 @@ our @EXPORT = qw(
setCacheHeaders
approxTableSize
requireLocalStore
dbh
);
@ -351,4 +352,10 @@ sub requireLocalStore {
}
sub dbh {
my ($c) = @_;
return $c->model('DB')->schema->storage->dbh;
}
1;

View file

@ -39,10 +39,10 @@
[% IF name == name2 %]
[% idle = 0 %]
<tr>
<td><tt>[% INCLUDE renderFullJobNameOfBuild build=step.build %]</tt></td>
<td><tt>[% INCLUDE renderFullJobName project=step.project jobset=step.jobset job=step.job %]</tt></td>
<td><tt>[% step.system %]</tt></td>
<td><a href="[% c.uri_for('/build' step.build.id) %]">[% step.build.id %]</a></td>
<td><a class="row-link" href="[% c.uri_for('/build' step.build.id 'nixlog' step.stepnr 'tail-reload') %]">[% step.stepnr %]</a></td>
<td><a href="[% c.uri_for('/build' step.build) %]">[% step.build %]</a></td>
<td><a class="row-link" href="[% c.uri_for('/build' step.build 'nixlog' step.stepnr 'tail-reload') %]">[% step.stepnr %]</a></td>
<td><tt>[% step.drvpath.match('-(.*)').0 %]</tt></td>
<td style="width: 10em">[% INCLUDE renderDuration duration = curTime - step.starttime %] </td>
</tr>