Pull profiling dependency from Chromium
Profiling can be enabled by setting profiling=1 in gyp, e.g. GYP_DEFINES="profiling=1" gclient runhooks To turn on heap profiling, use the HEAPPROFILE environment variable to specify a filename for the heap profile dump, e.g. HEAPPROFILE=/tmp/heapprofile out/Release/packager ... To turn on cpu profiling, use the CPUPROFILE environment variable to specify a filename for the cpu profile dump, e.g. CPUPROFILE=/tmp/cpuprofile out/Release/packager ... Note that profiling may not work for debug builds, so use release build if possible. See docs/linux_profiling.md for details. This change will help identify and resolve problem behind Issue #61. Change-Id: I6f85a04ed82dd0cb3588e6b38e8ceb68dac6c436
This commit is contained in:
parent
09d1c2ce9f
commit
9c95309c12
|
@ -20,7 +20,7 @@
|
||||||
/packager/third_party/libwebm/src/
|
/packager/third_party/libwebm/src/
|
||||||
/packager/third_party/llvm-build/
|
/packager/third_party/llvm-build/
|
||||||
/packager/third_party/modp_b64/
|
/packager/third_party/modp_b64/
|
||||||
/packager/third_party/openssl/
|
/packager/third_party/tcmalloc/
|
||||||
/packager/third_party/webm-tools/src/
|
/packager/third_party/webm-tools/src/
|
||||||
/packager/third_party/yasm/source/patched-yasm/
|
/packager/third_party/yasm/source/patched-yasm/
|
||||||
/packager/third_party/zlib/
|
/packager/third_party/zlib/
|
||||||
|
|
3
DEPS
3
DEPS
|
@ -54,6 +54,9 @@ deps = {
|
||||||
"src/packager/third_party/modp_b64":
|
"src/packager/third_party/modp_b64":
|
||||||
Var("chromium_git") + "/chromium/src/third_party/modp_b64@3a0e3b4ef6c54678a2d14522533df56b33b56119",
|
Var("chromium_git") + "/chromium/src/third_party/modp_b64@3a0e3b4ef6c54678a2d14522533df56b33b56119",
|
||||||
|
|
||||||
|
"src/packager/third_party/tcmalloc/chromium":
|
||||||
|
Var("chromium_git") + "/chromium/src/third_party/tcmalloc/chromium@fa1492f75861094061043a17c0f779c3d35780bf",
|
||||||
|
|
||||||
"src/packager/third_party/webm-tools/src":
|
"src/packager/third_party/webm-tools/src":
|
||||||
Var("chromium_git") + "/webm/webm-tools@702ff3e4bb462b24464a202f8fcf9f65cc44b6e5",
|
Var("chromium_git") + "/webm/webm-tools@702ff3e4bb462b24464a202f8fcf9f65cc44b6e5",
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
# Linux Profiling
|
||||||
|
|
||||||
|
Profiling code is enabled when the `use_allocator` variable in gyp is set to
|
||||||
|
`tcmalloc` (currently the default) and `profiling` variable in gyp is set to
|
||||||
|
`1`. That will build the tcmalloc library, including the cpu profiling and heap
|
||||||
|
profiling code into edash-packager, e.g.
|
||||||
|
|
||||||
|
GYP_DEFINES='profiling=1 use_allocator="tcmalloc"' gclient runhooks
|
||||||
|
|
||||||
|
If the stack traces in your profiles are incomplete, this may be due to missing
|
||||||
|
frame pointers in some of the libraries. A workaround is to use the
|
||||||
|
`linux_keep_shadow_stacks=1` gyp option. This will keep a shadow stack using the
|
||||||
|
`-finstrument-functions` option of gcc and consult the stack when unwinding.
|
||||||
|
|
||||||
|
## CPU Profiling
|
||||||
|
|
||||||
|
In order to enable cpu profiling, run edash-packager with the environment
|
||||||
|
variable `CPUPROFILE` set to a filename. For example:
|
||||||
|
|
||||||
|
CPUPROFILE=/tmp/cpuprofile out/Release/packager
|
||||||
|
|
||||||
|
The cpu profile will be dumped periodically to the filename specified in the
|
||||||
|
CPUPROFILE environment variable. You can then analyze the dumps using the pprof
|
||||||
|
script (packager/third_party/tcmalloc/chromium/src/pprof). For example,
|
||||||
|
|
||||||
|
pprof --gv out/Release/packager /tmp/cpuprofile
|
||||||
|
|
||||||
|
This will generate a visual representation of the cpu profile as a postscript
|
||||||
|
file and load it up using `gv`. For more powerful commands, please refer to the
|
||||||
|
pprof help output and the google-perftools documentation.
|
||||||
|
|
||||||
|
For further information, please refer to
|
||||||
|
http://google-perftools.googlecode.com/svn/trunk/doc/cpuprofile.html.
|
||||||
|
|
||||||
|
## Heap Profiling
|
||||||
|
|
||||||
|
To turn on the heap profiler on edash-packager, use the `HEAPPROFILE`
|
||||||
|
environment variable to specify a filename for the heap profile. For example:
|
||||||
|
|
||||||
|
HEAPPROFILE=/tmp/heapprofile out/Release/packager
|
||||||
|
|
||||||
|
The heap profile will be dumped periodically to the filename specified in the
|
||||||
|
`HEAPPROFILE` environment variable. The dumps can be analyzed using the same
|
||||||
|
command as cpu profiling above.
|
||||||
|
|
||||||
|
For further information, please refer to
|
||||||
|
http://google-perftools.googlecode.com/svn/trunk/doc/heapprofile.html.
|
||||||
|
|
||||||
|
Some tests fork short-living processes which have a small memory footprint. To
|
||||||
|
catch those, use the `HEAP_PROFILE_ALLOCATION_INTERVAL` environment variable.
|
||||||
|
|
||||||
|
#### Dumping a profile of a running process
|
||||||
|
|
||||||
|
To programmatically generate a heap profile before exit, use code like:
|
||||||
|
|
||||||
|
#include "packager/third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h"
|
||||||
|
|
||||||
|
// "foobar" will be included in the message printed to the console
|
||||||
|
HeapProfilerDump("foobar");
|
||||||
|
|
||||||
|
Then add allocator.gyp dependency to the target with the above change:
|
||||||
|
|
||||||
|
'conditions': [
|
||||||
|
['profiling==1', {
|
||||||
|
'dependencies': [
|
||||||
|
'base/allocator/allocator.gyp:allocator',
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
],
|
||||||
|
|
||||||
|
Or you can use gdb to attach at any point:
|
||||||
|
|
||||||
|
1. Attach gdb to the process: `$ gdb -p 12345`
|
||||||
|
2. Cause it to dump a profile: `(gdb) p HeapProfilerDump("foobar")`
|
||||||
|
3. The filename will be printed on the console, e.g.
|
||||||
|
"`Dumping heap profile to heap.0001.heap (foobar)`"
|
||||||
|
|
||||||
|
## Reference
|
||||||
|
|
||||||
|
[Linux Profiling in Chromium](https://chromium.googlesource.com/chromium/src/+/master/docs/linux_profiling.md)
|
|
@ -47,6 +47,13 @@
|
||||||
'third_party/boringssl/boringssl.gyp:boringssl',
|
'third_party/boringssl/boringssl.gyp:boringssl',
|
||||||
'third_party/gflags/gflags.gyp:gflags',
|
'third_party/gflags/gflags.gyp:gflags',
|
||||||
],
|
],
|
||||||
|
'conditions': [
|
||||||
|
['profiling==1', {
|
||||||
|
'dependencies': [
|
||||||
|
'base/allocator/allocator.gyp:allocator',
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'target_name': 'mpd_generator',
|
'target_name': 'mpd_generator',
|
||||||
|
|
Loading…
Reference in New Issue