Commit 11d792e3 authored by Leigh Stoller's avatar Leigh Stoller

Change the prerender code to run in the background so that Mike does

not have to wait 3 minutes for it to finish before he can watch his
experiment swapin fail for some other reason.

I adopted the same pid mechanism as in eventsys_control.in, which uses
a slot in the experiments table.

Running "prerender" puts the render into the background and stores
the pid. Running "prerender -r" kills a running prerender and removes
the existing info from the DB.

Fixed the problem with swapmod not restoring the old vis; swapmod now
kills any running prerender, and restarts one if the swapmod fails
(the prerun of the new NS file starts up another prerender in the
background).

Add setpriority() call in prerender to nice it and children to 15.
parent d44a0a58
......@@ -263,6 +263,7 @@ CREATE TABLE experiments (
canceled tinyint(4) NOT NULL default '0',
batchstate varchar(12) default NULL,
event_sched_pid int(11) default '0',
prerender_pid int(11) default '0',
uselinkdelays tinyint(4) NOT NULL default '0',
forcelinkdelays tinyint(4) NOT NULL default '0',
multiplex_factor smallint(5) default NULL,
......
......@@ -827,3 +827,10 @@ last_net_act,last_cpu_act,last_ext_act);
I contemplated putting this into the nodes table instead, but a
node has no role when its not reserved, so it seemed like the
wrong place for it.
1.169: Add a prerender pid so that it can run in the background, but
be killed if the experiment fails, terminates, or modifies.
alter table experiments add prerender_pid int(11) default '0' \
after event_sched_pid;
......@@ -59,7 +59,7 @@ my $action;
#
# Untaint the path
#
$ENV{'PATH'} = '/bin:/usr/bin';
$ENV{'PATH'} = "/bin:/usr/bin:$TB/libexec/vis";
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
#
......@@ -470,6 +470,9 @@ elsif ($inout eq "modify") {
fatal("*** $0:\n".
" Could not backup experiment state; cannot safely continue!\n");
}
# Must deal with the prerender explicitly since it runs background.
system("prerender -r $pid $eid");
TBExptRemoveVirtualState($pid, $eid);
#
......@@ -512,8 +515,13 @@ elsif ($inout eq "modify") {
print STDERR "*** $0:\n".
" $modifyError\n";
print STDOUT "Recovering experiment state...\n";
# Must deal with the prerender explicitly since it runs background.
system("prerender -r $pid $eid");
TBExptRemoveVirtualState($pid, $eid );
if (0 == TBExptRestoreVirtualState($pid, $eid, $$)) {
# Must deal with the prerender explicitly since it runs background.
system("prerender -t $pid $eid");
fatal("*** Update aborted; old state restored.\n");
} else {
# Set state to NEW so experiment will get wiped.
......
......@@ -86,8 +86,9 @@ if (! SetExpState($pid, $eid, EXPTSTATE_TERMINATING)) {
print "Clearing out virtual state.\n";
$errors += TBExptRemoveVirtualState( $pid, $eid );
# This will kill a running prerender.
print "Removing visualization data...\n";
system("prerender -r -t $pid $eid");
system("prerender -r $pid $eid");
if ($errors == 0) {
SetExpState($pid, $eid, EXPTSTATE_TERMINATED) or
......
......@@ -107,6 +107,9 @@ if (! $modify) {
sub cleanup {
if (! $modify) {
print STDERR "Cleaning up after errors.\n";
# Must kill the prerender process first!
system("prerender -r $pid $eid");
print "Removing experiment state ... " . TBTimeStamp() . "\n";
TBExptRemoveVirtualState($pid, $eid );
print "Removal done! " . TBTimeStamp() . "\n";
......@@ -116,7 +119,6 @@ sub cleanup {
# going to "NEW" tells swapexp to fully terminate the experiment.
#
SetExpState($pid, $eid, EXPTSTATE_NEW);
system("prerender -r $pid $eid");
}
}
......@@ -133,8 +135,8 @@ TBDebugTimeStamp("parser finished");
print "Parser done! " . TBTimeStamp() . "\n";
TBDebugTimeStamp("prerender started in background");
print "Precomputing visualization (in background)...\n";
system("prerender -t $pid $eid &");
print "Precomputing visualization ...\n";
system("prerender -t $pid $eid");
TBDebugTimeStamp("routes started");
print "Setting up static routes (if requested) ... \n";
......
......@@ -2,7 +2,7 @@
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -162,7 +162,7 @@ if (defined($output)) {
$args .= "2> /dev/null";
}
if (system("$render $args") != 0) {
if (system("nice $render $args") != 0) {
exit(1);
}
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment