Commit c5b79546 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Change to stats gathering code. Generate a new experiment_resources

record for each swapin (previously, it was just at swapmod). The
reason for this is that as the testbed gets more fragmented in terms
of hardware, it is less and less likely that consecutive swapins of
the same experiment will use the same number of physical resources.

We end up with some duplication of data inside the table, but no big
deal. I suspect we will revisit this per experiment state as the
workbench stuff proceeds.
parent 29759ea3
......@@ -123,7 +123,7 @@ use vars qw(@ISA @EXPORT);
TBDB_STATS_PRELOAD TBDB_STATS_START TBDB_STATS_TERMINATE
TBDB_STATS_SWAPIN TBDB_STATS_SWAPOUT TBDB_STATS_SWAPMODIFY
TBDB_STATS_FLAGS_IDLESWAP TBDB_STATS_FLAGS_PREMODIFY
TBDB_STATS_FLAGS_START
TBDB_STATS_FLAGS_START TBDB_STATS_FLAGS_PRESWAPIN
TBDB_JAILIPBASE TBDB_JAILIPMASK
......@@ -603,6 +603,7 @@ sub TBDB_STATS_SWAPMODIFY() { "swapmod"; }
sub TBDB_STATS_FLAGS_IDLESWAP() { 0x01; }
sub TBDB_STATS_FLAGS_PREMODIFY(){ 0x02; }
sub TBDB_STATS_FLAGS_START() { 0x04; }
sub TBDB_STATS_FLAGS_PRESWAPIN(){ 0x08; }
# Do not export this variable!
my $TBDB_STATS_STARTCLOCK;
......@@ -4385,7 +4386,7 @@ sub GatherSwapStats($$$$$;$)
return;
}
local $DBQUERY_MAXTRIES = 5;
local $DBQUERY_MAXTRIES = 0;
my $query_result =
DBQueryWarn("select e.state,e.gid,e.idx,s.rsrcidx,s.lastrsrc, ".
......@@ -4413,17 +4414,24 @@ sub GatherSwapStats($$$$$;$)
" swap_exitcode=$ecode ".
"where pid='$pid' and eid='$eid' and exptidx=$exptidx");
if ($mode eq TBDB_STATS_SWAPIN ||
$mode eq TBDB_STATS_START ||
#
# What about SWAPOUT errors? Well, 99.9 percent of the time,
# the nodes are going to be released even if the swapout fails.
# Since that is what we really care about wrt resource consumption,
# we let swapout errors fall through to the stats code below.
# I could probably check for this case (nodes actually released)
# but not bothering to do so.
#
if ($mode eq TBDB_STATS_START ||
$mode eq TBDB_STATS_PRELOAD) {
goto logit;
}
#
# If a modify failed, we need to revert back to the old
# If a modify or swapin failed, we need to revert back to the old
# resource record since the current one is bogus.
#
if ($mode eq TBDB_STATS_SWAPMODIFY) {
if ($mode eq TBDB_STATS_SWAPMODIFY || $mode eq TBDB_STATS_SWAPIN) {
if (defined($lastrsrc)) {
DBQueryWarn("update experiment_stats set ".
" rsrcidx=$lastrsrc,lastrsrc=NULL ".
......@@ -4450,8 +4458,10 @@ sub GatherSwapStats($$$$$;$)
# Pre-modify. Need to generate a new resource record. If the experiment
# fails to modify, we revert back to the old resource record later.
#
if ($mode eq TBDB_STATS_SWAPMODIFY &&
$flags & TBDB_STATS_FLAGS_PREMODIFY) {
if (($mode eq TBDB_STATS_SWAPMODIFY &&
$flags & TBDB_STATS_FLAGS_PREMODIFY) ||
($mode eq TBDB_STATS_SWAPIN &&
$flags & TBDB_STATS_FLAGS_PRESWAPIN && defined($lastrsrc))) {
$query_result =
DBQueryWarn("insert into experiment_resources ".
" (idx, tstamp, exptidx, lastidx) ".
......@@ -4468,6 +4478,21 @@ sub GatherSwapStats($$$$$;$)
" rsrcidx=$rsrcidx,lastrsrc=$lastrsrc ".
"where pid='$pid' and eid='$eid' and ".
" exptidx=$exptidx");
#
# In SWAPIN, copy over the thumbnail. This is temporary; I think
# the thumbnail is going to end up going someplace else.
#
if ($mode eq TBDB_STATS_SWAPIN) {
$query_result =
DBQueryWarn("select thumbnail from experiment_resources ".
"where idx=$lastrsrc");
if ($query_result &&
$query_result->numrows) {
my ($thumbdata) = $query_result->fetchrow_array();
TBExptSetThumbNail($pid, $eid, $thumbdata);
}
}
return;
}
......
......@@ -797,9 +797,10 @@ if ($inout eq "out") {
TBExptClearPanicBit($pid, $eid);
}
elsif ($inout eq "in") {
my $optarg = "";
GatherSwapStats($pid, $eid, $dbuid,
TBDB_STATS_SWAPIN, 0, TBDB_STATS_FLAGS_PRESWAPIN);
print STDOUT "Running 'tbswap in $optarg $pid $eid'\n";
print STDOUT "Running 'tbswap in $pid $eid'\n";
if (system("$tbdir/tbswap in $pid $eid") != 0) {
$errorstat = $? >> 8;
fatal("tbswap in failed!");
......
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