Package: libfile-stripnondeterminism-perl
Version: 0.035-2
Severity: normal
Tags: upstream patch
Hi,
Thanks to a very minimalistic performance test case for dh from Adam
Borowski, I realised that dh_strip-nondeterminism accounts for ~4.5%
of the total runtime for a (mostly) no-op dh package build[1]. This
cost applies even to packages for which dh_strip-nondeterminism does
not normalize any files.
Attached, I have included a few patches to optimize the start up time
a bit (Feel free to squash them into a single commit).
In my simplified testing, the start up time is reduced to ~0.075s
(down from ~0.170s) in the no-op case. The impact should be minimal
in the case where dh_strip-nondeterminism actually need to do
anything.
Thanks,
~Niels
[1] dpkg-buildpackage -us -uc -tc -b
>From 5a1ffdd72f55b17b11869b10a85529a0048fec91 Mon Sep 17 00:00:00 2001
From: Niels Thykier
Date: Mon, 10 Jul 2017 20:19:54 +
Subject: [PATCH 1/3] File::SND: Lazy load most handlers
This reduces the start up time of dh_strip_nondeterminism to ~0.10s
from ~0.17s in a "no-op" case.
Signed-off-by: Niels Thykier
---
lib/File/StripNondeterminism.pm | 73 -
1 file changed, 42 insertions(+), 31 deletions(-)
diff --git a/lib/File/StripNondeterminism.pm b/lib/File/StripNondeterminism.pm
index c29d4df..c153b0e 100644
--- a/lib/File/StripNondeterminism.pm
+++ b/lib/File/StripNondeterminism.pm
@@ -22,16 +22,9 @@ use strict;
use warnings;
use POSIX qw(tzset);
-use File::StripNondeterminism::handlers::ar;
-use File::StripNondeterminism::handlers::cpio;
-use File::StripNondeterminism::handlers::gettext;
-use File::StripNondeterminism::handlers::gzip;
-use File::StripNondeterminism::handlers::jar;
use File::StripNondeterminism::handlers::javadoc;
use File::StripNondeterminism::handlers::pearregistry;
-use File::StripNondeterminism::handlers::png;
use File::StripNondeterminism::handlers::javaproperties;
-use File::StripNondeterminism::handlers::zip;
our($VERSION, $canonical_time, $clamp_time);
@@ -59,29 +52,29 @@ sub get_normalizer_for_file($) {
# ar
if (m/\.a$/ && _get_file_type($_) =~ m/ar archive/) {
- return \::StripNondeterminism::handlers::ar::normalize;
+ return _handler('ar');
}
# cpio
if (m/\.cpio$/ && _get_file_type($_) =~ m/cpio archive/) {
- return \::StripNondeterminism::handlers::cpio::normalize;
+ return _handler('cpio');
}
# gettext
if (m/\.g?mo$/ && _get_file_type($_) =~ m/GNU message catalog/) {
- return
\::StripNondeterminism::handlers::gettext::normalize;
+ return _handler('gettext');
}
# gzip
if (m/\.(gz|dz)$/ && _get_file_type($_) =~ m/gzip compressed data/) {
- return \::StripNondeterminism::handlers::gzip::normalize;
+ return _handler('gzip');
}
# jar
if (m/\.(jar|war|hpi|apk)$/
&& _get_file_type($_) =~ m/(Java|Zip) archive data/) {
- return \::StripNondeterminism::handlers::jar::normalize;
+ return _handler('jar');
}
# javadoc
if (m/\.html$/
&&
File::StripNondeterminism::handlers::javadoc::is_javadoc_file($_)) {
- return
\::StripNondeterminism::handlers::javadoc::normalize;
+ return _handler('javadoc');
}
# pear registry
if (
@@ -89,11 +82,11 @@ sub get_normalizer_for_file($) {
&&
File::StripNondeterminism::handlers::pearregistry::is_registry_file(
$_)
) {
- return
\::StripNondeterminism::handlers::pearregistry::normalize;
+ return _handler('pearregistry');
}
# PNG
if (m/\.png$/ && _get_file_type($_) =~ m/PNG image data/) {
- return \::StripNondeterminism::handlers::png::normalize;
+ return _handler('png');
}
# pom.properties, version.properties
if (
@@ -101,32 +94,50 @@ sub get_normalizer_for_file($) {
&&
File::StripNondeterminism::handlers::javaproperties::is_java_properties_file(
$_)
) {
- return
-
\::StripNondeterminism::handlers::javaproperties::normalize;
+ return _handler('javaproperties');
}
# zip
if (m/\.(zip|pk3|epub|whl|xpi|htb|zhfst|par)$/
&& _get_file_type($_) =~ m/Zip archive data|EPUB document/) {
- return \::StripNondeterminism::handlers::zip::normalize;
+ return _handler('zip');
}
return undef;
}
-our %typemap = (
- ar => \::StripNondeterminism::handlers::ar::normalize,
- cpio=> \::StripNondeterminism::handlers::cpio::normalize,
- gettext =>