blob: b4213d7641be013d5d020be06107f55c179fb4dd [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
Erik Chene0525352018-03-02 16:23:2010## Taking a memory-infra trace
hjd0304f112016-11-14 22:36:5311
Erik Chene0525352018-03-02 16:23:2012 1. [Record a trace as usual][record-trace]: open [chrome://tracing][tracing]
Dale Curtis8d453c52019-11-04 22:02:0013 on Desktop Chrome or [chrome://inspect][inspect-tracing] to trace
hjd0304f112016-11-14 22:36:5314 Chrome for Android.
15
Erik Chene0525352018-03-02 16:23:2016 2. Make sure to enable the **memory-infra** category on the right.
hjd0304f112016-11-14 22:36:5317
18 ![Tick the memory-infra checkbox when recording a trace.][memory-infra-box]
19
hjd0304f112016-11-14 22:36:5320
21[record-trace]: https://sites.google.com/a/chromium.org/dev/developers/how-tos/trace-event-profiling-tool/recording-tracing-runs
22[tracing]: chrome://tracing
Dale Curtis8d453c52019-11-04 22:02:0023[inspect-tracing]: chrome://inspect
hjd0304f112016-11-14 22:36:5324[memory-infra-box]: https://storage.googleapis.com/chromium-docs.appspot.com/1c6d1886584e7cc6ffed0d377f32023f8da53e02
25
Erik Chene0525352018-03-02 16:23:2026## Navigating a memory-infra trace
27
hjd0304f112016-11-14 22:36:5328![Timeline View and Analysis View][tracing-views]
29
Erik Chene0525352018-03-02 16:23:2030After recording a trace, you will see the **timeline view**. The **timeline
31view** is primarily used for other tracing features. Click one of the
32![M][m-purple] dots to bring up the **analysis view**. Click on a cell in
33analysis view to reveal more information about its subsystem. PartitionAlloc for
34instance, has more details about its partitions.
hjd0304f112016-11-14 22:36:5335
36![Component details for PartitionAlloc][partalloc-details]
37
Erik Chene0525352018-03-02 16:23:2038The full details of the MemoryInfra UI are explained in its [design
39doc][mi-ui-doc].
hjd0304f112016-11-14 22:36:5340
41[tracing-views]: https://storage.googleapis.com/chromium-docs.appspot.com/db12015bd262385f0f8bd69133330978a99da1ca
hjd0304f112016-11-14 22:36:5342[partalloc-details]: https://storage.googleapis.com/chromium-docs.appspot.com/02eade61d57c83f8ef8227965513456555fc3324
43[m-purple]: https://storage.googleapis.com/chromium-docs.appspot.com/d7bdf4d16204c293688be2e5a0bcb2bf463dbbc3
44[mi-ui-doc]: https://docs.google.com/document/d/1b5BSBEd1oB-3zj_CBAQWiQZ0cmI0HmjmXG-5iNveLqw/edit
45
46## Columns
47
48**Columns in blue** reflect the amount of actual physical memory used by the
49process. This is what exerts memory pressure on the system.
50
ssid5183d872016-11-29 00:10:5651 * **Total Resident**: The current working set size of the process, excluding
52 the memory overhead of tracing. On Linux, this returns the resident set size.
53 * **Peak Total Resident**: The overall peak working set size of the process on
54 supported platforms. On Linux kernel versions >= 4.0 the peak usage between
55 two memory dumps is shown.
56 * **PSS**: POSIX only. The process's proportional share of total resident size.
57 * **Private Dirty**: The total size of dirty pages which are not used by any
58 other process.
59 * **Swapped**: The total size of anonymous memory used by process, which is
60 swapped out of RAM.
hjd0304f112016-11-14 22:36:5361
qyearsleyc0dc6f42016-12-02 22:13:3962**Columns in black** reflect a best estimation of the amount of physical
hjd0304f112016-11-14 22:36:5363memory used by various subsystems of Chrome.
64
65 * **Blink GC**: Memory used by [Oilpan][oilpan].
66 * **CC**: Memory used by the compositor.
67 See [cc/memory][cc-memory] for the full details.
ssid5183d872016-11-29 00:10:5668 * **Discardable**: Total [discardable][discardable] memory used by the process
69 from various components like Skia caches and Web caches.
70 * **Font Caches**: Size of cache that stores Font shapes and platform Fonts.
hjd0304f112016-11-14 22:36:5371 * **GPU** and **GPU Memory Buffer**: GPU memory and RAM used for GPU purposes.
72 See [GPU Memory Tracing][gpu-memory].
ssid5183d872016-11-29 00:10:5673 * **LevelDB**: Memory used for LeveldbValueStore(s), IndexedDB databases and
74 ProtoDatabase(s).
hjd0304f112016-11-14 22:36:5375 * **Malloc**: Memory allocated by calls to `malloc`, or `new` for most
76 non-Blink objects.
77 * **PartitionAlloc**: Memory allocated via [PartitionAlloc][partalloc].
78 Blink objects that are not managed by Oilpan are allocated with
79 PartitionAlloc.
ssid5183d872016-11-29 00:10:5680 * **Skia**: Memory used by all resources used by the Skia rendering system.
81 * **SQLite**: Memory used for all sqlite databases.
82 * **Sync**: Memory used by Chrome Sync when signed in.
83 * **UI**: Android only. Memory used by Android java bitmaps for the UI.
84 * **V8**: Memory used by V8 Javascript engine.
85 * **Web Cache**: Memory used by resources downloaded from the Web, like images
hjd9dddc3f2017-01-11 16:16:3786 and scripts.
hjd0304f112016-11-14 22:36:5387
88The **tracing column in gray** reports memory that is used to collect all of the
89above information. This memory would not be used if tracing were not enabled,
90and it is discounted from malloc and the blue columns.
91
92<!-- TODO(primiano): Improve this. https://crbug.com/??? -->
93
Kent Tamura6943cf792018-04-09 05:24:5494[oilpan]: /third_party/blink/renderer/platform/heap/BlinkGCDesign.md
ssid5183d872016-11-29 00:10:5695[discardable]:base/memory/discardable_memory.h
hjd0304f112016-11-14 22:36:5396[cc-memory]: probe-cc.md
97[gpu-memory]: probe-gpu.md
palmera988c502016-12-14 09:40:3898[partalloc]: /base/allocator/partition_allocator/PartitionAlloc.md
hjd0304f112016-11-14 22:36:5399
hjd9dddc3f2017-01-11 16:16:37100## 'effective\_size' vs. 'size'
101
102This is a little like the difference between 'self time' and 'cumulative time'
103in a profiling tool. Size is the total amount of memory allocated/requested
104by a subsystem whereas effective size is the total amount of memory
105used/consumed by a subsystem. If Skia allocates 10mb via partition_alloc
106that memory would show up in the size of both Skia and partition_alloc
107but only in the effective size of Skia since although partition_alloc
108allocates the 10mb it does so on behalf of Skia which is responsible
109for the memory. Summing all effective sizes gives the total amount of
110memory used whereas summing size would give a number larger than the total
111amount of memory used.
112
hjd0304f112016-11-14 22:36:53113## Related Pages
114
115 * [Adding MemoryInfra Tracing to a Component](adding_memory_infra_tracing.md)
116 * [GPU Memory Tracing](probe-gpu.md)
hjd0304f112016-11-14 22:36:53117 * [Heap Profiling with MemoryInfra](heap_profiler.md)
118 * [Startup Tracing with MemoryInfra](memory_infra_startup_tracing.md)
119
120## Rationale
121
122Another memory profiler? What is wrong with tool X?
123Most of the existing tools:
124
125 * Are hard to get working with Chrome. (Massive symbols, require OS-specific
126 tricks.)
127 * Lack Chrome-related context.
128 * Don't deal with multi-process scenarios.
129
130MemoryInfra leverages the existing tracing infrastructure in Chrome and provides
131contextual data:
132
133 * **It speaks Chrome slang.**
134 The Chromium codebase is instrumented. Its memory subsystems (allocators,
135 caches, etc.) uniformly report their stats into the trace in a way that can
136 be understood by Chrome developers. No more
137 `__gnu_cxx::new_allocator< std::_Rb_tree_node< std::pair< std::string const, base::Value*>>> ::allocate`.
138 * **Timeline data that can be correlated with other events.**
139 Did memory suddenly increase during a specific Blink / V8 / HTML parsing
140 event? Which subsystem increased? Did memory not go down as expected after
141 closing a tab? Which other threads were active during a bloat?
142 * **Works out of the box on desktop and mobile.**
Daniel Bratellf73f0df2018-09-24 13:52:49143 No recompilations, no time-consuming symbolizations stages. All the
144 logic is already in Chrome, ready to dump at any time.
hjd0304f112016-11-14 22:36:53145 * **The same technology is used for telemetry and the ChromePerf dashboard.**
146 See [the slides][chromeperf-slides] and take a look at
147 [some ChromePerf dashboards][chromeperf] and
148 [telemetry documentation][telemetry].
149
150[chromeperf-slides]: https://docs.google.com/presentation/d/1OyxyT1sfg50lA36A7ibZ7-bBRXI1kVlvCW0W9qAmM_0/present?slide=id.gde150139b_0_137
151[chromeperf]: https://chromeperf.appspot.com/report?sid=3b54e60c9951656574e19252fadeca846813afe04453c98a49136af4c8820b8d
152[telemetry]: https://catapult.gsrc.io/telemetry
153
154## Development
155
156MemoryInfra is based on a simple and extensible architecture. See
157[the slides][dp-slides] on how to get your subsystem reported in MemoryInfra,
158or take a look at one of the existing examples such as
159[malloc_dump_provider.cc][malloc-dp]. The crbug label is
160[Hotlist-MemoryInfra][hotlist]. Don't hesitate to contact
161[[email protected]][mailtracing] for questions and support.
162
163[dp-slides]: https://docs.google.com/presentation/d/1GI3HY3Mm5-Mvp6eZyVB0JiaJ-u3L1MMJeKHJg4lxjEI/present?slide=id.g995514d5c_1_45
John Palmer046f9872021-05-24 01:24:56164[malloc-dp]: https://chromium.googlesource.com/chromium/src.git/+/main/base/trace_event/malloc_dump_provider.cc
hjd0304f112016-11-14 22:36:53165[hotlist]: https://code.google.com/p/chromium/issues/list?q=label:Hotlist-MemoryInfra
166[mailtracing]: mailto:[email protected]
167
168## Design documents
169
170Architectural:
171
172<iframe width="100%" height="300px" src="https://docs.google.com/a/google.com/embeddedfolderview?id=0B3KuDeqD-lVJfmp0cW1VcE5XVWNxZndxelV5T19kT2NFSndYZlNFbkFpc3pSa2VDN0hlMm8">
173</iframe>
174
175Chrome-side design docs:
176
177<iframe width="100%" height="300px" src="https://docs.google.com/a/google.com/embeddedfolderview?id=0B3KuDeqD-lVJfndSa2dleUQtMnZDeWpPZk1JV0QtbVM5STkwWms4YThzQ0pGTmU1QU9kNVk">
178</iframe>
179
180Catapult-side design docs:
181
182<iframe width="100%" height="300px" src="https://docs.google.com/a/google.com/embeddedfolderview?id=0B3KuDeqD-lVJfm10bXd5YmRNWUpKOElOWS0xdU1tMmV1S3F4aHo0ZDJLTmtGRy1qVnQtVWM">
183</iframe>