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

[lintian] 02/08: L::C::B: Reduce the memory usage for objdump_info



This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository lintian.

commit f4c57bbce8c97f826f68cd9c222c25e5629d7963
Author: Niels Thykier <niels@thykier.net>
Date:   Mon Jan 25 18:20:48 2016 +0000

    L::C::B: Reduce the memory usage for objdump_info
    
    A lot of the fields in objdump_info are initialized to a default
    value.  Sadly, this has a considerable overhead.  With this patch, we
    do away with most defaults.  This reduces the memory usage of
    objdump_info by ~20% (2.2MB) on
    linux-image-4.4.0-trunk-rt-686-pae_4.4-1~exp1_i386.deb.
    
    Note that objdump is still the primary memory hog for said package at
    8.29MB (out of a total of 12.69).
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 checks/shared-libs.pm         |  4 ++--
 lib/Lintian/Collect/Binary.pm | 27 ++++++++++-----------------
 2 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/checks/shared-libs.pm b/checks/shared-libs.pm
index 3bc4c23..1e02ff8 100644
--- a/checks/shared-libs.pm
+++ b/checks/shared-libs.pm
@@ -69,8 +69,8 @@ sub run {
 
     # 1st step: get info about shared libraries installed by this package
     foreach my $file (sort keys %{$objdump}) {
-        $SONAME{$file} = $objdump->{$file}->{SONAME}[0]
-          if scalar @{ $objdump->{$file}->{SONAME} };
+        $SONAME{$file} = $objdump->{$file}{SONAME}[0]
+          if exists($objdump->{$file}{SONAME});
     }
 
     foreach my $file ($info->sorted_index) {
diff --git a/lib/Lintian/Collect/Binary.pm b/lib/Lintian/Collect/Binary.pm
index 8d7bdf5..5117ced 100644
--- a/lib/Lintian/Collect/Binary.pm
+++ b/lib/Lintian/Collect/Binary.pm
@@ -370,18 +370,16 @@ sub objdump_info {
     my $fd = open_gz($objf);
     foreach my $pg (parse_dpkg_control($fd)) {
         my %info = (
-            'PH' => {},
-            'SH' => {},
-            'ELF'    => 1,
-            'NOTES'  => [],
+            'PH'     => {},
+            'SH'     => {},
             'NEEDED' => [],
-            'RPATH'  => {},
-            'SONAME' => [],
-            'TEXTREL' => 0,
         );
-        $info{'ERRORS'} = lc($pg->{'broken'}//'no') eq 'yes' ? 1 : 0;
-        $info{'BAD-DYNAMIC-TABLE'}
-          = lc($pg->{'bad-dynamic-table'}//'no') eq 'yes' ? 1 : 0;
+        if (lc($pg->{'broken'}//'no') eq 'yes') {
+            $info{'ERRORS'} = 1;
+        }
+        if (lc($pg->{'bad-dynamic-table'}//'no') eq 'yes') {
+            $info{'BAD-DYNAMIC-TABLE'} = 1;
+        }
         foreach my $symd (split m/\s*\n\s*/, $pg->{'dynamic-symbols'}//'') {
             next unless $symd;
             if ($symd =~ m/^\s*(\S+)\s+(?:(\S+)\s+)?(\S+)$/){
@@ -399,12 +397,12 @@ sub objdump_info {
         foreach my $data (split m/\s*\n\s*/, $pg->{'program-headers'}//'') {
             next unless $data;
             my ($header, @vals) = split m/\s++/, $data;
-            $info{'PH'}->{$header} = {};
             foreach my $extra (@vals) {
                 my ($opt, $val) = split m/=/, $extra;
-                $info{'PH'}->{$header}->{$opt} = $val;
                 if ($opt eq 'interp' and $header eq 'INTERP') {
                     $info{'INTERP'} = $val;
+                } else {
+                    $info{'PH'}{$header}{$opt} = $val;
                 }
             }
         }
@@ -428,15 +426,10 @@ sub objdump_info {
             # object file in a static lib.
             my ($lib, $obj) = ($1, $2);
             my $libentry = $objdump_info{$lib};
-            $info{'ELF'} = 0;
             if (not defined $libentry) {
                 $libentry = {
                     'filename' => $lib,
                     'objects'  => [$obj],
-                    # static libs have no SONAMEs (and shared-libs
-                    # checks for it)
-                    'SONAME'   => [],
-                    'ELF'      => 0,
                 };
                 $objdump_info{$lib} = $libentry;
             } else {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: