tweak memory handling to make it less special: treat -M as an override_prop

as we should.
Use core methods to access the memory threshold.

UI simplification: -M can take a suffix, default is K, but you can just say
-M 520M or -M 2G now.
This commit is contained in:
espie 2013-01-28 10:14:17 +00:00
parent cd3023d079
commit c259d653cc
4 changed files with 22 additions and 22 deletions

View File

@ -1,7 +1,7 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
# $OpenBSD: dpb,v 1.79 2013/01/28 09:56:00 espie Exp $
# $OpenBSD: dpb,v 1.80 2013/01/28 10:14:17 espie Exp $
#
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
#
@ -155,9 +155,6 @@ sub handle_options
$state->{random} = 1;
$state->heuristics->random;
},
M => sub {
$state->heuristics->set_threshold(shift);
},
P => sub {
push(@{$state->{paths}}, shift);
},
@ -291,6 +288,9 @@ sub start_cores
if ($state->defines("ALWAYS_CLEAN")) {
$override_prop->{always_clean} = 1;
}
if ($state->opt('M')) {
$override_prop->{mem} = $state->opt('M');
}
my $default_prop = {
junk => 150,

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
# $OpenBSD: Core.pm,v 1.30 2013/01/27 17:54:45 espie Exp $
# $OpenBSD: Core.pm,v 1.31 2013/01/28 10:14:17 espie Exp $
#
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
#
@ -31,6 +31,16 @@ sub new
if (defined $prop->{stuck}) {
$prop->{stuck_timeout} = $prop->{stuck} * $prop->{sf};
}
if (defined $prop->{mem}) {
my $_ = $prop->{mem};
if (s/K$//) {
} elsif (s/M$//) {
$_ *= 1024;
} elsif (s/G$//) {
$_ *= 1024 * 1024;
}
$prop->{memory} = $_;
}
$prop->{small} //= 120;
$prop->{small_timeout} = $prop->{small} * $prop->{sf};
# if ($class->name_is_localhost($name)) {
@ -789,9 +799,6 @@ sub parse_hosts_file
if (defined $prop->{arch} && $prop->{arch} ne $state->arch) {
next;
}
if (defined $prop->{mem}) {
$prop->{memory} = $prop->{mem};
}
if ($host eq 'DEFAULT') {
$default = { %$prop };
next;

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
# $OpenBSD: Engine.pm,v 1.71 2013/01/10 10:30:13 espie Exp $
# $OpenBSD: Engine.pm,v 1.72 2013/01/28 10:14:17 espie Exp $
#
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
#
@ -337,8 +337,7 @@ sub already_done
sub start_build
{
my ($self, $v, $core, $lock) = @_;
my $special = $self->{engine}{heuristics}->
special_parameters($core->host, $v);
my $special = $self->{engine}{heuristics}->special_parameters($core, $v);
$self->log('J', $v, " ".$core->hostname." ".$special);
$self->{engine}{affinity}->start($v, $core);
$self->{builder}->build($v, $core, $special,

View File

@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
# $OpenBSD: Heuristics.pm,v 1.16 2013/01/10 22:42:21 espie Exp $
# $OpenBSD: Heuristics.pm,v 1.17 2013/01/28 10:14:17 espie Exp $
#
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
#
@ -78,13 +78,6 @@ sub equates
}
}
my $threshold;
sub set_threshold
{
my ($self, $t) = @_;
$threshold = $t;
}
sub add_size_info
{
my ($self, $path, $sz) = @_;
@ -96,12 +89,13 @@ my $used_per_host = {};
sub special_parameters
{
my ($self, $host, $v) = @_;
my $t = $host->{prop}->{memory} // $threshold;
my ($self, $core, $v) = @_;
my $t = $core->memory;
return 0 if !defined $t;
my $p = $v->pkgpath_and_flavors;
# we build in memory if we know this port and it's light enough
if (defined $t && defined $wrkdir{$p}) {
my $hostname = $host->name;
my $hostname = $core->hostname;
$used_per_host->{$hostname} //= 0;
if ($used_per_host->{$hostname} + $wrkdir{$p} <= $t) {
$used_per_host->{$hostname} += $wrkdir{$p};