CC: | mike [...] nrdvana.net |
Subject: | Speed up module load time (0.55s for me) |
DateTime is an amazingly useful module! Unfortunately it isn't very
suitable for quick commandline usage, because it adds half a second
delay to command execution.
Also, because DateTime is used by so many other modules, it makes many
others unsuitable for small shell utilities.
I was wondering if you could take a look at the things it includes, and
either avoid modules that aren't strictly necessary, or load some lesser
used features on demand via 'require' within methods.
A quick review of strace output shows a long delay following perl
opening the 'utf8.pm' module.
Here's the output of
strace -e trace=open -r perl -e 'use DateTime;'
0.000000 open("/etc/ld.so.cache", O_RDONLY) = 3
0.000427 open("/usr/lib/libperl.so.5.12", O_RDONLY) = 3
0.000531 open("/lib/libc.so.6", O_RDONLY) = 3
0.000888 open("/lib/libdl.so.2", O_RDONLY) = 3
0.000601 open("/lib/libm.so.6", O_RDONLY) = 3
0.000449 open("/lib/libcrypt.so.1", O_RDONLY) = 3
0.003186 open("/usr/lib/locale/locale-archive",
O_RDONLY|O_LARGEFILE) = 3
0.000632 open("/dev/urandom", O_RDONLY|O_LARGEFILE) = 3
0.002876 open("/dev/null", O_RDONLY|O_LARGEFILE) = 3
0.002172 open("/usr/lib/perl5/site_perl/5.12.4/i686-
linux/DateTime.pm", O_RDONLY|O_LARGEFILE) = 4
0.002987 open("/usr/lib/perl5/5.12.4/strict.pm",
O_RDONLY|O_LARGEFILE) = 5
0.004273 open("/usr/lib/perl5/5.12.4/warnings.pm",
O_RDONLY|O_LARGEFILE) = 5
0.013314 open("/usr/lib/perl5/5.12.4/Carp.pm",
O_RDONLY|O_LARGEFILE) = 5
0.010418 open("/usr/lib/perl5/5.12.4/Exporter.pm",
O_RDONLY|O_LARGEFILE) = 5
0.004610 open("/usr/lib/perl5/site_perl/5.12.4/i686-
linux/DateTime/Duration.pm", O_RDONLY|O_LARGEFILE) = 5
0.001572 open("/usr/lib/perl5/site_perl/5.12.4/i686-
linux/DateTime/Helpers.pm", O_RDONLY|O_LARGEFILE) = 6
0.001554 open("/usr/lib/perl5/vendor_perl/5.12.4/i686-
linux/Scalar/Util.pm", O_RDONLY|O_LARGEFILE) = 7
0.002458 open("/usr/lib/perl5/5.12.4/vars.pm",
O_RDONLY|O_LARGEFILE) = 8
0.002588 open("/usr/lib/perl5/5.12.4/warnings/register.pm",
O_RDONLY|O_LARGEFILE) = 9
0.006139 open("/usr/lib/perl5/vendor_perl/5.12.4/i686-
linux/List/Util.pm", O_RDONLY|O_LARGEFILE) = 7
0.003878 open("/usr/lib/perl5/5.12.4/XSLoader.pm",
O_RDONLY|O_LARGEFILE) = 7
0.004082 open("/usr/lib/perl5/vendor_perl/5.12.4/i686-
linux/auto/List/Util/Util.so", O_RDONLY) = 7
0.002693 open("/usr/lib/perl5/site_perl/5.12.4/i686-
linux/Params/Validate.pm", O_RDONLY|O_LARGEFILE) = 6
0.001839
open("/usr/lib/perl5/site_perl/5.12.4/Module/Implementation.pm",
O_RDONLY|O_LARGEFILE) = 7
0.001585 open("/usr/lib/perl5/site_perl/5.12.4/Module/Runtime.pm",
O_RDONLY|O_LARGEFILE) = 8
0.007459 open("/usr/lib/perl5/site_perl/5.12.4/Try/Tiny.pm",
O_RDONLY|O_LARGEFILE) = 8
0.007638 open("/usr/lib/perl5/site_perl/5.12.4/i686-
linux/Params/Validate/Constants.pm", O_RDONLY|O_LARGEFILE) = 7
0.005338 open("/usr/lib/perl5/site_perl/5.12.4/i686-
linux/Params/Validate/XS.pm", O_RDONLY|O_LARGEFILE) = 6
0.002735 open("/usr/lib/perl5/site_perl/5.12.4/i686-
linux/auto/Params/Validate/XS/XS.so", O_RDONLY) = 6
0.003537 open("/usr/lib/perl5/5.12.4/overload.pm",
O_RDONLY|O_LARGEFILE) = 6
0.007881 open("/usr/lib/perl5/5.12.4/constant.pm",
O_RDONLY|O_LARGEFILE) = 6
0.014536 open("/usr/lib/perl5/site_perl/5.12.1/DateTime/Locale.pm",
O_RDONLY|O_LARGEFILE) = 5
0.002066
open("/usr/lib/perl5/site_perl/5.12.1/DateTime/Locale/Base.pm",
O_RDONLY|O_LARGEFILE) = 6
0.001519 open("/usr/lib/perl5/site_perl/5.12.4/i686-
linux/List/MoreUtils.pm", O_RDONLY|O_LARGEFILE) = 7
0.002608 open("/usr/lib/perl5/5.12.4/i686-linux/DynaLoader.pm",
O_RDONLY|O_LARGEFILE) = 8
0.002466 open("/usr/lib/perl5/5.12.4/i686-linux/Config.pm",
O_RDONLY|O_LARGEFILE) = 9
0.009498 open("/usr/lib/perl5/5.12.4/AutoLoader.pm",
O_RDONLY|O_LARGEFILE) = 8
0.006735 open("/usr/lib/perl5/5.12.4/i686-linux/Config_heavy.pl",
O_RDONLY|O_LARGEFILE) = 8
0.009558 open("/usr/lib/perl5/5.12.4/i686-linux/Config_git.pl",
O_RDONLY|O_LARGEFILE) = 8
0.003216 open("/usr/lib/perl5/site_perl/5.12.4/i686-
linux/auto/List/MoreUtils/MoreUtils.so", O_RDONLY) = 8
0.017674
open("/usr/lib/perl5/site_perl/5.12.1/DateTime/Locale/Catalog.pm",
O_RDONLY|O_LARGEFILE) = 6
0.002712 open("/usr/lib/perl5/5.12.4/utf8.pm",
O_RDONLY|O_LARGEFILE) = 7
0.261864
open("/usr/lib/perl5/site_perl/5.12.1/DateTime/TimeZone.pm",
O_RDONLY|O_LARGEFILE) = 5
0.002128
open("/usr/lib/perl5/site_perl/5.12.1/DateTime/TimeZone/Catalog.pm",
O_RDONLY|O_LARGEFILE) = 6
0.015146
open("/usr/lib/perl5/site_perl/5.12.1/DateTime/TimeZone/Floating.pm",
O_RDONLY|O_LARGEFILE) = 6
0.003154 open("/usr/lib/perl5/5.12.4/base.pm",
O_RDONLY|O_LARGEFILE) = 7
0.006219
open("/usr/lib/perl5/site_perl/5.12.1/DateTime/TimeZone/OffsetOnly.pm",
O_RDONLY|O_LARGEFILE) = 7
0.002345
open("/usr/lib/perl5/site_perl/5.12.1/DateTime/TimeZone/UTC.pm",
O_RDONLY|O_LARGEFILE) = 8
0.005778
open("/usr/lib/perl5/site_perl/5.12.1/DateTime/TimeZone/Local.pm",
O_RDONLY|O_LARGEFILE) = 6
0.001782 open("/usr/lib/perl5/vendor_perl/5.12.4/i686-
linux/File/Spec.pm", O_RDONLY|O_LARGEFILE) = 7
0.002111 open("/usr/lib/perl5/vendor_perl/5.12.4/i686-
linux/File/Spec/Unix.pm", O_RDONLY|O_LARGEFILE) = 7
0.024346 open("/usr/lib/perl5/site_perl/5.12.4/Math/Round.pm",
O_RDONLY|O_LARGEFILE) = 5
0.002417 open("/usr/lib/perl5/5.12.4/i686-linux/POSIX.pm",
O_RDONLY|O_LARGEFILE) = 6
0.001259 open("/usr/lib/perl5/5.12.4/i686-
linux/auto/POSIX/autosplit.ix", O_RDONLY|O_LARGEFILE) = 7
0.006308 open("/usr/lib/perl5/5.12.4/i686-linux/Fcntl.pm",
O_RDONLY|O_LARGEFILE) = 7
0.002466 open("/usr/lib/perl5/5.12.4/i686-
linux/auto/Fcntl/Fcntl.so", O_RDONLY) = 8
0.008151 open("/usr/lib/perl5/5.12.4/Tie/Hash.pm",
O_RDONLY|O_LARGEFILE) = 7
0.005231 open("/usr/lib/perl5/5.12.4/i686-
linux/auto/POSIX/POSIX.so", O_RDONLY) = 6
0.003182 open("/usr/share/locale/locale.alias", O_RDONLY) = 6
0.000942 open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libc.mo",
O_RDONLY) = -1 ENOENT (No such file or directory)
0.000182 open("/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo",
O_RDONLY) = -1 ENOENT (No such file or directory)
0.000345 open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo",
O_RDONLY) = -1 ENOENT (No such file or directory)
0.000155 open("/usr/share/locale/en.UTF-8/LC_MESSAGES/libc.mo",
O_RDONLY) = -1 ENOENT (No such file or directory)
0.000136 open("/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo",
O_RDONLY) = -1 ENOENT (No such file or directory)
0.000132 open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY)
= -1 ENOENT (No such file or directory)
0.000282 open("/usr/lib/perl5/5.12.4/i686-
linux/auto/POSIX/load_imports.al", O_RDONLY|O_LARGEFILE) = 6
0.007776 open("/usr/lib/perl5/5.12.4/Exporter/Heavy.pm",
O_RDONLY|O_LARGEFILE) = 6
0.039999 open("/usr/lib/perl5/5.12.4/integer.pm",
O_RDONLY|O_LARGEFILE) = 5
0.041378 open("/usr/lib/perl5/site_perl/5.12.4/i686-
linux/auto/DateTime/DateTime.so", O_RDONLY) = 4
0.001480 open("/usr/lib/perl5/site_perl/5.12.4/i686-
linux/DateTime/Infinite.pm", O_RDONLY|O_LARGEFILE) = 4
0.006546
open("/usr/lib/perl5/site_perl/5.12.1/DateTime/Locale/en_US.pm",
O_RDONLY|O_LARGEFILE) = 4
0.002057
open("/usr/lib/perl5/site_perl/5.12.1/DateTime/Locale/en.pm",
O_RDONLY|O_LARGEFILE) = 5
0.002065
open("/usr/lib/perl5/site_perl/5.12.1/DateTime/Locale/root.pm",
O_RDONLY|O_LARGEFILE) = 6