Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the devel-nytprof CPAN distribution.

Report information
The Basics
Id: 49303
Status: resolved
Priority: 0/
Queue: devel-nytprof

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

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



Subject: Option to force NYTProf to survive truncation
Download (untitled) / with headers
text/plain 1.2k
During a significant production performance event yesterday, we attempted to diagnose the problem by replicating the production dataset to a test environment and running the same code (a batch-mode application) for the previous and current releases under NYTProf. Since the size of the performance problem was 2 orders of magnitude (someone allowed an O(n^2) to slip into some ancillary code) it should have been easy to find the problem with only a minute or two out of the 2 hour batch run. However, we encountered problems with nytprofhtml during this process, because the mechanism by which we aborted the batch result seemed to result in an immediate exit that somehow failed to cleanup properly. Despite having all of the data from the run, nytprofhtml refused to generate the report because the file was "truncated". In many scenarios, this kind of thing is actually likely. NYTProf runs on applications that end with a segfault or some other kind of failure, for example. If there is any way to allow it, we would greatly appreciate some kind of --force style option that tells NYTProf to NOT fail on truncated dump files, and at least make a "best guess" of how the program ended. If it can survive unclean exits up to and including a seg fault or hard power failure, that would be awesome.
Subject: Re: [rt.cpan.org #49303] Option to force NYTProf to survive truncation
Date: Tue, 1 Sep 2009 09:47:08 +0100
To: Adam Kennedy via RT <bug-devel-nytprof [...] rt.cpan.org>
From: Tim Bunce <Tim.Bunce [...] pobox.com>
Download (untitled) / with headers
text/plain 1.6k
On Mon, Aug 31, 2009 at 09:06:01PM -0400, Adam Kennedy via RT wrote: Show quoted text
> > However, we encountered problems with nytprofhtml during this process, > because the mechanism by which we aborted the batch result seemed to > result in an immediate exit that somehow failed to cleanup properly. > > Despite having all of the data from the run, nytprofhtml refused to > generate the report because the file was "truncated".
Strictly speaking "somehow failed to cleanup properly" means that it didn't have "all of the data from the run". I presume you're refering to the pre-END phase, or perhaps pre-global-destruction. Show quoted text
> In many scenarios, this kind of thing is actually likely. NYTProf runs > on applications that end with a segfault or some other kind of failure, > for example.
There's a fair bit of data that can only be written to the file when the profile is being completed. A simple workaround could be just adding: END { DB::finish_profile() } http://search.cpan.org/~timb/Devel-NYTProf-2.10/lib/Devel/NYTProf.pm#RUN-TIME_CONTROL_OF_PROFILING Show quoted text
> If there is any way to allow it, we would greatly appreciate some kind > of --force style option that tells NYTProf to NOT fail on truncated dump > files, and at least make a "best guess" of how the program ended.
Try hacking it to not croak and see how far you get. It might not take much. (I'm swamped at the moment trying to find an elegant solution to the exception-thrown-from-xsub road block I'm currently facing.) Show quoted text
> If it can survive unclean exits up to and including a seg fault or hard > power failure, that would be awesome.
You might want to also use compress=0 so you loose less unflushed data. Tim.
Subject: Re: [rt.cpan.org #49303] Option to force NYTProf to survive truncation
Date: Wed, 2 Sep 2009 10:55:08 +1000
To: bug-devel-nytprof [...] rt.cpan.org
From: Adam Kennedy <adamkennedybackup [...] gmail.com>
Download (untitled) / with headers
text/plain 1.9k
2009/9/1 Tim Bunce via RT <bug-devel-nytprof@rt.cpan.org>: Show quoted text
> Strictly speaking "somehow failed to cleanup properly" means that it > didn't have "all of the data from the run". I presume you're refering to > the pre-END phase, or perhaps pre-global-destruction.
Possibly. Wearing the hat of a naive user, all I'm seeing is that I CTRL-C or SIGHUP or SIGKILL or segfault or $whatever, and it doesn't work. A lack of knowledge of the internal state and the failure mode for the software is part of the reason that I'm using NYTPRof in the first place. Show quoted text
>> In many scenarios, this kind of thing is actually likely. NYTProf runs >> on applications that end with a segfault or some other kind of failure, >> for example.
> > There's a fair bit of data that can only be written to the file when the > profile is being completed. > > A simple workaround could be just adding: > >    END { DB::finish_profile() } > > http://search.cpan.org/~timb/Devel-NYTProf-2.10/lib/Devel/NYTProf.pm#RUN-TIME_CONTROL_OF_PROFILING >
>> If there is any way to allow it, we would greatly appreciate some kind >> of --force style option that tells NYTProf to NOT fail on truncated dump >> files, and at least make a "best guess" of how the program ended.
> > Try hacking it to not croak and see how far you get. It might not take much.
It's a 250k line of code bohemoth, "hacking it not to croak" is a little tricky :) Show quoted text
> (I'm swamped at the moment trying to find an elegant solution to the > exception-thrown-from-xsub road block I'm currently facing.)
There is no urgency to this request, we worked around the problem and got our results. But while the problem of profiling runs aborting for uncontrolled reasons was fresh in my mind, I wanted to dump it into RT so it could be addressed at a later time. Show quoted text
>> If it can survive unclean exits up to and including a seg fault or hard >> power failure, that would be awesome.
> > You might want to also use compress=0 so you loose less unflushed data.
I'll have a look at that and see if it helps. Adam K
Download (untitled) / with headers
text/plain 588b
On Tue Sep 01 20:55:27 2009, adam@ali.as wrote: Show quoted text
> 2009/9/1 Tim Bunce via RT <bug-devel-nytprof@rt.cpan.org>:
> > > > A simple workaround could be just adding: > > > >    END { DB::finish_profile() } > >
I've found it may also help to do this in $SIG{INT}: $SIG{INT} = sub { DB::finish_profile(); exit 1; }; This was helpful while debugging a Catalyst HTTP server. It might be useful to document this clearly in the CAVEAT section or somewhere obvious. The existing documentation on finish_profile() doesn't really make it clear that this is the solution to many database file errors.
Subject: Re: [rt.cpan.org #49303] Option to force NYTProf to survive truncation
Date: Mon, 28 Sep 2009 10:02:39 +0100
To: Andrew Sterling Hanenkamp via RT <bug-devel-nytprof [...] rt.cpan.org>
From: Tim Bunce <Tim.Bunce [...] pobox.com>
Download (untitled) / with headers
text/plain 1.2k
On Sun, Sep 27, 2009 at 10:11:34PM -0400, Andrew Sterling Hanenkamp via RT wrote: Show quoted text
> > I've found it may also help to do this in $SIG{INT}: > > $SIG{INT} = sub { DB::finish_profile(); exit 1; }; > > This was helpful while debugging a Catalyst HTTP server. It might be > useful to document this clearly in the CAVEAT section or somewhere > obvious. The existing documentation on finish_profile() doesn't really > make it clear that this is the solution to many database file errors.
Great idea. Thanks. Taking that a little further, it would be handy to have an option to enable that for INT and perhaps some other signals. Something like this: --- lib/Devel/NYTProf/Core.pm (revision 862) +++ lib/Devel/NYTProf/Core.pm (working copy) @@ -22,6 +22,13 @@ for my $optval ( $NYTPROF =~ /((?:[^\\:]+|\\.)+)/g) { my ($opt, $val) = $optval =~ /^((?:[^\\=]+|\\.)+)=((?:[^\\=]+|\\.)+)\z/; s/\\(.)/$1/g for $opt, $val; + + if ($opt eq 'sigend' && $val) { + my @sigs = ($val eq '1') ? qw(INT HUP PIPE BUS SEGV) : split(/,/, $val); + $SIG{uc $_} = sub { DB::finish_profile(); exit 1; } for @sigs; + next; + } + DB::set_option($opt, $val); } } Then you wouldn't have to mess with the code. Tim.
I'm going to call this ticket resolved by the addition of the sigexit option.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.