[SCM] Debian package checker branch, master, updated. 2.5.14-38-g4220141
The following commit has been merged in the master branch:
commit 4220141e785ea95c3c07642821c88ec659e67c2b
Author: Niels Thykier <niels@thykier.net>
Date: Fri Jul 5 10:27:58 2013 +0200
lintian: Add memory usage information with -ddd and -dddd
Add information about how much memory Lintian spends in L::Collect
objects with -ddd. At -dddd, breakdown the usage per "field" in the
L::Collect object.
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/debian/changelog b/debian/changelog
index e4fa6d6..44062c9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -52,6 +52,11 @@ lintian (2.5.15) UNRELEASED; urgency=low
* debian/rules:
+ [NT] Generate API documentation during build.
+ * frontend/lintian:
+ + [NT] Add information about memory usage with -ddd if
+ Devel::Size is available. A more detailed breakdown
+ of the memory usage with -dddd.
+
* lib/Lintian/Collect/Source.pm:
+ [NT] "binaries" and "binary_field" now only exposes data
about entries in d/control with a valid package name.
diff --git a/frontend/lintian b/frontend/lintian
index 79410e0..25a610c 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -120,6 +120,8 @@ my @auto_remove = ();
my $start_timer = sub { 0; };
my $finish_timer = sub { ''; };
+my $memory_usage = sub { 'N/A'; };
+
# }}}
# {{{ Setup Code
@@ -821,6 +823,38 @@ if ($debug) {
print "N: Cannot load Time::HiRes ($@)\n";
print "N: Running times will not be timed.\n";
}
+ if ($debug > 2) {
+ eval {
+ require Devel::Size;
+ import Devel::Size qw(total_size);
+ {
+ no warnings qw(once);
+ # Disable warnings about stuff Devel::Size cannot
+ # give reliable sizes for.
+ $Devel::Size::warn = 0;
+ }
+
+ $memory_usage = sub {
+ my ($obj) = @_;
+ my $size = total_size($obj);
+ my $unit = 'B';
+ if ($size > 1536) {
+ $size /= 1024;
+ $unit = 'kB';
+ if ($size > 1536) {
+ $size /= 1024;
+ $unit = 'MB';
+ }
+ }
+ return sprintf('%.2f %s', $size, $unit);
+ };
+ print "N: Using Devel::Size to debug memory usage\n";
+ };
+ if ($@) {
+ print "N: Cannot load Devel::Size ($@)\n";
+ print "N: Running memory usage will not be checked.\n";
+ }
+ }
}
} else {
# Ensure verbose has a defined value
@@ -1409,6 +1443,18 @@ sub process_group {
post_pkg_process_overrides ($lpkg);
} # end foreach my $lpkg ($group->get_processable)
+ if ($debug > 2) {
+ for my $lpkg ($group->get_processables) {
+ my $id = $lpkg->identifier;
+ my $usage = $memory_usage->($lpkg->info);
+ my $breakdown = $lpkg->info->_memory_usage($memory_usage);
+ debug_msg(3, "Memory usage [$id]: $usage");
+ for my $field (sort(keys(%{$breakdown}))) {
+ debug_msg(4, " -- $field: $breakdown->{$field}");
+ }
+ }
+ }
+
if (@auto_remove) {
# Invoke auto-clean now that the group has been checked
foreach my $lpkg ($group->get_processables){
diff --git a/lib/Lintian/Collect.pm b/lib/Lintian/Collect.pm
index e207db5..cbe7650 100644
--- a/lib/Lintian/Collect.pm
+++ b/lib/Lintian/Collect.pm
@@ -250,6 +250,15 @@ sub is_non_free {
return $self->{is_non_free};
}
+sub _memory_usage {
+ my ($self, $calc_usage) = @_;
+ my %usage;
+ for my $field (keys(%{$self})) {
+ $usage{$field} = $calc_usage->($self->{$field});
+ }
+ return \%usage;
+}
+
=back
=head1 AUTHOR
diff --git a/man/lintian.pod.in b/man/lintian.pod.in
index ec9cd64..3067afc 100644
--- a/man/lintian.pod.in
+++ b/man/lintian.pod.in
@@ -141,6 +141,10 @@ Can be used multiple times to increase the debug information. If
passed twice or more, Lintian will emit approximate run times for
collections and checks (if L<Time::HiRes> can be loaded).
+If passed 3 times (and if L<Devel::Size> can be loaded), Lintian will
+display memory usage for (some of its) data structures. With 4 times,
+the memory usage will be more detailed.
+
This option cannot be specified in the config file. If used on the
command line it will override the B<verbose> and the B<quiet> options
in the config file.
--
Debian package checker
Reply to: