blob: aa75974933e160c28da6b1d103655799c182c270 [file] [log] [blame] [view]
hjd0304f112016-11-14 22:36:531# MemoryInfra
2
3MemoryInfra is a timeline-based profiling system integrated in chrome://tracing.
4It aims at creating Chrome-scale memory measurement tooling so that on any
5Chrome in the world --- desktop, mobile, Chrome OS or any other --- with the
6click of a button you can understand where memory is being used in your system.
7
8[TOC]
9
10## Getting Started
11
12 1. Get a bleeding-edge or tip-of-tree build of Chrome.
13
14 2. [Record a trace as usual][record-trace]: open [chrome://tracing][tracing]
15 on Desktop Chrome or [chrome://inspect?tracing][inspect-tracing] to trace
16 Chrome for Android.
17
18 3. Make sure to enable the **memory-infra** category on the right.
19
20 ![Tick the memory-infra checkbox when recording a trace.][memory-infra-box]
21
22 4. For now, some subsystems only work if Chrome is started with the
23 `--no-sandbox` flag.
24 <!-- TODO(primiano) TODO(ssid): https://crbug.com/461788 -->
25
26[record-trace]: https://sites.google.com/a/chromium.org/dev/developers/how-tos/trace-event-profiling-tool/recording-tracing-runs
27[tracing]: chrome://tracing
28[inspect-tracing]: chrome://inspect?tracing
29[memory-infra-box]: https://storage.googleapis.com/chromium-docs.appspot.com/1c6d1886584e7cc6ffed0d377f32023f8da53e02
30
31![Timeline View and Analysis View][tracing-views]
32
33After recording a trace, you will see the **timeline view**. Timeline view
34shows:
35
36 * Total resident memory grouped by process (at the top).
37 * Total resident memory grouped by subsystem (at the top).
38 * Allocated memory per subsystem for every process.
39
40Click one of the ![M][m-blue] dots to bring up the **analysis view**. Click
41on a cell in analysis view to reveal more information about its subsystem.
42PartitionAlloc for instance, has more details about its partitions.
43
44![Component details for PartitionAlloc][partalloc-details]
45
46The purple ![M][m-purple] dots represent heavy dumps. In these dumps, components
47can provide more details than in the regular dumps. The full details of the
48MemoryInfra UI are explained in its [design doc][mi-ui-doc].
49
50[tracing-views]: https://storage.googleapis.com/chromium-docs.appspot.com/db12015bd262385f0f8bd69133330978a99da1ca
51[m-blue]: https://storage.googleapis.com/chromium-docs.appspot.com/b60f342e38ff3a3767bbe4c8640d96a2d8bc864b
52[partalloc-details]: https://storage.googleapis.com/chromium-docs.appspot.com/02eade61d57c83f8ef8227965513456555fc3324
53[m-purple]: https://storage.googleapis.com/chromium-docs.appspot.com/d7bdf4d16204c293688be2e5a0bcb2bf463dbbc3
54[mi-ui-doc]: https://docs.google.com/document/d/1b5BSBEd1oB-3zj_CBAQWiQZ0cmI0HmjmXG-5iNveLqw/edit
55
56## Columns
57
58**Columns in blue** reflect the amount of actual physical memory used by the
59process. This is what exerts memory pressure on the system.
60
ssid5183d872016-11-29 00:10:5661 * **Total Resident**: The current working set size of the process, excluding
62 the memory overhead of tracing. On Linux, this returns the resident set size.
63 * **Peak Total Resident**: The overall peak working set size of the process on
64 supported platforms. On Linux kernel versions >= 4.0 the peak usage between
65 two memory dumps is shown.
66 * **PSS**: POSIX only. The process's proportional share of total resident size.
67 * **Private Dirty**: The total size of dirty pages which are not used by any
68 other process.
69 * **Swapped**: The total size of anonymous memory used by process, which is
70 swapped out of RAM.
hjd0304f112016-11-14 22:36:5371
qyearsleyc0dc6f42016-12-02 22:13:3972**Columns in black** reflect a best estimation of the amount of physical
hjd0304f112016-11-14 22:36:5373memory used by various subsystems of Chrome.
74
75 * **Blink GC**: Memory used by [Oilpan][oilpan].
76 * **CC**: Memory used by the compositor.
77 See [cc/memory][cc-memory] for the full details.
ssid5183d872016-11-29 00:10:5678 * **Discardable**: Total [discardable][discardable] memory used by the process
79 from various components like Skia caches and Web caches.
80 * **Font Caches**: Size of cache that stores Font shapes and platform Fonts.
hjd0304f112016-11-14 22:36:5381 * **GPU** and **GPU Memory Buffer**: GPU memory and RAM used for GPU purposes.
82 See [GPU Memory Tracing][gpu-memory].
ssid5183d872016-11-29 00:10:5683 * **LevelDB**: Memory used for LeveldbValueStore(s), IndexedDB databases and
84 ProtoDatabase(s).
hjd0304f112016-11-14 22:36:5385 * **Malloc**: Memory allocated by calls to `malloc`, or `new` for most
86 non-Blink objects.
87 * **PartitionAlloc**: Memory allocated via [PartitionAlloc][partalloc].
88 Blink objects that are not managed by Oilpan are allocated with
89 PartitionAlloc.
ssid5183d872016-11-29 00:10:5690 * **Skia**: Memory used by all resources used by the Skia rendering system.
91 * **SQLite**: Memory used for all sqlite databases.
92 * **Sync**: Memory used by Chrome Sync when signed in.
93 * **UI**: Android only. Memory used by Android java bitmaps for the UI.
94 * **V8**: Memory used by V8 Javascript engine.
95 * **Web Cache**: Memory used by resources downloaded from the Web, like images
96 and scipts.
hjd0304f112016-11-14 22:36:5397
98The **tracing column in gray** reports memory that is used to collect all of the
99above information. This memory would not be used if tracing were not enabled,
100and it is discounted from malloc and the blue columns.
101
102<!-- TODO(primiano): Improve this. https://crbug.com/??? -->
103
104[oilpan]: /third_party/WebKit/Source/platform/heap/BlinkGCDesign.md
ssid5183d872016-11-29 00:10:56105[discardable]:base/memory/discardable_memory.h
hjd0304f112016-11-14 22:36:53106[cc-memory]: probe-cc.md
107[gpu-memory]: probe-gpu.md
108[partalloc]: /third_party/WebKit/Source/wtf/allocator/PartitionAlloc.md
109
110## Related Pages
111
112 * [Adding MemoryInfra Tracing to a Component](adding_memory_infra_tracing.md)
113 * [GPU Memory Tracing](probe-gpu.md)
114 * [Heap Profiler Internals](heap_profiler_internals.md)
115 * [Heap Profiling with MemoryInfra](heap_profiler.md)
116 * [Startup Tracing with MemoryInfra](memory_infra_startup_tracing.md)
117
118## Rationale
119
120Another memory profiler? What is wrong with tool X?
121Most of the existing tools:
122
123 * Are hard to get working with Chrome. (Massive symbols, require OS-specific
124 tricks.)
125 * Lack Chrome-related context.
126 * Don't deal with multi-process scenarios.
127
128MemoryInfra leverages the existing tracing infrastructure in Chrome and provides
129contextual data:
130
131 * **It speaks Chrome slang.**
132 The Chromium codebase is instrumented. Its memory subsystems (allocators,
133 caches, etc.) uniformly report their stats into the trace in a way that can
134 be understood by Chrome developers. No more
135 `__gnu_cxx::new_allocator< std::_Rb_tree_node< std::pair< std::string const, base::Value*>>> ::allocate`.
136 * **Timeline data that can be correlated with other events.**
137 Did memory suddenly increase during a specific Blink / V8 / HTML parsing
138 event? Which subsystem increased? Did memory not go down as expected after
139 closing a tab? Which other threads were active during a bloat?
140 * **Works out of the box on desktop and mobile.**
141 No recompilations with unmaintained `GYP_DEFINES`, no time-consuming
142 symbolizations stages. All the logic is already into Chrome, ready to dump at
143 any time.
144 * **The same technology is used for telemetry and the ChromePerf dashboard.**
145 See [the slides][chromeperf-slides] and take a look at
146 [some ChromePerf dashboards][chromeperf] and
147 [telemetry documentation][telemetry].
148
149[chromeperf-slides]: https://docs.google.com/presentation/d/1OyxyT1sfg50lA36A7ibZ7-bBRXI1kVlvCW0W9qAmM_0/present?slide=id.gde150139b_0_137
150[chromeperf]: https://chromeperf.appspot.com/report?sid=3b54e60c9951656574e19252fadeca846813afe04453c98a49136af4c8820b8d
151[telemetry]: https://catapult.gsrc.io/telemetry
152
153## Development
154
155MemoryInfra is based on a simple and extensible architecture. See
156[the slides][dp-slides] on how to get your subsystem reported in MemoryInfra,
157or take a look at one of the existing examples such as
158[malloc_dump_provider.cc][malloc-dp]. The crbug label is
159[Hotlist-MemoryInfra][hotlist]. Don't hesitate to contact
160[[email protected]][mailtracing] for questions and support.
161
162[dp-slides]: https://docs.google.com/presentation/d/1GI3HY3Mm5-Mvp6eZyVB0JiaJ-u3L1MMJeKHJg4lxjEI/present?slide=id.g995514d5c_1_45
163[malloc-dp]: https://chromium.googlesource.com/chromium/src.git/+/master/base/trace_event/malloc_dump_provider.cc
164[hotlist]: https://code.google.com/p/chromium/issues/list?q=label:Hotlist-MemoryInfra
165[mailtracing]: mailto:[email protected]
166
167## Design documents
168
169Architectural:
170
171<iframe width="100%" height="300px" src="https://docs.google.com/a/google.com/embeddedfolderview?id=0B3KuDeqD-lVJfmp0cW1VcE5XVWNxZndxelV5T19kT2NFSndYZlNFbkFpc3pSa2VDN0hlMm8">
172</iframe>
173
174Chrome-side design docs:
175
176<iframe width="100%" height="300px" src="https://docs.google.com/a/google.com/embeddedfolderview?id=0B3KuDeqD-lVJfndSa2dleUQtMnZDeWpPZk1JV0QtbVM5STkwWms4YThzQ0pGTmU1QU9kNVk">
177</iframe>
178
179Catapult-side design docs:
180
181<iframe width="100%" height="300px" src="https://docs.google.com/a/google.com/embeddedfolderview?id=0B3KuDeqD-lVJfm10bXd5YmRNWUpKOElOWS0xdU1tMmV1S3F4aHo0ZDJLTmtGRy1qVnQtVWM">
182</iframe>