Mailinglist Archive: opensuse-buildservice (250 mails)

< Previous Next >
[opensuse-buildservice] [PATCH] Display average building time on obs monitor page
  • From: "Jan-Simon Möller" <dl9pf@xxxxxx>
  • Date: Mon, 27 Apr 2009 03:54:44 +0200
  • Message-id: <200904270354.45378.dl9pf@xxxxxx>
Hi !

The attached patches display the average time needed to build a package per
arch below the "Blocked Queue" on the monitor page.
It uses exponential smoothing (smoothing factor 0.3) to calculate the average.

Have phun!
Jan-Simon

Index: src/backend/BSXML.pm
===================================================================
--- src/backend/BSXML.pm (Revision 7191)
+++ src/backend/BSXML.pm (Arbeitskopie)
@@ -515,6 +515,10 @@
'arch',
'jobs',
]],
+ [[ 'buildavg', =>
+ 'arch',
+ 'buildavg',
+ ]],
[[ 'scheduler' =>
'arch',
'state',
@@ -821,6 +825,7 @@
'packages',
'time',
]],
+ 'buildavg',
'avg',
'variance',
];
Index: src/backend/bs_repserver
===================================================================
--- src/backend/bs_repserver (Revision 7191)
+++ src/backend/bs_repserver (Arbeitskopie)
@@ -726,6 +726,7 @@
my @building;
my @waiting;
my @blocked;
+ my @buildaverage;
my @a;
@a = ls($jobsdir) unless $cgi->{'scheduleronly'};
for my $a (@a) {
@@ -751,11 +752,15 @@
if ($si && defined($si->{'notready'})) {
push @blocked, {'arch' => $a, 'jobs' => $si->{'notready'}};
}
+ if ($si && defined($si->{'buildavg'})) {
+ push @buildaverage, {'arch' => $a, 'buildavg' => $si->{'buildavg'}};
+ }
}
@idle = sort {$a->{'workerid'} cmp $b->{'workerid'} || $a->{'uri'} cmp
$b->{'uri'} || $a cmp $b} @idle;
@building = sort {$a->{'workerid'} cmp $b->{'workerid'} || $a->{'uri'} cmp
$b->{'uri'} || $a cmp $b} @building;
@waiting = sort {$a->{'arch'} cmp $b->{'arch'} || $a cmp $b} @waiting;
@blocked = sort {$a->{'arch'} cmp $b->{'arch'} || $a cmp $b} @blocked;
+ @buildaverage = sort {$a->{'arch'} cmp $b->{'arch'} || $a cmp $b}
@buildaverage;

my @scheddata;
my @schedarchs = grep {s/^bs_sched\.(.*)\.lock$/$1/} sort(ls($rundir));
@@ -785,6 +790,7 @@
$ret->{'building'} = \@building;
$ret->{'waiting'} = \@waiting;
$ret->{'blocked'} = \@blocked;
+ $ret->{'buildavg'} = \@buildaverage;
$ret->{'idle'} = \@idle;
}
$ret->{'scheduler'} = \@scheddata;
Index: src/backend/bs_sched
===================================================================
--- src/backend/bs_sched (Revision 7191)
+++ src/backend/bs_sched (Arbeitskopie)
@@ -88,6 +88,9 @@
# Create directory on first start
mkdir_p($infodir) || die ("Failed to create ".$infodir);

+my $buildavg = 0;
+
+
sub unify {
my %h = map {$_ => 1} @_;
return grep(delete($h{$_}), @_);
@@ -1761,6 +1764,11 @@
print " - $job is outdated\n";
return;
}
+ # calculate exponential weighted average
+ my $myjobtime = time() - $status->{'readytime'};
+ my $weight = 0.3;
+ $buildavg = ($weight * $myjobtime) + ((1 - $weight) * $buildavg);
+
delete $status->{'job'}; # no longer building

delete $status->{'arch'}; # obsolete
@@ -4159,5 +4167,6 @@
$worst->{'time'} = $prpchecktimes{$prp};
push @{$sinfo->{'worst'}}, $worst;
}
+ $sinfo->{'buildavg'} = $buildavg;
writexml("$infodir/.schedulerinfo.$myarch",
"$infodir/schedulerinfo.$myarch", $sinfo, $BSXML::schedulerinfo);
}
Index: src/webclient/app/views/monitor/index.rhtml
===================================================================
--- src/webclient/app/views/monitor/index.rhtml (Revision 7191)
+++ src/webclient/app/views/monitor/index.rhtml (Arbeitskopie)
@@ -9,3 +9,4 @@
<%= render :partial => 'idle' %>
<%= render :partial => 'waiting' %>
<%= render :partial => 'blocked' %>
+<%= render :partial => 'average' %>
< Previous Next >
Follow Ups