| OLD | NEW |
| 1 # Profiling Content Shell on Android | 1 # Profiling Content Shell on Android |
| 2 | 2 |
| 3 Below are the instructions for setting up profiling for Content Shell on | 3 Below are the instructions for setting up profiling for Content Shell on |
| 4 Android. This will let you generate profiles for ContentShell. This will require | 4 Android. This will let you generate profiles for ContentShell. This will require |
| 5 linux, building an userdebug Android build, and wiping the device. | 5 linux, building an userdebug Android build, and wiping the device. |
| 6 | 6 |
| 7 [TOC] | 7 [TOC] |
| 8 | 8 |
| 9 ## Prepare your device. | 9 ## Prepare your device. |
| 10 | 10 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 If you get the error `error: device offline`, you may need to become a developer | 70 If you get the error `error: device offline`, you may need to become a developer |
| 71 on your device before Linux will see it. On Jellybean 4.2.1 and above this | 71 on your device before Linux will see it. On Jellybean 4.2.1 and above this |
| 72 requires going to “about phone” or “about tablet” and clicking the build number | 72 requires going to “about phone” or “about tablet” and clicking the build number |
| 73 7 times: | 73 7 times: |
| 74 http://androidmuscle.com/how-to-enable-usb-debugging-developer-options-on-nexus-
4-and-android-4-2-devices/ | 74 http://androidmuscle.com/how-to-enable-usb-debugging-developer-options-on-nexus-
4-and-android-4-2-devices/ |
| 75 | 75 |
| 76 ## Enable profiling | 76 ## Enable profiling |
| 77 | 77 |
| 78 Rebuild `content_shell_apk` with profiling enabled. | 78 Rebuild `content_shell_apk` with profiling enabled. |
| 79 | 79 |
| 80 With GYP (deprecated): | |
| 81 | |
| 82 export GYP_DEFINES="$GYP_DEFINES profiling=1" | |
| 83 build/gyp_chromium | |
| 84 ninja -C out/Release content_shell_apk | |
| 85 | |
| 86 With GN: | 80 With GN: |
| 87 | 81 |
| 88 gn args out/Profiling | 82 gn args out/Profiling |
| 89 # add "enable_profiling = true" | 83 # add "enable_profiling = true" |
| 90 ninja -C out/Profiling content_shell_apk | 84 ninja -C out/Profiling content_shell_apk |
| 91 export CHROMIUM_OUTPUT_DIR="$PWD/out/Profiling" | 85 export CHROMIUM_OUTPUT_DIR="$PWD/out/Profiling" |
| 92 | 86 |
| 93 ## Run a Telemetry perf profiler | 87 ## Run a Telemetry perf profiler |
| 94 | 88 |
| 95 You can run any Telemetry benchmark with `--profiler=perf`, and it will: | 89 You can run any Telemetry benchmark with `--profiler=perf`, and it will: |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 ## Create the report | 184 ## Create the report |
| 191 | 185 |
| 192 1. Run the following: | 186 1. Run the following: |
| 193 | 187 |
| 194 ``` | 188 ``` |
| 195 ./perfhost_linux report -g -i perf.data --symfs symbols/ | 189 ./perfhost_linux report -g -i perf.data --symfs symbols/ |
| 196 ``` | 190 ``` |
| 197 | 191 |
| 198 1. If you don’t see chromium/webkit symbols, make sure that you built/pushed | 192 1. If you don’t see chromium/webkit symbols, make sure that you built/pushed |
| 199 Release, and that the symlink you created to the .so is valid! | 193 Release, and that the symlink you created to the .so is valid! |
| 200 1. If you have symbols, but your callstacks are nonsense, make sure you ran | |
| 201 `build/gyp_chromium` after setting `profiling=1`, and rebuilt. | |
| 202 | 194 |
| 203 ## Add symbols for the kernel | 195 ## Add symbols for the kernel |
| 204 | 196 |
| 205 1. By default, /proc/kallsyms returns 0 for all symbols, to fix this, set | 197 1. By default, /proc/kallsyms returns 0 for all symbols, to fix this, set |
| 206 `/proc/sys/kernel/kptr_restrict` to `0`: | 198 `/proc/sys/kernel/kptr_restrict` to `0`: |
| 207 | 199 |
| 208 ``` | 200 ``` |
| 209 adb shell echo “0” > /proc/sys/kernel/kptr_restrict | 201 adb shell echo “0” > /proc/sys/kernel/kptr_restrict |
| 210 ``` | 202 ``` |
| 211 | 203 |
| 212 1. See http://lwn.net/Articles/420403/ for explanation of what this does. | 204 1. See http://lwn.net/Articles/420403/ for explanation of what this does. |
| 213 | 205 |
| 214 ``` | 206 ``` |
| 215 adb pull /proc/kallsyms symbols/kallsyms | 207 adb pull /proc/kallsyms symbols/kallsyms |
| 216 ``` | 208 ``` |
| 217 | 209 |
| 218 1. Now add --kallsyms to your perfhost\_linux command: | 210 1. Now add --kallsyms to your perfhost\_linux command: |
| 219 ``` | 211 ``` |
| 220 ./perfhost_linux report -g -i perf.data --symfs symbols/ \ | 212 ./perfhost_linux report -g -i perf.data --symfs symbols/ \ |
| 221 --kallsyms=symbols/kallsyms | 213 --kallsyms=symbols/kallsyms |
| 222 ``` | 214 ``` |
| OLD | NEW |