From 0f24c1129293627507bc75c9463ffe5c8c148aff Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 11 Nov 2008 10:27:36 +0000 Subject: [PATCH] * Perform builds in parallel. * Turn off sqlite's synchronous mode because fsync() performance *really* sucks on ext3 (it syncs the entire filesystem). See https://bugzilla.mozilla.org/show_bug.cgi?id=421482 --- src/HydraFrontend/root/index.tt | 3 ++- src/build.pl | 5 +++++ src/runner.pl | 29 +++++++++++++++++++++++++---- src/scheduler.pl | 8 +++++++- 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/HydraFrontend/root/index.tt b/src/HydraFrontend/root/index.tt index 338e4ad7..882a108f 100644 --- a/src/HydraFrontend/root/index.tt +++ b/src/HydraFrontend/root/index.tt @@ -5,11 +5,12 @@ - + [% FOREACH job IN jobs -%] + diff --git a/src/build.pl b/src/build.pl index cee0ef45..d449f71a 100644 --- a/src/build.pl +++ b/src/build.pl @@ -7,6 +7,8 @@ use HydraFrontend::Schema; my $db = HydraFrontend::Schema->connect("dbi:SQLite:dbname=hydra.sqlite", "", "", {}); +$db->storage->dbh->do("PRAGMA synchronous = OFF;"); + sub isValidPath { my $path = shift; @@ -124,7 +126,10 @@ sub buildJob { } $job->delete; + }); + + print "STOP ", time, "\n"; } diff --git a/src/runner.pl b/src/runner.pl index 9fecd534..7889eb74 100644 --- a/src/runner.pl +++ b/src/runner.pl @@ -1,11 +1,14 @@ #! @perl@ -w use strict; +use POSIX qw(dup2); use HydraFrontend::Schema; my $db = HydraFrontend::Schema->connect("dbi:SQLite:dbname=hydra.sqlite", "", "", {}); +$db->storage->dbh->do("PRAGMA synchronous = OFF;"); + # Unlock jobs whose building process has died. $db->txn_do(sub { @@ -22,8 +25,7 @@ $db->txn_do(sub { }); -while (1) { - +sub checkJobs { print "looking for runnable jobs...\n"; my $job; @@ -46,9 +48,20 @@ while (1) { # Start the job. We need to do this outside the transaction in # case it aborts or something. if (defined $job) { - print "starting job ", $job->id, "\n"; + my $id = $job->id; + print "starting job $id\n"; eval { - system("perl -I HydraFrontend/lib -w ./build.pl " . $job->id); + my $child = fork(); + die unless defined $child; + if ($child == 0) { + open LOG, ">logs/$id" or die; + POSIX::dup2(fileno(LOG), 1) or die; + POSIX::dup2(fileno(LOG), 2) or die; + exec("perl", "-IHydraFrontend/lib", "-w", + "./build.pl", $id); + warn "cannot start job " . $id; + _exit(1); + } }; if ($@) { warn $@; @@ -59,6 +72,14 @@ while (1) { }); } } +} + + +while (1) { + eval { + checkJobs; + }; + warn $@ if $@; print "sleeping...\n"; sleep(10); diff --git a/src/scheduler.pl b/src/scheduler.pl index a3563aad..d1731b9d 100644 --- a/src/scheduler.pl +++ b/src/scheduler.pl @@ -7,6 +7,8 @@ use HydraFrontend::Schema; my $db = HydraFrontend::Schema->connect("dbi:SQLite:dbname=hydra.sqlite", "", "", {}); +$db->storage->dbh->do("PRAGMA synchronous = OFF;"); + sub isValidPath { my $path = shift; @@ -250,4 +252,8 @@ sub checkJobs { } -checkJobs; +while (1) { + checkJobs; + print "sleeping...\n"; + sleep 10; +}
PriorityProjectJobSystemTimestampDescription
#PriorityProjectJobSystemTimestampDescription
[% job.id %] [% job.priority %] [% job.project.name %] [% job.jobset.name %]