Thank you for the reply!

On Tuesday, November 11, 2014 3:25:25 AM UTC+11, Tim.Bunce wrote:
>
> The "... call from different interpreter ignored" message means 
> "call from different interpreter than the first one that enabled 
> profiling". 

So the 1-in-N sampling could be some on the basis of 1-in-N requests 
> that are handled by that thread. 


We run under mod-perl. I should have mentioned that before, sorry. From 
what I understand, mod-perl creates a pool of perl interpreters like this 
<http://modperlbook.org/html/24-3-1-Thread-Support.html>:

mod_perl 2.0 has [...] two classes of interpreters, parent and clone. A 
*parent* is like in mod_perl 1.0, where the main interpreter created at 
startup time compiles any preloaded Perl code. A *clone* is created from 
the parent using the Perl API perl_clone() function. At request time, 
parent interpreters are used only for making more clones, as the clones are 
the interpreters that actually handle requests.

Now when you say "the first [interpreter] that enabled profiling," you're 
talking about the initial load of Devel::NYTProf::Apache, right? As opposed 
to later calls of DB::enable_profiling(). Because I can see that loading 
the module immediately triggers the following log, even when NYTPROF is set 
to "start=no":
~ init_profiler for pid 22440, clock 1, tps 10000000, start 0, perldb 
0xf10, exitf 0x2

And I gather this happens because of the BEGIN { } block in 
Devel::NYTProf::Apache.

After that, under Apache MPM worker, all subsequent calls to 
DB::enable_profiling() fail like this:
~ enable_profile call from different interpreter ignored

If I have this right, the problem is it's no good loading NYTProf and 
letting it initialize in a mod-perl parent interpreter, because parent 
interpreters don't handle requests: only child interpreters do.

So today I've been trying to delay the loading of Devel::NYTProf::Apache 
until it's in a child interpreter. I kind of got this working, but the 
final output is not great... still useful, but NYTProf seems very confused 
and inaccurate, I guess due to being loaded so late. So this whole approach 
may be doomed. But anyway, what I found worked was not loading 
Devel::NYTProf::Apache until the web app decides it wants to profile a 
session, then calling "eval { require Devel::NYTProf::Apache; }".

This works intermittently. Under load, when mod-perl starts spitting out 
new interpreters, it fails a lot with "Devel/NYTProf.pm did not return a 
true value at /usr/lib/perl5/Devel/NYTProf/Apache.pm line 30." It also puts 
out lines like this:

NYTProf: perl interpreter address changed after init (threads/multiplicity 
not supported)

For fun, I tried unloading and reloading NYTProf but got segfaults.

Working intermittently is actually not so bad, since I only want to sample 
intermittently. But given the confused final output, it doesn't seem 
worthwhile.

So I'm afraid I'm stuck on how to follow your advice to sample "1-in-N 
requests that are handled by that thread." It seems if I load NYTProf 
early, like it wants, it will then ignore all DB::enable_profiling() calls, 
because they come from child interpreters. But if I load it late, it can't 
do its job.

Another approach would be to use a FastCGI backend connected via a 
> filesystem socket. Then, whenever it suits you, you can simply start a 
> separate single-threaded FastCGI backend process connected to that socket. 
>

I have tried, honestly, but completely failed to understand what this 
means. I know those words but not what you're describing.

Thank you again!

Max.

-- 
-- 
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:  [email protected]
To unsubscribe, email:  [email protected]
--- 
You received this message because you are subscribed to the Google Groups 
"Devel::NYTProf Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to