| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 1. Run `adb root`. Every time you connect your device you’ll want to run this. | 67 1. Run `adb root`. Every time you connect your device you’ll want to run this. |
| 68 1. If adb is not available, make sure to run `. build/android/envsetup.sh` | 68 1. If adb is not available, make sure to run `. build/android/envsetup.sh` |
| 69 | 69 |
| 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 |
| 77 |
| 78 Rebuild `content_shell_apk` with profiling enabled. |
| 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: |
| 87 |
| 88 gn args out/Profiling |
| 89 # add "enable_profiling = true" |
| 90 ninja -C out/Profiling content_shell_apk |
| 91 export CHROMIUM_OUTPUT_DIR="$PWD/out/Profiling" |
| 92 |
| 76 ## Run a Telemetry perf profiler | 93 ## Run a Telemetry perf profiler |
| 77 | 94 |
| 78 You can run any Telemetry benchmark with `--profiler=perf`, and it will: | 95 You can run any Telemetry benchmark with `--profiler=perf`, and it will: |
| 79 | 96 |
| 80 1. Download `perf` and `perfhost` | 97 1. Download `perf` and `perfhost` |
| 81 1. Install on your device | 98 2. Install on your device |
| 82 1. Run the test | 99 3. Run the test |
| 83 1. Setup symlinks to work with the `--symfs` parameter | 100 4. Setup symlinks to work with the `--symfs` parameter |
| 84 | 101 |
| 85 You can also run "manual" tests with Telemetry, more information here: | 102 You can also run "manual" tests with Telemetry, more information here: |
| 86 http://www.chromium.org/developers/telemetry/profiling#TOC-Manual-Profiling---An
droid | 103 http://www.chromium.org/developers/telemetry/profiling#TOC-Manual-Profiling---An
droid |
| 87 | 104 |
| 88 The following steps describe building `perf`, which is no longer necessary if | 105 The following steps describe building `perf`, which is no longer necessary if |
| 89 you use Telemetry. | 106 you use Telemetry. |
| 90 | 107 |
| 108 ## Use `adb_profile_chrome` |
| 109 |
| 110 Even if you're not running a Telemetry test, you can use Catapult to |
| 111 automatically push binaries and pull the profile data for you. |
| 112 |
| 113 build/android/adb_profile_chrome --browser=content_shell --perf |
| 114 |
| 115 While you still have to build, install and launch the APK yourself, Catapult |
| 116 will take care of creating the symfs etc. (i.e. you can skip the "not needed for |
| 117 Telemetry" steps below). |
| 118 |
| 91 ## Install `/system/bin/perf` on your device (not needed for Telemetry) | 119 ## Install `/system/bin/perf` on your device (not needed for Telemetry) |
| 92 | 120 |
| 93 # From inside the android source tree (not inside Chromium) | 121 # From inside the android source tree (not inside Chromium) |
| 94 mmm external/linux-tools-perf/ | 122 mmm external/linux-tools-perf/ |
| 95 adb remount # (allows you to write to the system image) | 123 adb remount # (allows you to write to the system image) |
| 96 adb sync | 124 adb sync |
| 97 adb shell perf top # check that perf can get samples (don’t expect symbols) | 125 adb shell perf top # check that perf can get samples (don’t expect symbols) |
| 98 | 126 |
| 99 ## Enable profiling | |
| 100 | |
| 101 Rebuild `content_shell_apk` with profiling enabled | |
| 102 | |
| 103 export GYP_DEFINES="$GYP_DEFINES profiling=1" | |
| 104 build/gyp_chromium | |
| 105 ninja -C out/Release content_shell_apk | |
| 106 | |
| 107 ## Install ContentShell | 127 ## Install ContentShell |
| 108 | 128 |
| 109 Install with the following: | 129 Install with the following: |
| 110 | 130 |
| 111 build/android/adb_install_apk.py \ | 131 build/android/adb_install_apk.py \ |
| 112 --apk out/Release/apks/ContentShell.apk \ | 132 --apk out/Release/apks/ContentShell.apk \ |
| 113 --apk_package org.chromium.content_shell | 133 --apk_package org.chromium.content_shell |
| 114 | 134 |
| 115 ## Run ContentShell | 135 ## Run ContentShell |
| 116 | 136 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 chmod a+x perfhost_linux | 180 chmod a+x perfhost_linux |
| 161 | 181 |
| 162 ## Actually record a profile on the device! | 182 ## Actually record a profile on the device! |
| 163 | 183 |
| 164 Run the following: | 184 Run the following: |
| 165 | 185 |
| 166 adb shell ps | grep content (look for the pid of the sandboxed_process) | 186 adb shell ps | grep content (look for the pid of the sandboxed_process) |
| 167 adb shell perf record -g -p 12345 sleep 5 | 187 adb shell perf record -g -p 12345 sleep 5 |
| 168 adb pull /data/perf.data | 188 adb pull /data/perf.data |
| 169 | 189 |
| 170 | |
| 171 ## Create the report | 190 ## Create the report |
| 172 | 191 |
| 173 1. Run the following: | 192 1. Run the following: |
| 174 | 193 |
| 175 ``` | 194 ``` |
| 176 ./perfhost_linux report -g -i perf.data --symfs symbols/ | 195 ./perfhost_linux report -g -i perf.data --symfs symbols/ |
| 177 ``` | 196 ``` |
| 178 | 197 |
| 179 1. If you don’t see chromium/webkit symbols, make sure that you built/pushed | 198 1. If you don’t see chromium/webkit symbols, make sure that you built/pushed |
| 180 Release, and that the symlink you created to the .so is valid! | 199 Release, and that the symlink you created to the .so is valid! |
| (...skipping 13 matching lines...) Expand all Loading... |
| 194 | 213 |
| 195 ``` | 214 ``` |
| 196 adb pull /proc/kallsyms symbols/kallsyms | 215 adb pull /proc/kallsyms symbols/kallsyms |
| 197 ``` | 216 ``` |
| 198 | 217 |
| 199 1. Now add --kallsyms to your perfhost\_linux command: | 218 1. Now add --kallsyms to your perfhost\_linux command: |
| 200 ``` | 219 ``` |
| 201 ./perfhost_linux report -g -i perf.data --symfs symbols/ \ | 220 ./perfhost_linux report -g -i perf.data --symfs symbols/ \ |
| 202 --kallsyms=symbols/kallsyms | 221 --kallsyms=symbols/kallsyms |
| 203 ``` | 222 ``` |
| OLD | NEW |