Mailinglist Archive: opensuse-buildservice (233 mails)

< Previous Next >
[opensuse-buildservice] [Patch] Display average building time
  • From: "Jan-Simon Möller" <dl9pf@xxxxxx>
  • Date: Wed, 17 Dec 2008 21:47:30 +0100
  • Message-id: <200812172147.31799.dl9pf@xxxxxx>
Hi !

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

Have phun!
Jan-Simon

Index: views/monitor/index.rhtml
===================================================================
--- views/monitor/index.rhtml (Revision 5929)
+++ views/monitor/index.rhtml (Arbeitskopie)
@@ -9,3 +9,4 @@
<%= render :partial => 'idle' %>
<%= render :partial => 'waiting' %>
<%= render :partial => 'blocked' %>
+<%= render :partial => 'average' %>
Index: views/monitor/_average.rhtml
===================================================================
--- views/monitor/_average.rhtml (Revision 0)
+++ views/monitor/_average.rhtml (Revision 0)
@@ -0,0 +1,5 @@
+<br>
+<h2>Average building time</h2>
+<% @workerstatus.each_buildavg.sort {|a,b| a.arch <=> b.arch }.each do |entry|
%>
+ <%= entry.arch %>: <%=
distance_of_time_in_words(Time.at(entry.buildavg.to_i), Time.at(0), true) %>
<br />
+<% end %>
Index: BSXML.pm
===================================================================
--- BSXML.pm (Revision 5929)
+++ BSXML.pm (Arbeitskopie)
@@ -508,6 +508,10 @@
'arch',
'jobs',
]],
+ [[ 'buildavg', =>
+ 'arch',
+ 'buildavg',
+ ]],
[[ 'scheduler' =>
'arch',
'state',
@@ -813,6 +817,7 @@
'packages',
'time',
]],
+ 'buildavg',
'avg',
'variance',
];
Index: bs_repserver
===================================================================
--- bs_repserver (Revision 5929)
+++ bs_repserver (Arbeitskopie)
@@ -724,6 +724,7 @@
my @building;
my @waiting;
my @blocked;
+ my @buildaverage;
my @a;
@a = ls($jobsdir) unless $cgi->{'scheduleronly'};
for my $a (@a) {
@@ -749,11 +750,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));
@@ -783,6 +788,7 @@
$ret->{'building'} = \@building;
$ret->{'waiting'} = \@waiting;
$ret->{'blocked'} = \@blocked;
+ $ret->{'buildavg'} = \@buildaverage;
$ret->{'idle'} = \@idle;
}
$ret->{'scheduler'} = \@scheddata;
Index: bs_sched
===================================================================
--- bs_sched (Revision 5929)
+++ bs_sched (Arbeitskopie)
@@ -84,6 +84,9 @@

my %remoteprojs; # remote project cache

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

delete $status->{'arch'}; # obsolete
@@ -3946,5 +3954,6 @@
$worst->{'time'} = $prpchecktimes{$prp};
push @{$sinfo->{'worst'}}, $worst;
}
+ $sinfo->{'buildavg'} = $buildavg;
writexml("$infodir/.schedulerinfo.$myarch",
"$infodir/schedulerinfo.$myarch", $sinfo, $BSXML::schedulerinfo);
}
< Previous Next >