[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] Cache the minimum version for a particular soname



Hello,

when building some package, I noticed the dh_shlibdeps step takes a noticeable amount of time. I profiled it and discovered it is because of the function get_smallest_version, which is called for each (binary, soname), and takes time proportional to the number of symbols.

In this patch, I amended the issue by caching the minimal dependency for a particular soname. It helped to reduce the time needed to build the package (without compiling, ie. I didn't clean the package before measurement) from about 10 minutes to about 5 minutes (on an Athlon XP 1800+).

What do you think about it?

Regards
    Jiri Palecek

---
 scripts/Dpkg/Shlibs/SymbolFile.pm |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/scripts/Dpkg/Shlibs/SymbolFile.pm b/scripts/Dpkg/Shlibs/SymbolFile.pm
index 3412f5f..c71c390 100644
--- a/scripts/Dpkg/Shlibs/SymbolFile.pm
+++ b/scripts/Dpkg/Shlibs/SymbolFile.pm
@@ -275,8 +275,9 @@ sub merge_symbols {
 	$self->create_object($soname, '');
     }
     # Scan all symbols provided by the objects
+    my $obj = $self->{objects}{$soname};
+    delete $obj->{minver};
     foreach my $name (keys %dynsyms) {
-	my $obj = $self->{objects}{$soname};
         my $sym;
 	if (exists $obj->{syms}{$name}) {
 	    # If the symbol is already listed in the file
@@ -371,6 +372,8 @@ sub get_dependency {
 sub get_smallest_version {
     my ($self, $soname, $dep_id) = @_;
     $dep_id = 0 unless defined($dep_id);
+ return $self->{objects}{$soname}{minver}{$dep_id} if(defined($self->{objects}{$soname}{minver}) && + defined($self->{objects}{$soname}{minver}{$dep_id}));
     my $minver;
     foreach my $sym (values %{$self->{objects}{$soname}{syms}}) {
         next if $dep_id != $sym->{dep_id};
@@ -379,6 +382,8 @@ sub get_smallest_version {
             $minver = $sym->{minver};
         }
     }
+ $self->{objects}{$soname}{minver}={ } unless defined($self->{objects}{$soname}{minver});
+    $self->{objects}{$soname}{minver}{$dep_id}=$minver;
     return $minver;
 }

--
1.6.3.3


Reply to: