Permalink
Browse files

Cache the results of log parsing.

Greatly speeds up generating the index.cgi and rss.cgi output after the
first time.
  • Loading branch information...
1 parent b499328 commit 312dbc993a1b71f15325d6d7be8748eb77e90fdc @apenwarr committed Oct 29, 2008
Showing with 57 additions and 36 deletions.
  1. +2 −1 autobuilder.sh
  2. +41 −4 out/Autobuilder.pm
  3. +6 −12 out/changelog.pl
  4. +6 −17 out/index.cgi
  5. +2 −2 out/rss.cgi
View
@@ -27,7 +27,8 @@ if [ ! -x build.sh ]; then
exit 1
fi
-mkdir -p out/pass out/fail out/ignore
+mkdir -p out/pass out/fail out/ignore out/errcache
+chmod a+w out/errcache
did_something=1
while [ -n "$did_something" ]; do
View
@@ -51,7 +51,7 @@ sub commitlink($$)
}
my $err_tail = "";
-sub find_errors($)
+sub _find_errors($)
{
my $filename = shift;
my $out = "";
@@ -119,7 +119,11 @@ sub find_errors($)
push @msg, "Warnings($warnings)";
}
if ($errors || ($overallfail && !$testsfailed)) {
- push @msg, "Errors($errors)";
+ if ($errors > 0) {
+ push @msg, "Errors($errors)";
+ } else {
+ push @msg, "Errors";
+ }
}
if ($testsfailed) {
push @msg, "Failures($testsfailed)";
@@ -130,10 +134,43 @@ sub find_errors($)
return join("/", @msg), $out;
}
-sub squish_log($)
+sub age($)
{
my $filename = shift;
- my ($msg, $out) = find_errors($filename);
+ return -M $filename;
+}
+
+sub find_errors($)
+{
+ my $rev = shift;
+ my $fn;
+
+ if (-e "pass/$rev") {
+ $fn = "pass/$rev";
+ } elsif (-e "fail/$rev") {
+ $fn = "fail/$rev";
+ } else {
+ return undef, undef;
+ }
+
+ if (-r "errcache/$rev" && age("errcache/$rev") < age($fn)) {
+ return _find_errors("errcache/$rev");
+ } else {
+ my ($warnmsg, $errs) = _find_errors($fn);
+ if (defined($warnmsg)) {
+ mkdir "errcache";
+ open my $outf, ">errcache/$rev";
+ print $outf $errs;
+ close $outf;
+ }
+ return $warnmsg, $errs;
+ }
+}
+
+sub squish_log($)
+{
+ my $rev = shift;
+ my ($msg, $out) = find_errors($rev);
return $out . $err_tail;
}
View
@@ -117,26 +117,20 @@ (@)
$filenames .= "<p>";
}
- my $abstatus = "";
- if (-f "fail/$rev") {
- $abstatus = "Errors";
- } elsif (-f "pass/$rev") {
- my ($warnmsg, $errs) = find_errors("pass/$rev");
- $abstatus = $warnmsg;
- }
- if ($abstatus) {
+ my ($warnmsg, $errs) = find_errors($rev);
+ if ($warnmsg) {
my $aburl = autobuilder_url();
- $abstatus = sprintf("(Autobuilder: %s)<br>",
- $aburl ? "<a href='$aburl/log.cgi?log=$rev'>$abstatus</a>"
- : $abstatus);
+ $warnmsg = sprintf("(Autobuilder: %s)<br>",
+ $aburl ? "<a href='$aburl/log.cgi?log=$rev'>$warnmsg</a>"
+ : $warnmsg);
}
push @out, qq{
<div>
<span class='svtitle'>$commitlink by <b>$who</b></span>
<span class='svdate'>$date</span>
<ul>
- <div class='svcommentary'>$abstatus$filenames</div>
+ <div class='svcommentary'>$warnmsg$filenames</div>
<div class='svtext'>$log</div>
</ul>
</div>
View
@@ -132,7 +132,9 @@ sub fixbranchprint($)
sub status_to_statcode($)
{
my $status = shift;
- if ($status eq "ok") {
+ if (!defined($status)) {
+ return "pending";
+ } elsif ($status eq "ok") {
return "ok";
} elsif ($status eq "BUILDING") {
return "pending";
@@ -156,18 +158,8 @@ for my $bpb (sort { branch_age($a) <=> branch_age($b) } @branchlist) {
next if (-f "ignore/$topcommit");
- if (-f "fail/$topcommit") {
- $fn = "fail/$topcommit";
- } elsif (-f "pass/$topcommit") {
- $fn = "pass/$topcommit";
- }
- my $statcode;
- if ($fn) {
- my ($warnmsg, $errs) = find_errors($fn);
- $statcode = status_to_statcode($warnmsg);
- } else {
- $statcode = "pending";
- }
+ my ($warnmsg, $errs) = find_errors($topcommit);
+ my $statcode = status_to_statcode($warnmsg);
print li(a({href=>"#$branch"},
span({class=>"status branch status-$statcode"}, $branchprint)));
@@ -214,7 +206,6 @@ for my $bpb (sort { lc($a) cmp lc($b) } @branchlist) {
foreach my $rev (revs_for_branch($branch)) {
my ($commit, $email, $comment) = split(" ", $rev, 3);
- my $filename;
my $failed;
my $logcgi = "log.cgi?log=$commit";
$email =~ s/\@.*//;
@@ -246,11 +237,9 @@ for my $bpb (sort { lc($a) cmp lc($b) } @branchlist) {
}
if (-f "pass/$commit") {
- $filename = "pass/$commit";
$failed = 0;
# fall through
} elsif (-f "fail/$commit") {
- $filename = "fail/$commit";
$failed = 1;
# fall through
} elsif ($commit eq $currently_doing) {
@@ -270,7 +259,7 @@ for my $bpb (sort { lc($a) cmp lc($b) } @branchlist) {
next;
}
- my ($warnmsg, $errs) = find_errors($filename);
+ my ($warnmsg, $errs) = find_errors($commit);
my $status = ($warnmsg eq "ok") ? "ok"
: ($warnmsg =~ /^Warnings\(\d+\)$/) ? "Warn" : "FAIL";
pushrow(@branchout, $status,
View
@@ -54,11 +54,11 @@ for my $path (sort { mtime($b) cmp mtime($a) } @all) {
next;
}
- my ($warnmsg, $errs) = find_errors($filename);
+ my ($warnmsg, $errs) = find_errors($commit);
my $codestr = $warnmsg;
$codestr =~ s/([A-Z])[a-z]*/$1/g;
- my $longstr = "$warnmsg: $commit<p>\n\n" . squish_log($filename);
+ my $longstr = "$warnmsg: $commit<p>\n\n" . squish_log($commit);
$longstr =~ s/\&/\&amp;/g;
$longstr =~ s/</&lt;/g;

0 comments on commit 312dbc9

Please sign in to comment.