Skip Menu |

This queue is for tickets about the version CPAN distribution.

Report information
The Basics
Id: 34590
Status: resolved
Priority: 0/
Queue: version

People
Owner: Nobody in particular
Requestors: dmuey [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: use XSLoader instead of DynaLoader to lower overhead
First off, thanks for this great module. I use it all the time as per PBP. unfortuntaely using it ads a lot to of overhead. Of special note is Config.pm which adds a lot of overhead. hal9000:~ dmuey$ perl -e 'use DynaLoader;for my $k(keys %INC) { print "$k: $INC{$k}\n"; }' Carp.pm: /System/Library/Perl/5.8.8/Carp.pm warnings.pm: /System/Library/Perl/5.8.8/warnings.pm warnings/register.pm: /System/Library/Perl/5.8.8/warnings/register.pm AutoLoader.pm: /System/Library/Perl/5.8.8/AutoLoader.pm strict.pm: /System/Library/Perl/5.8.8/strict.pm Exporter.pm: /System/Library/Perl/5.8.8/Exporter.pm vars.pm: /System/Library/Perl/5.8.8/vars.pm Config.pm: /System/Library/Perl/5.8.8/darwin-thread-multi-2level/Config.pm DynaLoader.pm: /System/Library/Perl/5.8.8/darwin-thread-multi-2level/DynaLoader.pm hal9000:~ dmuey$ hal9000:~ dmuey$ perl -e 'use XSLoader;for my $k(keys %INC) { print "$k: $INC{$k}\n"; }' XSLoader.pm: /System/Library/Perl/5.8.8/darwin-thread-multi-2level/XSLoader.pm hal9000:~ dmuey$ Its about 440K better on RSS: hal9000:~ dmuey$ perl -e 'use DynaLoader;print `ps u -p $$`;' USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND dmuey 13502 0.0 0.2 76944 1852 s000 S+ 7:55AM 0:00.01 perl -e use DynaLoader;print `ps u -p $$`; hal9000:~ dmuey$ perl -e 'use XSLoader;print `ps u -p $$`;' USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND dmuey 13504 0.0 0.1 76944 1416 s000 R+ 7:55AM 0:00.00 perl -e use XSLoader;print `ps u -p $$`; hal9000:~ dmuey$
This should keep everyone backwards compatible if you want: eval { require XSLoader; XSLoader::load('YourPackage', $VERSION); 1; } or do { require DynaLoader; push @ISA, 'DynaLoader'; bootstrap YourPackage $VERSION; };
Works great, patch will b e uploaded here soon. but in the meantime (note that VERSIONis still a version object and Config.pm is not in %INC) hal9000:~ dmuey$ perl -MData::Dumper -Mstrict -wle 'use version;my $VERSION=qv("0.2.1");print Dumper $VERSION, \%INC;' $VAR1 = bless( { 'qv' => 1, 'version' => [ 0, 2, 1 ] }, 'version' ); $VAR2 = { 'version/vxs.pm' => '/System/Library/Perl/Extras/5.8.8/darwin-thread-multi- 2level/version/vxs.pm', 'warnings/register.pm' => '/System/Library/Perl/5.8.8/warnings/register.pm', 'bytes.pm' => '/System/Library/Perl/5.8.8/bytes.pm', 'XSLoader.pm' => '/System/Library/Perl/5.8.8/darwin-thread-multi- 2level/XSLoader.pm', 'Carp.pm' => '/System/Library/Perl/5.8.8/Carp.pm', 'vars.pm' => '/System/Library/Perl/5.8.8/vars.pm', 'strict.pm' => '/System/Library/Perl/5.8.8/strict.pm', 'Exporter.pm' => '/System/Library/Perl/5.8.8/Exporter.pm', 'version.pm' => '/System/Library/Perl/Extras/5.8.8/darwin-thread-multi- 2level/version.pm', 'warnings.pm' => '/System/Library/Perl/5.8.8/warnings.pm', 'overload.pm' => '/System/Library/Perl/5.8.8/overload.pm', 'Data/Dumper.pm' => '/System/Library/Perl/5.8.8/darwin-thread-multi- 2level/Data/Dumper.pm' }; hal9000:~ dmuey$ Now with the original: hal9000:~ dmuey$ perl -MData::Dumper -Mstrict -wle 'use version;my $VERSION=qv("0.2.1");print Dumper $VERSION, \%INC;' $VAR1 = bless( { 'qv' => 1, 'version' => [ 0, 2, 1 ] }, 'version' ); $VAR2 = { 'version/vxs.pm' => '/System/Library/Perl/Extras/5.8.8/darwin-thread-multi- 2level/version/vxs.pm', 'warnings/register.pm' => '/System/Library/Perl/5.8.8/warnings/register.pm', 'bytes.pm' => '/System/Library/Perl/5.8.8/bytes.pm', 'XSLoader.pm' => '/System/Library/Perl/5.8.8/darwin-thread-multi- 2level/XSLoader.pm', 'Carp.pm' => '/System/Library/Perl/5.8.8/Carp.pm', 'vars.pm' => '/System/Library/Perl/5.8.8/vars.pm', 'strict.pm' => '/System/Library/Perl/5.8.8/strict.pm', 'Exporter.pm' => '/System/Library/Perl/5.8.8/Exporter.pm', 'version.pm' => '/System/Library/Perl/Extras/5.8.8/darwin-thread-multi- 2level/version.pm', 'warnings.pm' => '/System/Library/Perl/5.8.8/warnings.pm', 'AutoLoader.pm' => '/System/Library/Perl/5.8.8/AutoLoader.pm', 'overload.pm' => '/System/Library/Perl/5.8.8/overload.pm', 'Config.pm' => '/System/Library/Perl/5.8.8/darwin-thread-multi-2level/Config.pm', 'DynaLoader.pm' => '/System/Library/Perl/5.8.8/darwin-thread-multi- 2level/DynaLoader.pm', 'Data/Dumper.pm' => '/System/Library/Perl/5.8.8/darwin-thread-multi- 2level/Data/Dumper.pm' }; hal9000:~ dmuey$ Memory use: hal9000:~ dmuey$ perl -e 'print `ps u -p $$`;' USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND dmuey 13669 0.0 0.1 76944 1168 s000 R+ 10:23AM 0:00.00 perl -e print `ps u -p $$`; hal9000:~ dmuey$ perl -e 'use version;print `ps u -p $$`;' USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND dmuey 13671 0.0 0.2 76980 1820 s000 R+ 10:23AM 0:00.01 perl -e use version;print `ps u -p $$`; hal9000:~ dmuey$ orig: hal9000:~ dmuey$ perl -e 'print `ps u -p $$`;' USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND dmuey 13700 0.0 0.1 76944 1168 s000 R+ 10:25AM 0:00.00 perl -e print `ps u -p $$`; hal9000:~ dmuey$ perl -e 'use version;print `ps u -p $$`;' USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND dmuey 13702 3.7 0.2 76980 1944 s000 S+ 10:25AM 0:00.02 perl -e use version;print `ps u -p $$`; hal9000:~ dmuey$
eval or do patch to use XSLoader if possible and then default to DynaLoader if needed:
--- vxs.pm.orig 2008-04-01 10:18:19.000000000 -0500 +++ vxs.pm 2008-04-01 10:20:18.000000000 -0500 @@ -4,17 +4,22 @@ use 5.005_03; use strict; -require DynaLoader; use vars qw(@ISA $VERSION $CLASS ); -@ISA = qw(DynaLoader); - $VERSION = "0.70"; $CLASS = 'version::vxs'; -local $^W; # shut up the 'redefined' warning for UNIVERSAL::VERSION -bootstrap version::vxs if $] < 5.009; +eval { + require XSLoader; + XSLoader::load('version::vxs', $VERSION); + 1; +} or do { + require DynaLoader; + push @ISA, 'DynaLoader'; + local $^W; # shut up the 'redefined' warning for UNIVERSAL::VERSION + bootstrap version::vxs $VERSION; +}; # Preloaded methods go here.
From: jpeacock [...] cpan.org
On Tue Apr 01 11:28:21 2008, DMUEY wrote: Show quoted text
> eval or do patch to use XSLoader if possible and then default to > DynaLoader if needed:
I'll certainly consider this for inclusion in a future CPAN release, but you should *really* be running 0.74 (not 0.70), since that is the code that exists in Perl v5.10.0 (and hence is considered the standard release). There were substantial API changes between 0.70 and 0.74 (so much so that I have deleted from CPAN all prior releases). Thanks for the patch... John
From: dmuey [...] cpan.org
Show quoted text
> I'll certainly consider this for inclusion in a future CPAN release, but > you should *really* be running 0.74 (not 0.70), since that is the code
interesting, I didn't realize mine was old, thanks. I'd be happy to redo the patch if you like, but its simple enough I suppose :)
Subject: Re: [rt.cpan.org #34590] use XSLoader instead of DynaLoader to lower overhead
Date: Wed, 02 Apr 2008 10:29:58 -0400
To: bug-version [...] rt.cpan.org
From: John Peacock <john.peacock [...] havurah-software.org>
Daniel Muey via RT wrote: Show quoted text
> I'd be happy to redo the patch if you like, but its simple enough I suppose :)
Thanks, I've already checked in the changes. I just have to decide when I want to release the new version... John
Fixed in 0.75. Thanks for the patch! John