1Devel::NYTProf::Apache(U3s)er Contributed Perl DocumentatDieovnel::NYTProf::Apache(3)
2
3
4
6 Devel::NYTProf::Apache - Profile mod_perl applications with
7 Devel::NYTProf
8
10 # in your Apache config file with mod_perl installed
11 PerlPassEnv NYTPROF
12 PerlModule Devel::NYTProf::Apache
13
14 If you're using virtual hosts with "PerlOptions" that include either
15 "+Parent" or "+Clone" then see "VIRTUAL HOSTS" below.
16
18 This module allows mod_perl applications to be profiled using
19 "Devel::NYTProf".
20
21 If the NYTPROF environment variable isn't set at the time
22 Devel::NYTProf::Apache is loaded then Devel::NYTProf::Apache will issue
23 a warning and default it to:
24
25 file=/tmp/nytprof.$$.out:addpid=1:endatexit=1
26
27 The file actually created by NTProf will also have the process id
28 appended to it because the "addpid" option is enabled by default.
29
30 See "ENVIRONMENT VARIABLES" in Devel::NYTProf for more details on the
31 settings effected by this environment variable.
32
33 Try using "PerlPassEnv" in your httpd.conf if you can set the NYTPROF
34 environment variable externally. Note that if you set the NYTPROF
35 environment variable externally then the file name obviously can't
36 include the parent process id. For example, to set stmts=0 externally,
37 use:
38
39 NYTPROF=file=/tmp/nytprof.out:out:addpid=1:endatexit=1:stmts=0
40
41 Each profiled mod_perl process will need to have terminated cleanly
42 before you can successfully read the profile data file. The simplest
43 approach is to start the httpd, make some requests (e.g., 100 of the
44 same request), then stop it and process the profile data.
45
46 Alternatively you could send a TERM signal to the httpd worker process
47 to terminate that one process. The parent httpd process will start up
48 another one for you ready for more profiling.
49
50 Example httpd.conf
51 It's usually a good idea to use just one child process when profiling,
52 which you can do by setting the "MaxClients" to 1 in httpd.conf.
53
54 Set "MaxRequestsPerChild" to 0 to avoid worker processes exiting and
55 restarting during the profiling, which would split the profile data
56 across multiple files.
57
58 Using an "IfDefine" blocks lets you leave the profile configuration in
59 place and enable it whenever it's needed by adding "-D NYTPROF" to the
60 httpd startup command line.
61
62 <IfDefine NYTPROF>
63 MaxClients 1
64 MaxRequestsPerChild 0
65 PerlModule Devel::NYTProf::Apache
66 </IfDefine>
67
68 With that configuration you should get two profile files, one for the
69 parent process and one for the worker.
70
72 If your httpd configuration includes virtual hosts with "PerlOptions"
73 that include either "+Parent" or "+Clone" then mod_perl2 will create a
74 new perl interpreter to handle requests for that virtual host. This
75 causes some issues for profiling.
76
77 If "Devel::NYTProf::Apache" is loaded in the top-level configuration
78 then activity in any virtual hosts that use their own perl interpreter
79 won't be profiled. Normal virtual hosts will be profiled just fine.
80
81 You can profile a single virtual host that uses its own perl
82 interpreter by loading "Devel::NYTProf::Apache" inside the
83 configuration for that virtual host. In this case do not use
84 "PerlModule" directive. You need to use a "Perl" directive instead,
85 like this:
86
87 <VirtualHost *:1234>
88 ...
89 <Perl> use Devel::NYTProf::Apache; </Perl>
90 ...
91 </VirtualHost>
92
94 Profiling mod_perl on Windows is not supported because NYTProf
95 currently doesn't support threads.
96
98 Truncated profile: Profiles for large applications can take a while to
99 write to the disk. Allow sufficient time after stopping apache, or
100 check the process has actually exited, before trying to read the
101 profile.
102
103 Truncated profile: The mod_perl child_terminate() function terminates
104 the child without giving perl an opportunity to cleanup. Since
105 "Devel::NYTProf::Apache" doesn't intercept the mod_perl
106 child_terminate() function (yet) the profile will be corrupted if it's
107 called. You're most likely to encounter this when using
108 Apache::SizeLimit, so you may want to disable it while profiling.
109
111 Devel::NYTProf
112
114 Adam Kaplan, "<akaplan at nytimes.com>" Tim Bunce,
115 <http://www.tim.bunce.name> and <http://blog.timbunce.org> Steve
116 Peters, "<steve at fisharerojo.org>"
117
119 Copyright (C) 2008 by Adam Kaplan and The New York Times Company.
120 Copyright (C) 2008 by Steve Peters.
121 Copyright (C) 2008-2012 by Tim Bunce.
122
123 This library is free software; you can redistribute it and/or modify it
124 under the same terms as Perl itself, either Perl version 5.8.8 or, at
125 your option, any later version of Perl 5 you may have available.
126
127
128
129perl v5.30.1 2020-01-29 Devel::NYTProf::Apache(3)