Speed up mass-scale KVM VM adoption

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@9914 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2011-06-23 13:44:24 +00:00
parent 2bed6cd128
commit ad93e349d9

View File

@ -717,6 +717,7 @@ sub getrvidparms {
return 0,@output;
}
my %cached_noderanges;
sub pick_target {
my $node = shift;
my $addmemory = shift;
@ -729,7 +730,14 @@ sub pick_target {
unless ($candidates) {
return undef;
}
foreach (noderange($candidates)) {
my @fosterhyps; #noderange is relatively expensive, and generally we only will have a few distinct noderange descriptions to contend with in a mass adoption, so cache eache one for reuse across pick_target() calls
if (defined $cached_noderanges{$candidates}) {
@fosterhyps = @{$cached_noderanges{$candidates}};
} else {
@fosterhyps = noderange($candidates);
$cached_noderanges{$candidates} = \@fosterhyps;
}
foreach (@fosterhyps) {
my $targconn;
my $cand=$_;
if ($_ eq $currhyp) { next; } #skip current node