diff --git a/db/libdb.pm.in b/db/libdb.pm.in index 21152bbd951eacf4af59a52031184b1f6880a6da..c713de17041f39abc7dc5657ab52a81de693168d 100644 --- a/db/libdb.pm.in +++ b/db/libdb.pm.in @@ -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 diff --git a/sql/database-create.sql b/sql/database-create.sql index 74f2094da588082ec97c66f21d3f0cab0fdad278..96c028e5ae03d3a483934f7eb2c4e12c26dcc6c0 100644 --- a/sql/database-create.sql +++ b/sql/database-create.sql @@ -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; -- diff --git a/sql/database-migrate.txt b/sql/database-migrate.txt index 7eb2a9fd6337304d7965014eb4a0feaf9388b332..5e749b25d686437b09b36a6779bd95df16a8c292 100644 --- a/sql/database-migrate.txt +++ b/sql/database-migrate.txt @@ -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 diff --git a/www/showsumstats.php3 b/www/showsumstats.php3 index b09cadff4bc9dcedb16e8a959eb8696701e67dc1..e8b56427b03375ac40b27d7b745c194d7019e181 100644 --- a/www/showsumstats.php3 +++ b/www/showsumstats.php3 @@ -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
\n"; + echo "$idx $pid $eid $uid $tstamp $action $pnodes $pnodes2
\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); }