Remove typechecker-only options from GlobalOptions to avoid code duplication
[hiphop-php.git] / hphp / doc / debug.profile
blob20bfe4866cb50ecb88869f93c25feac439ca72ff
2 <h2>Using Google CPU Profiler</h2>
4 Building with GOOGLE_CPU_PROFILER set lets you collect profiles from
5 the server or from the command line. However, our testing has found
6 that the server can get stalled while profiling for reasons
7 unknown. Still, it's possible to get enough requests in that the
8 profile can be significant.
10 There are two stages in profiling, collecting the profile and
11 processing it into a readable format. Collection is different on the
12 command line and server.
14 = Profiling from the command line
16 For building stand alone programs you need to link with libprofiler and
17 libunwind:
19  export LIBRARY_PATH=[path]/hphp/external/google-perftools/lib:\
20    [path]/hphp/external/libunwind/lib
21  g++ <my program>.cpp -lprofiler
23 With a compiled program, p, execute:
25   CPUPROFILE=p.prof CPUPROFILE_FREQUENCY=1000 p args
27 This will create a file p.prof when p finishes while taking samples 1000
28 times per second. The frequency can be changed: higher frequencies
29 will impact performance but lower frequencies will require a longer
30 run to collect a significant number of samples.
32 = Profiling from the server
34 Run
36   GET http://[server]:8088/prof-cpu-on
38 Then hit the server some number of times. When satisfied,
40   GET http://[server]:8088/prof-cpu-off
42 A file /hphp/pprof/[host]/hphp.prof should be created. The exact path is
43 configurable with the runtime option Debug.ProfilerOutputDir
44 (defaults to /tmp on production).
46 = Processing the profile
48 Use the tool pprof to process the profile. For example:
50   pprof --gif p p.prof > p.gif
52 This generates a gif with the callgraph of p.
54 Note that if you needed to strip the program, it's still possible
55 to use pprof if you call it on the unstripped version.