From 411e2ccb3aeafa863a7313d6e87f9e63a886ce38 Mon Sep 17 00:00:00 2001 From: "biao716.wang" Date: Tue, 27 Oct 2020 16:28:20 +0900 Subject: [PATCH] Improve the perfermance of getting package dependence. After change, the run time of update_pkgdeps has been shorteneded to 25% of the original run time. For tesing of tizen unified 956 packages, the orignial run time of this function is 154s, now is 41s. Change-Id: I0bb96c7890559d0b6ed56b39c7a558137a2d8bb0 Signed-off-by: biao716.wang --- depanneur | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/depanneur b/depanneur index 3143529..af0bdbe 100755 --- a/depanneur +++ b/depanneur @@ -151,6 +151,7 @@ my @pre_packs = (); # temp packages data, item structure : # {project_base_path: # filepath: spec file path } my %to_build = (); # for all packages should be built this time +my %subptomainp = (); # dict to store map from subpack name to main pack name. my %repo = (); # store all packages dependency in memory my %pkgdeps = (); # direct and indirect dependency dict my %pkgddeps = (); # direct dependency dict @@ -1033,6 +1034,10 @@ sub parse_packs { subpacks => @subpacks, filename => $spec, }; + #to store the map from subpack to main pack. + foreach my $sub_p (@{$packs{$name}->{subpacks}}) { + $subptomainp{$sub_p} = $name; + } if (@sorted) { #pick up the smallest source tag such as source0 @@ -1347,14 +1352,14 @@ sub set_idle { # find which package does this sub-package belong to #--------------------------------------------------------------------- sub source_of { - my ($sub, %packs) = @_; - foreach my $x (keys %packs) { - my @sp = @{$packs{$x}->{subpacks}}; - if (grep $_ eq $sub, @sp ) { - return $x; - } + my ($sub, $ref_subtomain) = @_; + if (exists($ref_subtomain->{$sub}) ) + { + #info("sub: $sub, main pack: $ref_subtomain->{$sub}"); + return $ref_subtomain->{$sub}; } return; + } #--------------------------------------------------------------------- @@ -1502,7 +1507,7 @@ sub update_pkgdeps } my @deps; foreach my $depp (@bdeps) { - my $so = source_of($depp, %to_build); + my $so = source_of($depp, \%subptomainp); if (defined($so) && $name ne $so && (! grep($_ eq $so, @skipped)) && (! grep($_ eq $so, @deps))) { @@ -1527,7 +1532,7 @@ sub update_pkgddeps { my @bdeps = get_deps($fn); my @deps; foreach my $depp (@bdeps) { - my $so = source_of($depp, %to_build); + my $so = source_of($depp, \%subptomainp); if (defined($so) && $name ne $so && (! grep($_ eq $so, @skipped)) && (! grep($_ eq $so, @done)) -- 2.34.1