Commit eb3d7568 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

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($$$$$;$) ...@@ -3252,8 +3252,8 @@ sub GatherSwapStats($$$$$;$)
$flags & TBDB_STATS_FLAGS_PREMODIFY) { $flags & TBDB_STATS_FLAGS_PREMODIFY) {
$query_result = $query_result =
DBQueryWarn("insert into experiment_resources ". DBQueryWarn("insert into experiment_resources ".
" (idx, tstamp, exptidx) ". " (idx, tstamp, exptidx, lastidx) ".
"values (0, now(), $exptidx)"); "values (0, now(), $exptidx, $rsrcidx)");
if (! $query_result || if (! $query_result ||
! $query_result->insertid) { ! $query_result->insertid) {
print STDERR print STDERR
......
...@@ -172,6 +172,7 @@ CREATE TABLE eventlist ( ...@@ -172,6 +172,7 @@ CREATE TABLE eventlist (
CREATE TABLE experiment_resources ( CREATE TABLE experiment_resources (
idx int(10) unsigned NOT NULL auto_increment, idx int(10) unsigned NOT NULL auto_increment,
exptidx int(10) unsigned NOT NULL default '0', exptidx int(10) unsigned NOT NULL default '0',
lastidx int(10) unsigned default NULL,
tstamp datetime default NULL, tstamp datetime default NULL,
vnodes smallint(5) unsigned default '0', vnodes smallint(5) unsigned default '0',
pnodes smallint(5) unsigned default '0', pnodes smallint(5) unsigned default '0',
...@@ -188,7 +189,8 @@ CREATE TABLE experiment_resources ( ...@@ -188,7 +189,8 @@ CREATE TABLE experiment_resources (
minlinks tinyint(3) unsigned default '0', minlinks tinyint(3) unsigned default '0',
maxlinks tinyint(3) unsigned default '0', maxlinks tinyint(3) unsigned default '0',
PRIMARY KEY (idx), PRIMARY KEY (idx),
KEY exptidx (exptidx) KEY exptidx (exptidx),
KEY lastidx (lastidx)
) TYPE=MyISAM; ) TYPE=MyISAM;
-- --
......
...@@ -693,3 +693,31 @@ last_net_act,last_cpu_act,last_ext_act); ...@@ -693,3 +693,31 @@ last_net_act,last_cpu_act,last_ext_act);
alter ignore table comments modify alter ignore table comments modify
column_name varchar(64) not null default ""; 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) { ...@@ -238,7 +238,7 @@ function edaycmp ($a, $b) {
function showrange ($showby, $sortby, $range) { function showrange ($showby, $sortby, $range) {
global $TBOPSPID, $TB_EXPTSTATE_ACTIVE; global $TBOPSPID, $TB_EXPTSTATE_ACTIVE;
$debug = 0; $debug = 1;
switch ($range) { switch ($range) {
case "day": case "day":
...@@ -328,7 +328,7 @@ function showrange ($showby, $sortby, $range) { ...@@ -328,7 +328,7 @@ function showrange ($showby, $sortby, $range) {
"left join experiment_resources as r1 on ". "left join experiment_resources as r1 on ".
" r1.idx=t.rsrcidx ". " r1.idx=t.rsrcidx ".
"left join experiment_resources as r2 on ". "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 && ". "where t.exitcode = 0 && ".
" ((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(t.tstamp)) ". " ((UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(t.tstamp)) ".
" < $wclause) ". " < $wclause) ".
...@@ -393,7 +393,7 @@ function showrange ($showby, $sortby, $range) { ...@@ -393,7 +393,7 @@ function showrange ($showby, $sortby, $range) {
} }
if ($debug) 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) { switch ($action) {
case "start": case "start":
...@@ -440,11 +440,10 @@ function showrange ($showby, $sortby, $range) { ...@@ -440,11 +440,10 @@ function showrange ($showby, $sortby, $range) {
# Basically, start the clock ticking again with the new # Basically, start the clock ticking again with the new
# number of pnodes. # number of pnodes.
if ($action == "swapmod") { if ($action == "swapmod") {
# Yuck, we redefined uid above, but we want to start the # Yuck, we redefined uid/pnodes above, but we want to start the
# new record for the current swapper. # new record for the current swapper/#pnodes.
$uid = $row["uid"]; $expt_start["$pid:$eid"] = array('pnodes' => $row['pnodes1'],
$expt_start["$pid:$eid"] = array('pnodes' => $pnodes, 'uid' => $row['uid'],
'uid' => $uid,
'pid' => $pid, 'pid' => $pid,
'stamp' => $tstamp); '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