From ad93e349d9329f1bed434992505a48b11aa99316 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Thu, 23 Jun 2011 13:44:24 +0000 Subject: [PATCH] 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 --- xCAT-server/lib/xcat/plugins/kvm.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index ddfcde70e..1e1047238 100644 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -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