Improve the perfermance of getting package dependence. 39/246239/1 submit/trunk/20201029.114030 submit/trunk/20201029.132130 submit/trunk/20201029.140230 submit/trunk/20201030.104730 submit/trunk/20201030.143530 submit/trunk/20201102.094730
authorbiao716.wang <biao716.wang@samsung.com>
Tue, 27 Oct 2020 07:28:20 +0000 (16:28 +0900)
committerbiao716.wang <biao716.wang@samsung.com>
Tue, 27 Oct 2020 07:35:21 +0000 (16:35 +0900)
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 <biao716.wang@samsung.com>
depanneur

index 314352937c5d93196d806c6b897eae7cc3f33449..af0bdbe2f53eadb434f8c7d4f5964141cf5b6621 100755 (executable)
--- 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))