On Thu, Mar 05, 2009 at 01:21:37PM -0800, Coke wrote:
>
> Anyone have a workaround for the Storable issue yet? (I have the same
> issue with a fresh 5.10 install on OS X 10.4.11)
>
> I am able to generate an nytprof.out file, but get a similar Storable
> not found error when trying to run nytprofhtml.
>
> Tim - any guidance welcome.
You and 'tcbarrett' seem keen, great!
Here's a summary of the problem and what we can do about it...
AutoLoader (or rather, AutoSplit,
http://search.cpan.org/perldoc?AutoSplit)
writes an autosplit.ix containing a bunch of stubs, and a bunch of
foo.al files, one per AutoLoad'able sub. AutoLoader loads the autosplit.ix
file for the module that's 'use'd it, and supplies an AUTOLOADer that
loads the
foo.al for whatever sub is used.
From NYTProf's perspective, with trace=2, we see this sequence of fids
(file id's) being assigned:
> New fid 2 (after 1:7 ) 2 e0:0 /usr/lib/perl5/5.8.8/i386-linux-thread-multi/POSIX.pm
> New fid 5 (after 3:159 ) 2 e0:0 /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto/POSIX/autosplit.ix
> New fid 6 (after 3:961 ) 2 e0:0 ../../lib/POSIX.pm /tmp/t/../../lib/POSIX.pm
(there are two paths on that last line because the filename perl has is
relative, so NYTProf tries to determine the absolute path by prepending
the current working directory.)
I'll ignore the autosplit.ix as it's not a problem.
The problem is that the
foo.al files contain a #line directive like
#line 120 "../../lib/POSIX.pm (autosplit into ../../lib/auto/POSIX/
errno.al)"
which perl dutifully accepts as the line number and filename.
So NYTProf see the filename as
"../../lib/POSIX.pm (autosplit into ../../lib/auto/POSIX/
errno.al)"
It's smart enough to strip off the " (autosplit..." suffix, but that's all.
So we're left with a relative filename that bears little relation to reality.
What we really want to happen is for get_file_id() in NYTProf.xs to
return the same fid for both these strings:
"/usr/lib/perl5/5.8.8/i386-linux-thread-multi/POSIX.pm"
"../../lib/POSIX.pm (autosplit into ../../lib/auto/POSIX/
errno.al)"
A slight complication is that get_file_id needs to be _very_ fast.
That means we need both strings to be in the hash table, so when
an autosplit entry is added we need to detect that and search for the
corresponding 'parent' fid and then assign the same fid to the autosplit
entry.
Here's a sketch of the steps I'd take (possibly wrong and probably
incomplete :-) ...
[... deleted ...]
I did write it out but then I figured it would be easier to do the
structural change myself and leave the more, er, interesting parts to
you :)
See r694
Now all you need to do is write find_autosplit_parent() :-)
That needs to iterate over the hash, like write_cached_fids() does,
and find an entry with a .key that 'matches' the file_name argument.
So for the example above, "../../lib/POSIX.pm (autosplit ...."
should match the "..../i386-linux-thread-multi/POSIX.pm" entry.
Clearly ignoring the directory portion is essential. I'd also
suggest not exiting the loop early, so you get the most recent
fid that matches, as that's most likely to be the right one.
I guess you can decide between yourselves who writes the code and who
writes the tests. Or have a race... both do both and I'll pick the
winner :)
Tim.