mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-12-23 13:17:54 +00:00
parallel: Median time implemented using remedian.
This commit is contained in:
parent
eac8d05e3a
commit
ee30290b9a
33
src/parallel
33
src/parallel
|
@ -5570,7 +5570,9 @@ sub new {
|
||||||
'queue' => [],
|
'queue' => [],
|
||||||
'delta_time' => $delta_time,
|
'delta_time' => $delta_time,
|
||||||
'pct' => $pct,
|
'pct' => $pct,
|
||||||
'avg_damper' => $avg_damper,
|
'remedian_idx' => 0,
|
||||||
|
'remedian_arr' => [],
|
||||||
|
'remedian' => undef,
|
||||||
}, ref($class) || $class;
|
}, ref($class) || $class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5584,17 +5586,36 @@ sub set_delta_time {
|
||||||
$self->{'delta_time'} = shift;
|
$self->{'delta_time'} = shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub remedian {
|
||||||
|
my $self = shift;
|
||||||
|
return $self->{'remedian'};
|
||||||
|
}
|
||||||
|
|
||||||
|
sub set_remedian {
|
||||||
|
# Set median of the last 999^3 (=997002999) values using Remedian
|
||||||
|
#
|
||||||
|
# Rousseeuw, Peter J., and Gilbert W. Bassett Jr. "The remedian: A
|
||||||
|
# robust averaging method for large data sets." Journal of the
|
||||||
|
# American Statistical Association 85.409 (1990): 97-104.
|
||||||
|
my $self = shift;
|
||||||
|
my $val = shift;
|
||||||
|
my $i = $self->{'remedian_idx'}++;
|
||||||
|
my $rref = $self->{'remedian_arr'};
|
||||||
|
$rref->[0][$i%999] = $val;
|
||||||
|
$rref->[1][$i/999%999] = (sort @{$rref->[0]})[$#{$rref->[0]}/2];
|
||||||
|
$rref->[2][$i/999/999%999] = (sort @{$rref->[1]})[$#{$rref->[1]}/2];
|
||||||
|
$self->{'remedian'} = (sort @{$rref->[2]})[$#{$rref->[2]}/2];
|
||||||
|
# die((sort @{$rref->[2]})[$#{$rref->[2]}/2]);
|
||||||
|
}
|
||||||
|
|
||||||
sub update_delta_time {
|
sub update_delta_time {
|
||||||
# Update delta_time based on runtime of finished job if timeout is
|
# Update delta_time based on runtime of finished job if timeout is
|
||||||
# a percentage
|
# a percentage
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $runtime = shift;
|
my $runtime = shift;
|
||||||
if($self->{'pct'}) {
|
if($self->{'pct'}) {
|
||||||
# Converge to the average fast in the start, and slower later
|
$self->set_remedian($runtime);
|
||||||
$self->{'avg_damper'} = $self->{'avg_damper'} * 0.9 + 0.001;
|
$self->{'delta_time'} = $self->{'pct'} * $self->remedian();
|
||||||
$self->{'delta_time'} =
|
|
||||||
$self->{'pct'} * $runtime * $self->{'avg_damper'} +
|
|
||||||
(1 - $self->{'avg_damper'}) * $self->{'delta_time'};
|
|
||||||
::debug("Timeout: $self->{'delta_time'}s ");
|
::debug("Timeout: $self->{'delta_time'}s ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue