Commit eb3d7568 authored by Leigh Stoller's avatar Leigh Stoller

Add a lastidx field to the experiment_resources table. This makes it

easier to chain back through the swapmod incarnations of an experiment,
without going through query hell, and is very useful in summary stats
page for calculating the usage across swapmods.

Note that the lastrsrc field of the experiments table can now go.
parent 2e2dc874
......@@ -3252,8 +3252,8 @@ sub GatherSwapStats($$$$$;$)
$flags & TBDB_STATS_FLAGS_PREMODIFY) {
$query_result =
DBQueryWarn("insert into experiment_resources ".
" (idx, tstamp, exptidx) ".
"values (0, now(), $exptidx)");
" (idx, tstamp, exptidx, lastidx) ".
"values (0, now(), $exptidx, $rsrcidx)");
if (! $query_result ||
! $query_result->insertid) {
print STDERR
......
......@@ -172,6 +172,7 @@ CREATE TABLE eventlist (
CREATE TABLE experiment_resources (
idx int(10) unsigned NOT NULL auto_increment,
exptidx int(10) unsigned NOT NULL default '0',
lastidx int(10) unsigned default NULL,
tstamp datetime default NULL,
vnodes smallint(5) unsigned default '0',
pnodes smallint(5) unsigned default '0',
......@@ -188,7 +189,8 @@ CREATE TABLE experiment_resources (
minlinks tinyint(3) unsigned default '0',
maxlinks tinyint(3) unsigned default '0',
PRIMARY KEY (idx),
KEY exptidx (exptidx)
KEY exptidx (exptidx),
KEY lastidx (lastidx)
) TYPE=MyISAM;
--
......
......@@ -693,3 +693,31 @@ last_net_act,last_cpu_act,last_ext_act);
alter ignore table comments modify
column_name varchar(64) not null default "";
1.158: Add chain field to experiment_resources to make it easier to
step back through experiment history, and keep the join size
down.
alter table experiment_resources add lastidx int(10)
unsigned default NULL after exptidx;
alter table experiment_resources add index(lastidx);
my $query_result =
DBQueryWarn("select idx,exptidx from experiment_resources ".
"order by exptidx,tstamp asc");
my $lastexpt = -1;
my $lastidx = -1;
while (($idx,$exptidx) = $query_result->fetchrow_array()) {
if ($exptidx != $lastexpt) {
print "update experiment_resources set lastidx=NULL ".
"where exptidx=$exptidx and idx=$idx;\n";
$lastexpt = $exptidx;
$lastidx = $idx;
next;
}
print "update experiment_resources set lastidx=$lastidx ".
"where exptidx=$exptidx and idx=$idx;\n";
$lastidx = $idx;
}
\ No newline at end of file
......@@ -238,7 +238,7 @@ function edaycmp ($a, $b) {
function showrange ($showby, $sortby, $range) {
global $TBOPSPID, $TB_EXPTSTATE_ACTIVE;
$debug = 0;
$debug = 1;
switch ($range) {
case "day":
......@@ -328,7 +328,7 @@ function showrange ($showby, $sortby, $range) {
"left join experiment_resources as r1 on ".
" r1.idx=t.rsrcidx ".
"left join experiment_resources as r2 on ".
" r2.idx=s.lastrsrc and s.lastrsrc is not null ".
" r2.idx=r1.lastidx and r1.lastidx is not null ".
"where t.exitcode = 0 && ".
" ((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(t.tstamp)) ".
" < $wclause) ".
......@@ -393,7 +393,7 @@ function showrange ($showby, $sortby, $range) {
}
if ($debug)
echo "$idx $pid $eid $uid $tstamp $action $pnodes<br>\n";
echo "$idx $pid $eid $uid $tstamp $action $pnodes $pnodes2<br>\n";
switch ($action) {
case "start":
......@@ -440,11 +440,10 @@ function showrange ($showby, $sortby, $range) {
# Basically, start the clock ticking again with the new
# number of pnodes.
if ($action == "swapmod") {
# Yuck, we redefined uid above, but we want to start the
# new record for the current swapper.
$uid = $row["uid"];
$expt_start["$pid:$eid"] = array('pnodes' => $pnodes,
'uid' => $uid,
# Yuck, we redefined uid/pnodes above, but we want to start the
# new record for the current swapper/#pnodes.
$expt_start["$pid:$eid"] = array('pnodes' => $row['pnodes1'],
'uid' => $row['uid'],
'pid' => $pid,
'stamp' => $tstamp);
}
......
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