| OLD | NEW |
| 1 <HTML> | 1 <HTML> |
| 2 | 2 |
| 3 <HEAD> | 3 <HEAD> |
| 4 <title>pprof and Remote Servers</title> | 4 <title>pprof and Remote Servers</title> |
| 5 </HEAD> | 5 </HEAD> |
| 6 | 6 |
| 7 <BODY> | 7 <BODY> |
| 8 | 8 |
| 9 <h1><code>pprof</code> and Remote Servers</h1> | 9 <h1><code>pprof</code> and Remote Servers</h1> |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 get heap information. The actual url is controlled via the variable | 57 get heap information. The actual url is controlled via the variable |
| 58 <code>HEAP_PAGE</code> in the <code>pprof</code> script, so you | 58 <code>HEAP_PAGE</code> in the <code>pprof</code> script, so you |
| 59 can change it if you'd like.</p> | 59 can change it if you'd like.</p> |
| 60 | 60 |
| 61 <p>There are two ways to get this data. The first is to call</p> | 61 <p>There are two ways to get this data. The first is to call</p> |
| 62 <pre> | 62 <pre> |
| 63 MallocExtension::instance()->GetHeapSample(&output); | 63 MallocExtension::instance()->GetHeapSample(&output); |
| 64 </pre> | 64 </pre> |
| 65 <p>and have the server send <code>output</code> back as an HTTP | 65 <p>and have the server send <code>output</code> back as an HTTP |
| 66 response to <code>pprof</code>. <code>MallocExtension</code> is | 66 response to <code>pprof</code>. <code>MallocExtension</code> is |
| 67 defined in the header file <code>google/malloc_extension.h</code>.</p> | 67 defined in the header file <code>gperftools/malloc_extension.h</code>.</p> |
| 68 | 68 |
| 69 <p>Note this will only only work if the binary is being run with | 69 <p>Note this will only only work if the binary is being run with |
| 70 sampling turned on (which is not the default). To do this, set the | 70 sampling turned on (which is not the default). To do this, set the |
| 71 environment variable <code>TCMALLOC_SAMPLE_PARAMETER</code> to a | 71 environment variable <code>TCMALLOC_SAMPLE_PARAMETER</code> to a |
| 72 positive value, such as 524288, before running.</p> | 72 positive value, such as 524288, before running.</p> |
| 73 | 73 |
| 74 <p>The other way is to call <code>HeapProfileStart(filename)</code> | 74 <p>The other way is to call <code>HeapProfileStart(filename)</code> |
| 75 (from <code>heap-profiler.h</code>), continue to do work, and then, | 75 (from <code>heap-profiler.h</code>), continue to do work, and then, |
| 76 some number of seconds later, call <code>GetHeapProfile()</code> | 76 some number of seconds later, call <code>GetHeapProfile()</code> |
| 77 (followed by <code>HeapProfilerStop()</code>). The server can send | 77 (followed by <code>HeapProfilerStop()</code>). The server can send |
| (...skipping 30 matching lines...) Expand all Loading... |
| 108 get heap-profiling delta (growth) information. The actual url is | 108 get heap-profiling delta (growth) information. The actual url is |
| 109 controlled via the variable <code>GROWTH_PAGE</code> in the | 109 controlled via the variable <code>GROWTH_PAGE</code> in the |
| 110 <code>pprof</code> script, so you can change it if you'd like.</p> | 110 <code>pprof</code> script, so you can change it if you'd like.</p> |
| 111 | 111 |
| 112 <p>The server should respond by calling</p> | 112 <p>The server should respond by calling</p> |
| 113 <pre> | 113 <pre> |
| 114 MallocExtension::instance()->GetHeapGrowthStacks(&output); | 114 MallocExtension::instance()->GetHeapGrowthStacks(&output); |
| 115 </pre> | 115 </pre> |
| 116 <p>and sending <code>output</code> back as an HTTP response to | 116 <p>and sending <code>output</code> back as an HTTP response to |
| 117 <code>pprof</code>. <code>MallocExtension</code> is defined in the | 117 <code>pprof</code>. <code>MallocExtension</code> is defined in the |
| 118 header file <code>google/malloc_extension.h</code>.</p> | 118 header file <code>gperftools/malloc_extension.h</code>.</p> |
| 119 | 119 |
| 120 <p>Here's an example, from an actual Google webserver, of what the | 120 <p>Here's an example, from an actual Google webserver, of what the |
| 121 output should look like:</p> | 121 output should look like:</p> |
| 122 <pre> | 122 <pre> |
| 123 heap profile: 741: 812122112 [ 741: 812122112] @ growth | 123 heap profile: 741: 812122112 [ 741: 812122112] @ growth |
| 124 1: 1572864 [ 1: 1572864] @ 0x87da564 0x87db8a3 0x84787a4 0x846e851 0x
836d12f 0x834cd1c 0x8349ba5 0x10a3177 0x8349961 | 124 1: 1572864 [ 1: 1572864] @ 0x87da564 0x87db8a3 0x84787a4 0x846e851 0x
836d12f 0x834cd1c 0x8349ba5 0x10a3177 0x8349961 |
| 125 1: 1048576 [ 1: 1048576] @ 0x87d92e8 0x87d9213 0x87d9178 0x87d94d3 0x
87da9da 0x8a364ff 0x8a437e7 0x8ab7d23 0x8ab7da9 0x8ac7454 0x8348465 0x10a3161 0x
8349961 | 125 1: 1048576 [ 1: 1048576] @ 0x87d92e8 0x87d9213 0x87d9178 0x87d94d3 0x
87da9da 0x8a364ff 0x8a437e7 0x8ab7d23 0x8ab7da9 0x8ac7454 0x8348465 0x10a3161 0x
8349961 |
| 126 [...] | 126 [...] |
| 127 </pre> | 127 </pre> |
| 128 | 128 |
| 129 | 129 |
| 130 <h2> <A NAME="profile"><code><b>/pprof/profile</b></code></A> </h2> | 130 <h2> <A NAME="profile"><code><b>/pprof/profile</b></code></A> </h2> |
| 131 | 131 |
| 132 <p><code>pprof</code> asks for the url | 132 <p><code>pprof</code> asks for the url |
| 133 <code>/pprof/profile?seconds=XX</code> to get cpu-profiling | 133 <code>/pprof/profile?seconds=XX</code> to get cpu-profiling |
| 134 information. The actual url is controlled via the variable | 134 information. The actual url is controlled via the variable |
| 135 <code>PROFILE_PAGE</code> in the <code>pprof</code> script, so you can | 135 <code>PROFILE_PAGE</code> in the <code>pprof</code> script, so you can |
| 136 change it if you'd like.</p> | 136 change it if you'd like.</p> |
| 137 | 137 |
| 138 <p>The server should respond by calling | 138 <p>The server should respond by calling |
| 139 <code>ProfilerStart(filename)</code>, continuing to do its work, and | 139 <code>ProfilerStart(filename)</code>, continuing to do its work, and |
| 140 then, XX seconds later, calling <code>ProfilerStop()</code>. (These | 140 then, XX seconds later, calling <code>ProfilerStop()</code>. (These |
| 141 functions are declared in <code>google/profiler.h</code>.) The | 141 functions are declared in <code>gperftools/profiler.h</code>.) The |
| 142 application is responsible for picking a unique filename for | 142 application is responsible for picking a unique filename for |
| 143 <code>ProfilerStart()</code>. After calling | 143 <code>ProfilerStart()</code>. After calling |
| 144 <code>ProfilerStop()</code>, the server should read the contents of | 144 <code>ProfilerStop()</code>, the server should read the contents of |
| 145 <code>filename</code> and send them back as an HTTP response to | 145 <code>filename</code> and send them back as an HTTP response to |
| 146 <code>pprof</code>.</p> | 146 <code>pprof</code>.</p> |
| 147 | 147 |
| 148 <p>Obviously, to get useful profile information the application must | 148 <p>Obviously, to get useful profile information the application must |
| 149 continue to run in the XX seconds that the profiler is running. Thus, | 149 continue to run in the XX seconds that the profiler is running. Thus, |
| 150 the profile start-stop calls should be done in a separate thread, or | 150 the profile start-stop calls should be done in a separate thread, or |
| 151 be otherwise non-blocking.</p> | 151 be otherwise non-blocking.</p> |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 251 |
| 252 <p><code>pprof</code> itself does just this for local profiles (not | 252 <p><code>pprof</code> itself does just this for local profiles (not |
| 253 ones that talk to remote servers); look at the subroutine | 253 ones that talk to remote servers); look at the subroutine |
| 254 <code>GetProcedureBoundaries</code>.</p> | 254 <code>GetProcedureBoundaries</code>.</p> |
| 255 | 255 |
| 256 | 256 |
| 257 <hr> | 257 <hr> |
| 258 Last modified: Mon Jun 12 21:30:14 PDT 2006 | 258 Last modified: Mon Jun 12 21:30:14 PDT 2006 |
| 259 </body> | 259 </body> |
| 260 </html> | 260 </html> |
| OLD | NEW |