blob: 068297ef60add60554f4ae94b9db1f3376e1febb [file] [log] [blame] [view]
perezju8f6b9c02017-01-09 17:17:241# Memory Benchmarks
2
3This document describes benchmarks available to track Chrome's and
4WebView's memory usage, where they live, what they measure, how to run them,
5and on how to diagnose regressions.
6
7[TOC]
8
9## Glossary
10
11* **User story:** a set of actions to perform on a browser or device (e.g.
12 open google homepage, type "foo", click search, scroll down, visit first
13 result, etc.).
14* **Metric:** a data aggregation process that takes a Chrome trace as input
15 (produced by a [Telemetry][] run) and produces a set of summary numbers as
16 output (e.g. total GPU memory used).
17* **Benchmark:** a combination of (one or more) user stories and (one or
18 more) metrics.
19
20[Telemetry]: https://github.com/catapult-project/catapult/blob/master/telemetry/README.md
21
22## System Health
23
24*System health* is an effort to unify top-level benchmarks (as opposite to
25micro-benchmarks and regression tests) that are suitable to capture
26representative user stories.
27
28### Benchmarks
29
30System health memory benchmarks are:
31
32* [system_health.memory_mobile][system_health] -
33 user stories running on Android devices.
34* [system_health.memory_desktop][system_health] -
35 user stories running on desktop platforms.
36
Juan Antonio Navarro Perez2097a1d2019-07-05 10:42:5837These benchmarks are run continuously on the [chrome.perf][] waterfall,
perezju8f6b9c02017-01-09 17:17:2438collecting and reporting results on the
39[Chrome Performance Dashboard][chromeperf].
40
perezju8f6b9c02017-01-09 17:17:2441[system_health]: https://chromium.googlesource.com/chromium/src/+/master/tools/perf/page_sets/system_health/
Juan Antonio Navarro Perez2097a1d2019-07-05 10:42:5842[chrome.perf]: https://ci.chromium.org/p/chrome/g/chrome.perf/console
perezju8f6b9c02017-01-09 17:17:2443[chromeperf]: https://chromeperf.appspot.com/report
44
45### User stories
46
47System health user stories are classified by the kind of interactions they
48perform with the browser:
49
50* `browse` stories navigate to a URL and interact with the page; e.g.
51 scroll, click on elements, navigate to subpages, navigate back.
52* `load` stories just navigate to a URL and wait for the page to
53 load.
54* `background` stories navigate to a URL, possibly interact with the
55 page, and then bring another app to the foreground (thus pushing the
56 browser to the background).
57* `long_running` stories interact with a page for a longer period
58 of time (~5 mins).
59* `blank` has a single story that just navigates to **about:blank**.
60
61The full name of a story has the form `{interaction}:{category}:{site}` where:
62
63* `interaction` is one the labels given above;
64* `category` is used to group together sites with a similar purpose,
65 e.g. `news`, `social`, `tools`;
66* `site` is a short name identifying the website in which the story mostly
67 takes place, e.g. `cnn`, `facebook`, `gmail`.
68
69For example `browse:news:cnn` and `background:social:facebook` are two system
70health user stories.
71
72Today, for most stories a garbage collection is forced at the end of the
73story and a memory dump is then triggered. Metrics report the values
74obtained from this single measurement.
75
76## Continuous monitoring
77
78![Chrome Performance Dashboard](https://storage.googleapis.com/chromium-docs.appspot.com/79d08f59cf497c761f7099ea427704c14e9afc03.png)
79
80To view data from one of the benchmarks on the
81[Chrome Performance Dashboard][chromeperf] you should select:
82
83* **Test suite:** The name of a *[benchmark](#Benchmarks)*.
84* **Bot:** The name of a *platform or device configuration*. Sign in to also
85 see internal bots.
86* **Subtest (1):** The name of a *[metric](#Understanding-memory-metrics)*.
87* **Subtest (2):** The name of a *story group*; these have the form
88 `{interaction}_{category}` for system health stories.
89* **Subtest (3):** The name of a *[user story](#User-stories)*
90 (with `:` replaced by `_`).
91
xunjieli0c0ed3be2017-06-23 14:08:3592If you are investigating a Perf dashboard alert and would like to see the
93details, you can click on any point of the graph. It gives you the commit range,
94buildbot output and a link to the trace file taken during the buildbot run.
sullivana65c32f2017-07-06 17:39:0495(More information about reading trace files [here][memory-infra])
96
97[memory-infra]: /docs/memory-infra/README.md
xunjieli0c0ed3be2017-06-23 14:08:3598
99![Chrome Performance Dashboard Alert](https://storage.googleapis.com/chromium-docs.appspot.com/perfdashboard_alert.png)
100
perezju8f6b9c02017-01-09 17:17:24101## How to run the benchmarks
102
Juan Antonio Navarro Perez9e50ddde2018-12-18 10:22:49103Benchmarks may be run on a local platform/device or remotely on a pinpoint
104try job.
105
106### How to run a pinpoint try job
107
108Given a patch already uploaded to code review, try jobs provide a convenient
109way to evaluate its memory implications on devices or platforms which
110may not be immediately available to developers.
111
112![New pinpoint try job dialog](https://storage.googleapis.com/chromium-docs.appspot.com/yHRMmUqraqJ.png)
113
114To start a try job go to the [pinpoint][] website, click on the `+` button to
115create a new job, and fill in the required details:
116
117[pinpoint]: https://pinpoint-dot-chromeperf.appspot.com/
118
119* **Bug ID** (optional): The id of a crbug.com issue where pinpoint can post
120 updates when the job finishes.
121* **Gerrit URL**: URL to the patch you want to test. Note that your patch can
122 live in chromium or any of its sub-repositories!
123* **Bot**: Select a suitable device/platform from the drop-down menu on which
124 to run your job.
125* **Benchmark**: The name of the benchmark to run. If you are interested in
126 memory try `system_health.memory_mobile` or `system_health.memory_desktop`
127 as appropriate.
128* **Story** (optional): A pattern passed to Telemetry's `--story-filter`
129 option to only run stories that match the pattern.
130* **Extra Test Arguments** (optional): Additional command line arguments for
131 Telemetry's `run_benchmark`. Of note, if you are interested in running a
132 small but representative sample of system health stories you can pass
133 `--story-tag-filter health_check`.
134
135If you have more specific needs, or need to automate the creation of jobs, you
136can also consider using [pinpoint_cli][].
137
Juan Antonio Navarro Perez2097a1d2019-07-05 10:42:58138[pinpoint_cli]: https://cs.chromium.org/chromium/src/tools/perf/pinpoint_cli
perezju8f6b9c02017-01-09 17:17:24139
140### How to run locally
141
142After building, e.g. `ChromePublic.apk`, you can run a specific system health
143story with the command:
144
145```
146$SRC/tools/perf/run_benchmark run system_health.memory_mobile \
147 --browser android-chromium --story-filter load:search:google
148```
149
150This will run the story with a default of 3 repetitions and produce a
151`results.html` file comparing results from this and any previous benchmark
Juan A. Navarro Perezee12a2a2017-10-02 16:20:18152runs. In addition, you'll also get individual [trace files][memory-infra]
Juan Antonio Navarro Perez33b0d142018-01-19 14:54:35153for each story run by the benchmark. **Note:** by default only high level
154metrics are shown, you may need to tick the "Show all" check box in order to
155view some of the lower level memory metrics.
perezju8f6b9c02017-01-09 17:17:24156
157![Example results.html file](https://storage.googleapis.com/chromium-docs.appspot.com/ea60207d9bb4809178fe75923d6d1a2b241170ef.png)
158
159Other useful options for this command are:
160
161* `--pageset-repeat [n]` - override the default number of repetitions
perezju8f6b9c02017-01-09 17:17:24162* `--reset-results` - clear results from any previous benchmark runs in the
163 `results.html` file.
164* `--results-label [label]` - give meaningful names to your benchmark runs,
165 this way it is easier to compare them.
166
167For WebView make sure to [replace the system WebView][webview_install]
168on your device and use `--browser android-webview`.
169
sullivana65c32f2017-07-06 17:39:04170[memory-infra]: /docs/memory-infra/README.md
perezju8f6b9c02017-01-09 17:17:24171[webview_install]: https://www.chromium.org/developers/how-tos/build-instructions-android-webview
172
perezju8f6b9c02017-01-09 17:17:24173## Understanding memory metrics
174
175There is a large number of [memory-infra][] metrics, breaking down usage
176attributed to different components and processes.
177
178![memory-infra metrics](https://storage.googleapis.com/chromium-docs.appspot.com/a73239c6367ed0f844500e51ce1e04556cb99b4f.png)
179
180Most memory metrics have the form
181`memory:{browser}:{processes}:{source}:{component}:{kind}`
182where:
183
184* **browser:** One of `chrome` or `webview`.
185* **processess:** One of `browser_process`, `renderer_processess`,
186 `gpu_process`, or `all_processess`.
187* **source:** One of `reported_by_chrome` or `reported_by_os`
188* **component:** May be a Chrome component, e.g. `skia` or `sqlite`;
189 details about a specific component, e.g. `v8:heap`; or a class of memory
xunjieli0c0ed3be2017-06-23 14:08:35190 as seen by the OS, e.g. `system_memory:native_heap` or `gpu_memory`. If
191 reported by chrome, the metrics are gathered by `MemoryDumpProvider`s,
192 probes placed in the specific components' codebase. For example, in
193 "memory:chrome:all_processes:reported_by_chrome:net:effective_size_avg,"
194 the component is "net" which is Chrome's network stack and
195 "reported_by_chrome" means that this metric is gathered via probes in
196 the network stack.
perezju8f6b9c02017-01-09 17:17:24197* **kind:** The kind of memory being reported. For metrics reported by
198 Chrome this usually is `effective_size` (others are `locked_size`
199 and `allocated_objects_size`); for metrics by the OS this usually is
200 `proportional_resident_size` (others are `peak_resident_size` and
201 `private_dirty_size`).
202
sullivana65c32f2017-07-06 17:39:04203[memory-infra]: /docs/memory-infra/README.md