[rt.cpan.org #106142] [Patch] Preload dependencies for PDL and PDL::NiceSlice

[email protected] ("Shawn Laffan via RT")
Newsgroups perl.par
Message-ID <[email protected]>
Sun Aug 02 00:48:42 2015: Request 106142 was acted upon.
Transaction: Correspondence added by SLAFFAN
       Queue: Module-ScanDeps
     Subject: [Patch] Preload dependencies for PDL and PDL::NiceSlice
   Broken in: (no value)
    Severity: (no value)
       Owner: Nobody
  Requestors: [email protected]
      Status: open
 Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=106142 >


On Wed Jul 29 17:50:53 2015, SLAFFAN wrote:
> Thanks.  The PDL::NiceSlice approach is much simpler.
> 
> If I can get a chance I'll look into the PDL code to see what sort of
> calls are used.
> 
> Regards,
> Shawn.
> 
> 
> On Wed Jul 29 11:23:33 2015, RSCHUPP wrote:
> > On 2015-07-29 07:50:35, SLAFFAN wrote:
> >
> > > use PDL;
> > > use PDL::NiceSlice;
> > >  my $x = pdl [[2,3,4],[1,2,3]];
> > > print $x(1,);
> > > print $x;
> >
> >
> > I agree on the %Preload rule for PDL/NiceSlice.pm, it can be made
> > more
> > robust as
> >
> > 'PDL/NiceSlice.pm' => 'sub',
> >
> > but the rule for PDL.pm needs further investigation. Somehow
> > utf8_heavy.pl is
> > needed... Maybe this was caused by rev 1501 in
> > https://www.openfoundry.org/svn/par
> >  when I removed the scan rule that says
> >
> > Foo::Bar::quux(...)
> >
> > or
> >
> > Foo::Bar->quux(...)
> >
> > implies we should add a dependency on Foo::Bar.
> >
> > Cheers, Roderich
> >
> >


It looks like the change in rev 1501 is not the cause.  I modified the regexp to use a negative lookbehind to avoid false positives on $foo->bar->baz, and added it into scan_chunk, but utf8_heavy.pl was not packed.  I did not check for Foo::Bar::baz(), though.

return $1 if (/(?<!\W) \b (\w+(?:::\w+)*) \s* (?:->)/x and $1 ne 'Tk' and $1 ne 'shift' and $1 ne '__PACKAGE__');

A bit of further searching through the PDL code indicated File::Map was a pinch-point, so I added some more Preload rules as a check (see below).  These seem to work, but need further investigation since they are not generalised.

File::Map is loaded in PDL::Core, PDL::IO::FlexRaw and PDL::IO::FastRaw using a string eval.   From PDL::Core:

eval 'use File::Map 0.47 qw(:all)';


As a quick experiment, I added the following preload rules to Module::ScanDeps.  The explicit listing of unicore/Heavy.pl is needed because it is not found through the utf8.pm preload sub.  I am sure there is a better way, but maybe this helps locate the source of the problem?


    'File/Map.pm' => ['utf8.pm', 'unicore/Heavy.pl'],
    'PDL'         => ['PDL/Core.pm'],
    'PDL/Core.pm' => ['File/Map.pm'],


When I then run pp on the script below, explicitly loading File:Map, the packed executable works.

use PDL;
use File::Map;
my $x = pdl [[2,3,4],[1, 2, 3]]; 
print $x;


However, if I comment out the 'use File::Map' line it does not pack utf8_heavy.pl, so the preload rules above are clearly wrong.

Instrumenting _glob_in_inc to print to stdout whenever unico[rd]e is passed as the subdir argument has no effect, so I assume the utf8.pm preload sub is not being run for the above preload rules.


Hopefully the above is helpful.  

Regards,
Shawn.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.