Commit 87b3c945 authored by Kevin Atkinson's avatar Kevin Atkinson

Be more precise when nodes are in a so called invalid state.

That is when more than a fixed threshold of nodes (0.05 for now) are
in an invalid state for any particular class (ie "pc3000s", "d710s",
etc) only invalid that class for the time period, instead of all the
plot data.

Along the way fix various bugs with handling NaN (how invalid states
are flagged).
parent c85e79dc
......@@ -17,6 +17,7 @@ require "@prefix@/etc/node_usage.conf";
chdir "@prefix@/data/node_usage";
my $TOLERANCE = 0.05;
#my $TOLERANCE = 0.10;
my $TOLERANCE_INTERVAL = 1/3;
my $interval = 60*60;
......@@ -40,7 +41,7 @@ my @prev_data = map {0} @idxs;
my @total_so_far = map {0} @idxs;
my $next_cutoff = $start;
my $error_frac = 0;
my @error_frac = map {0} @idxs;
open F, "node_usage.raw";
open O, ">node_usage-$interval_name.dat";
......@@ -81,19 +82,20 @@ while (<F>) {
my @data = sum_usage_stats(1);
my @error = sum_usage_stats(2);
@data = map {$data[$_] + $error[$_]/2} @idxs;
if (any map {$error[$_] > $num[$_]*$TOLERANCE} @idxs) {
#print STDERR "ERROR $time: $error\n";
@data = map {'NaN'} @idxs;
}
@data = map {$error[$_] > $num[$_]*$TOLERANCE
? 'NaN' : $data[$_]} @idxs;
# if (any map {$error[$_] > $num[$_]*$TOLERANCE} @idxs) {
# print STDERR "ERROR $time: ", join (' ', map {"$error[$_] > ".$num[$_]*$TOLERANCE} @idxs), "\n";
# }
use warnings;
my $combine = sub {
my ($t) = (@_);
my $frac = ($t - $prev_time)/$interval;
if ($prev_data[0] != $prev_data[0]) { # ie NaN
$error_frac += $frac;
} else {
foreach my $i (@idxs) {
foreach my $i (@idxs) {
if ($prev_data[$i] != $prev_data[$i]) { # ie NaN
$error_frac[$i] += $frac;
} else {
$total_so_far[$i] += $prev_data[$i] * $frac;
}
}
......@@ -102,13 +104,11 @@ while (<F>) {
while ($time >= $next_cutoff) {
&$combine($next_cutoff);
my @free = @total_so_far;
if ($error_frac > $TOLERANCE_INTERVAL) {
foreach my $i (@idxs) {
$free[0] = 'NaN';
}
} else {
foreach my $i (@idxs) {
$free[$i] /= (1 - $error_frac);
foreach my $i (@idxs) {
if ($error_frac[$i] > $TOLERANCE_INTERVAL) {
$free[$i] = 'NaN';
} else {
$free[$i] /= (1 - $error_frac[$i]);
}
}
my @alloc = map {$num[$_] - $free[$_]} @idxs;
......@@ -117,7 +117,7 @@ while (<F>) {
@alloc = filter_w_start $dtime, @alloc;
print O join(' ', $dtime, map {sprintf("%.1f", $_)} (@free, @alloc)),"\n"
if $dtime >= $start;
$error_frac = 0;
@error_frac = map {0} @idxs;
@total_so_far = map {0} @idxs;
$prev_time = $next_cutoff;
$next_cutoff += $interval;
......
......@@ -25,11 +25,11 @@ my %res;
sub tally ($$@) {
my ($str, $what, @d) = @_;
if ($d[0] != $d[0]) { # ie NaN
$res{$what}{data}{$str}{invalid}++;
} else {
$res{$what}{data}{$str}{count}++;
foreach my $i (@idxs) {
foreach my $i (@idxs) {
if ($d[$i] != $d[$i]) { # ie NaN
$res{$what}{data}{$str}{invalid}[$i]++;
} else {
$res{$what}{data}{$str}{count}[$i]++;
$res{$what}{data}{$str}{data}[$i] += $d[$i];
}
}
......@@ -37,9 +37,9 @@ sub tally ($$@) {
sub tally_mod ($$@) {
my ($bin, $what, @d) = @_;
return if $d[0] != $d[0]; # ie NaN
$res{$what}{data}[$bin]{count}++;
foreach my $i (@idxs) {
next if $d[$i] != $d[$i]; # ie NaN
$res{$what}{data}[$bin]{count}[$i]++;
$res{$what}{data}[$bin]{data}[$i] += $d[$i];
}
}
......@@ -91,13 +91,14 @@ foreach my $k (keys %res) {
foreach my $i (sort keys %{$res{$k}{data}}) {
my @r;
my $d = $res{$k}{data}{$i};
my $invalid = $d->{invalid};
my $count = $d->{count};
if ($invalid / ($invalid + $count) > $TOLERANCE_INTERVAL) {
@r = map {'NaN'} @idxs;
} else {
foreach my $j (@idxs) {
foreach my $j (@idxs) {
my $invalid = $d->{invalid}[$j];
my $count = $d->{count}[$j];
if ($invalid / ($invalid + $count) > $TOLERANCE_INTERVAL) {
$r[$j] = 'NaN';
} else {
$r[$j] = $d->{data}[$j]/$count;
die "Unexpected NaN" if $r[$j] != $r[$j];
}
}
print F join(' ', "$i ", map {sprintf("%5.1f", $_)} @r),"\n"
......@@ -108,9 +109,8 @@ foreach my $k (keys %res) {
foreach my $i (0 .. $#{$res{$k}{data}}) {
my @r;
my $d = $res{$k}{data}[$i];
my $count = $d->{count};
foreach my $j (@idxs) {
$r[$j] = $d->{data}[$j]/$count;
$r[$j] = $d->{data}[$j] ? $d->{data}[$j]/$d->{count}[$j] : 0;
}
print F join(' ', sprintf("%6.3f ", $i/$div), map {sprintf("%5.1f", $_)} @r),"\n"
}
......
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