Can you send me the profile data file?
Tim.
On Thu, Jun 17, 2010 at 11:04:11AM -0700, Martin wrote:
> Before I get further lost in this I wonder if anyone else believes or
> has comments on the following extract of a Devel::NYTProf run. The
> code uses LWP::UserAgent in a POE server to retrieve ~ 30Mb file on
> the local 1Gb network (and it takes over 400s).
The overall numbers make sense though. The application run really does
take the amount of time nytprof says, and the subroutine times and
statement times are consistent. So I suspect perl not nytprof.
> I fail to see how line 158 below can take 320s.
> Run outside of the POE Server the same POST takes around 5s with this
> code: [...]
> and this is the same code being run inside the POE Server.
> Devel::NYTProf reports the top time in HTTP::Message::add_content like
> this:
>
> 149 sub add_content
> ...
> 151 7585 12.0ms my $self = shift;
> 152 7585 22.4ms $self->_content unless exists $self->{_content};
> 153 7585 14.5ms my $chunkref = \$_[0];
> 154 7585 14.7ms $chunkref = $$chunkref if ref($$chunkref); # legacy
> 155
> 156 7585 66.2ms 7585 149ms _utf8_downgrade($$chunkref);
> 157
> 158 7585 320s my $ref = ref($self->{_content});
> 159 7585 53.9ms if (!$ref) {
> 160 7585 365ms $self->{_content} .= $$chunkref;
> 161 }
Something very strange is going on.
Looking at the stream of statement timings I can see that that that line
in that file (fid 68) starts out only taking a small amount of time
Read 68:156 11 ticks
Read 68:158 35 ticks
Read 68:159 18 ticks
Read 68:160 67 ticks
but the time taken grows steadily, so later it's:
Read 68:156 11 ticks
Read 68:158 22197 ticks
Read 68:159 33 ticks
Read 68:160 284 ticks
and so it grows and grows until the final execution is:
Read 68:156 12 ticks
Read 68:158 888959 ticks
Read 68:159 64 ticks
Read 68:160 244 ticks
Nick, does this ring any bells with you?
Martin, please try with perl 5.10.1 as your 5.10.0 may be buggy.
Tim.
There were weird things with bless, overload and pathalogical hases
around the time of 5.10.0 but I didn't need to pay attention (since
we're using 5.8 .8 now and 5.12.1 soon) so I didn't.
Maybe Nicholas can shed some pumpkin light on it.
Please also give us your perl -V output, for the record.
> Thanks Tim for suggesting that.
You're welcome.
I'm glad NYTProf did "exactly what it said on the tin" :)
Tim.
No problem. I was just stating it for the record. I often do "stream
of thought" emails when I'm working on diagnosing a problem.
> I'm now also getting negative times for some statements time in subs:
(actually that's a subroutine profiler time for time spent in the sub)
> 49 1 19µs 1 -90.1s $out = $q->sendRequest(\%r);
> # spent - 90.1s making 1 call to XXX::Queue::sendRequest
I don't see sendRequest in the profile you sent me, but I do see some
negative times for subroutines. Looking at the table of all subs and
sorting by inclusive time gives me:
Subroutines
Calls P F Exclusive Inclusive
8 1 1 -429s -105s LWP::Protocol::collect
8 1 1 6.28ms -91.3s LWP::Protocol::http::request
8 1 1 2.00ms -91.2s LWP::UserAgent::send_request
8 5 1 1.08ms -91.2s LWP::UserAgent::request
8 1 1 525µs -91.2s LWP::UserAgent::simple_request
4 1 1 10.5ms -80.8s BET::Service::User::get_job_result
5 1 1 72.2ms -80.7s BET::Service::User::call_action
5 1 1 77.4ms -80.5s main::new_request
18 4 3 1.21ms -77.2s POE::Kernel::call
5 1 1 895µs -77.2s main::__ANON__[/home/jason/bet/server/service.pl:269]
5 1 1 534µs -77.2s POE::Wheel::ReadWrite::__ANON__[/usr/local/share/perl/5.10.0/POE/Wheel/ReadWrite.pm:293]
5 1 1 123µs -77.2s POE::Component::Server::TCP::__ANON__[/usr/local/share/perl/5.10.0/POE/Component/Server/TCP.pm:323]
208 2 1 25.5ms -76.8s POE::Kernel::_data_handle_enqueue_ready
250 3 1 12.1ms -74.9s POE::Session::_invoke_state
243 7 4 20.9ms -74.8s POE::Kernel::_dispatch_event
Recursion tends to cause odd timings but I'm not sure if that's the case here.
I've committed a change to add recursion details to the subroutine table.
The way timings are handled for subs that recurse is quite possibly broken.
Tim.
That's what I would have thought.
Assuming that the line number attribution is accurate, and it's something
in the hash lookup and reference taking, that's most strange. I don't think
that there's any copying involved.
On Fri, Jun 18, 2010 at 02:26:53PM +0100, Tim Bunce wrote:
> On Fri, Jun 18, 2010 at 05:47:50AM -0700, Martin wrote:
> >
> > I upgraded to Perl 5.10.1 and problem has gone away.
> > It is going to be a PITA to do this permanently but I seem to have
> > little choice. I've no idea what problem was fixed between 5.10.0 and
> > 5.10.1 which caused this, I had a quick look in perldelta but nothing
> > struck me.
>
> There were weird things with bless, overload and pathalogical hases
> around the time of 5.10.0 but I didn't need to pay attention (since
> we're using 5.8 .8 now and 5.12.1 soon) so I didn't.
>
> Maybe Nicholas can shed some pumpkin light on it.
>
> Please also give us your perl -V output, for the record.
-V for both would be interesting.
5.10.0 and 5.10.1 generate an identical optree for
my $ref = ref($self->{_content});
if (!$ref) {
$self->{_content} .= $$chunkref;
}
and the blame annotation: http://perl5.git.perl.org/perl.git/tree/maint-5.10
shows no changes to the code since 5.10.0 was shipped, so I can't see why it
would differ.
Nicholas Clark
> It may take a bit longer to try 5.10.1 as we have a huge number of
> modules in use but I'll have a go.
5.10.1 is binary compatible with 5.10.0 (if you build it with the same options)
So you don't (shouldn't) need to rebuild any modules.
Nicholas Clark
That's a curious configuration. On the plus side it does mean the binary
will have symbols. So you could use a sampling profiler[1]to probe where
perl is spending its time.
Tim.
[1] Like http://oprofile.sourceforge.net/about/
> --
> You've received this message because you are subscribed to
> the Devel::NYTProf Development User group.
>
> Group hosted at: http://groups.google.com/group/develnytprof-dev
> Project hosted at: http://perl-devel-nytprof.googlecode.com
> CPAN distribution: http://search.cpan.org/dist/Devel-NYTProf
>
> To post, email: develnyt...@googlegroups.com
> To unsubscribe, email: develnytprof-d...@googlegroups.com
>
If you run `perlbug` then you can file this is as a bug against core
perl and all the core perl 5 developers will hear about it in an
email. Most of what you've already posted would be great to copy/paste
into the bug report. It'll generate a formatted email to an address
something like per...@perl.org. You can then let it either send the
message directly if your system routes for external email or do what I
do which is then save the bug report as a text file and use my gmail
to send the exact "same" message. Please use the text formatting as
generated by perlbug.
Josh