Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # MemoryInfra | |
| 2 | |
| 3 MemoryInfra is a timeline-based profiling system integrated in chrome://tracing. | |
| 4 It aims at creating Chrome-scale memory measurement tooling so that on any | |
| 5 Chrome in the world --- desktop, mobile, Chrome OS or any other --- with the | |
| 6 click of a button you can understand where memory is being used in your system. | |
| 7 | |
| 8 [TOC] | |
| 9 | |
| 10 ## Getting Started | |
| 11 | |
| 12 * Get a bleeding-edge or tip-of-tree build of Chrome. | |
| 13 * [Record a trace as usual][record-trace]: open [chrome://tracing][tracing] on | |
| 14 Desktop Chrome or [chrome://inspect?tracing][inspect-tracing] to trace Chrome | |
| 15 for Android. | |
| 16 * Make sure to enable the **memory-infra** category on the right. | |
| 17 ![Tick the memory-infra checkbox when recording a trace.][memory-infra-box] | |
| 18 * For now, some subsystems only work if Chrome is started with the | |
| 19 `--no-sandbox` flag. | |
| 20 <!-- TODO(primiano) TODO(ssid): https://crbug.com/461788 --> | |
| 21 | |
| 22 [record-trace]: https://sites.google.com/a/chromium.org/dev/developers/how-t os/trace-event-profiling-tool/recording-tracing-runs | |
| 23 [tracing]: chrome://tracing | |
| 24 [inspect-tracing]: chrome://inspect?tracing | |
| 25 [memory-infra-box]: images/record-trace-memory-infra.png | |
| 26 | |
| 27 After recording a trace, you will see the **timeline view**. Timeline view | |
| 28 shows: | |
| 29 | |
| 30 * Total resident memory grouped by process (at the top). | |
| 31 * Total resident memory grouped by subsystem (at the top). | |
| 32 * Allocated memory per subsystem for every process. | |
| 33 | |
| 34 Click one of the ![M][m-blue] dots to bring up the **analysis view**. Click | |
| 35 on a cell in analysis view to reveal more information about its subsystem. | |
| 36 PartitionAlloc for instance, has more details about its partitions. | |
| 37 | |
| 38 ![Component details for PartitionAlloc][partalloc-details] | |
| 39 | |
| 40 The purple ![M][m-purple] dots represent heavy dumps. In these dumps, components | |
| 41 can provide more details than in the regular dumps. The full details of the | |
| 42 MemoryInfra UI are explained in its [design doc][mi-ui-doc]. | |
| 43 | |
| 44 [m-blue]: images/m-blue.png | |
| 45 [partalloc-details]: images/partalloc-details.png | |
| 46 [m-purple]: images/m-purple.png | |
| 47 [mi-ui-doc]: https://docs.google.com/document/d/1b5BSBEd1oB-3zj_CBAQWiQZ 0cmI0HmjmXG-5iNveLqw/edit | |
| 48 | |
| 49 ## Columns | |
| 50 | |
| 51 **Columns in blue** reflect the amount of actual _physical memory_ used by the | |
| 52 process. This is what exerts memory pressure on the system. | |
| 53 | |
| 54 * **Total Resident**: (undocumented). | |
|
Primiano Tucci (use gerrit)
2016/01/18 15:45:28
I'd replace all these (undocumented) with TODO: do
Ruud van Asseldonk
2016/01/18 16:25:21
Done.
| |
| 55 * **Peak Total Resident**: (undocumented). | |
| 56 * **PSS**: (undocumented). | |
| 57 * **Private Dirty**: (undocumented). | |
| 58 * **Swapped**: (undocumented). | |
| 59 | |
| 60 **Columns in black** reflect the amount of _virtual memory_ requested by various | |
|
Primiano Tucci (use gerrit)
2016/01/18 15:45:28
_virtual memory_ : not really: these provide the b
Ruud van Asseldonk
2016/01/18 16:25:21
Fixed.
| |
| 61 subsystems of Chrome. | |
| 62 | |
| 63 * **Blink GC**: Memory used by [Oilpan][oilpan]. | |
| 64 * **CC**: Memory used by the compositor. | |
| 65 See [cc/memory][cc-memory] for the full details. | |
| 66 * **Discardable**: (undocumented). | |
| 67 * **Font Caches**: (undocumented). | |
| 68 * **GPU**: (undocumented). | |
| 69 * **GPU Memory Buffer**: (undocumented). | |
| 70 * **LevelDB**: (undocumented). | |
| 71 * **Malloc**: Memory allocated by calls to `malloc`, or `new` for most | |
| 72 non-Blink objects. | |
| 73 * **PartitionAlloc**: Memory allocated via [PartitionAlloc][partalloc]. | |
| 74 Blink objects that are not managed by Oilpan are allocated with | |
| 75 PartitionAlloc. | |
| 76 * **Skia**: (undocumented). | |
| 77 * **SQLite**: (undocumented). | |
| 78 * **V8**: (undocumented). | |
| 79 * **Web Cache**: (undocumented). | |
| 80 | |
| 81 The **tracing column in gray** reports memory that is used to collect all of the | |
| 82 above information. This memory would not be used if tracing were not enabled. | |
|
Primiano Tucci (use gerrit)
2016/01/18 15:45:28
Add: and is properly discounted from both malloc a
Ruud van Asseldonk
2016/01/18 16:25:21
Done.
| |
| 83 | |
| 84 <!-- TODO(primiano): Improve this. https://crbug.com/??? --> | |
| 85 | |
| 86 [oilpan]: /third_party/WebKit/Source/platform/heap/BlinkGCDesign.md | |
| 87 [cc-memory]: /cc/memory.md | |
| 88 [partalloc]: /third_party/WebKit/Source/wtf/PartitionAlloc.md | |
| 89 | |
| 90 To illustrate the difference between physical and virtual memory, consider the | |
|
Primiano Tucci (use gerrit)
2016/01/18 15:45:28
Remove this section about physical and virtual. I'
Ruud van Asseldonk
2016/01/18 16:25:21
Done.
| |
| 91 following example: | |
| 92 | |
| 93 ```c | |
| 94 size_t kPageSize = 4096; | |
| 95 char* p = (char*)malloc(256 * kPageSize); | |
| 96 for (size_t i = 0; i < kPageSize; ++i) | |
| 97 p[i] = 'X'; | |
| 98 ``` | |
| 99 | |
| 100 Here the malloc dumper would report that 1 MiB of virtual address space has been | |
| 101 allocated, but only 1 KiB of that would be reported in the resident column. The | |
| 102 rest of the memory is never touched, so the operating system does not need to | |
| 103 back it by physical memory. | |
| 104 | |
| 105 ## Rationale | |
| 106 | |
| 107 Another memory profiler? What is wrong with tool X? | |
| 108 Most of the existing tools: | |
| 109 | |
| 110 * Are hard to get working with Chrome. (Massive symbols, require OS-specific | |
| 111 tricks.) | |
| 112 * Lack Chrome-related context. | |
| 113 * Don't deal with multi-process scenarios. | |
| 114 | |
| 115 MemoryInfra leverages the existing tracing infrastructure in Chrome and provides | |
| 116 contextual data: | |
| 117 | |
| 118 * **It speaks Chrome slang.** | |
| 119 The Chromium codebase is instrumented. Its memory subsystems (allocators, | |
| 120 caches, etc.) uniformly report their stats into the trace in a way that can | |
| 121 be understood by Chrome developers. No more | |
| 122 `__gnu_cxx::new_allocator< std::_Rb_tree_node< std::pair< std::string const, base::Value*>>> ::allocate`. | |
| 123 * **Timeline data that can be correlated with other events.** | |
| 124 Did memory suddenly increase during a specific Blink / V8 / HTML parsing | |
| 125 event? Which subsystem increased? Did memory not go down as expected after | |
| 126 closing a tab? Which other threads were active during a bloat? | |
| 127 * **Works out of the box on desktop and mobile.** | |
| 128 No recompilations with unmaintained `GYP_DEFINES`, no time-consuming | |
| 129 symbolizations stages. All the logic is already into Chrome, ready to dump at | |
| 130 any time. | |
| 131 * **The same technology is used for telemetry and the ChromePerf dashboard.** | |
| 132 See [the slides][chromeperf-slides] and take a look at | |
| 133 [some ChromePerf dashboards][chromeperf]. | |
| 134 | |
| 135 [chromeperf-slides]: https://docs.google.com/presentation/d/1OyxyT1sfg50lA36A7ib Z7-bBRXI1kVlvCW0W9qAmM_0/present?slide=id.gde150139b_0_137 | |
| 136 [chromeperf]: https://chromeperf.appspot.com/report?sid=3b54e60c995165657 4e19252fadeca846813afe04453c98a49136af4c8820b8d | |
| 137 | |
| 138 ## Development | |
| 139 | |
| 140 MemoryInfra is based on a simple and extensible architecture. See | |
| 141 [the slides][dp-slides] on how to get your subsystem reported in MemoryInfra, | |
| 142 or take a look at one of the existing examples such as | |
| 143 [malloc_dump_provider.cc][malloc-dp]. Don't hesitate to contact | |
| 144 [tracing@chromium.org][mailtracing] for questions and support. | |
| 145 | |
| 146 [dp-slides]: https://docs.google.com/presentation/d/1GI3HY3Mm5-Mvp6eZyVB0JiaJ- u3L1MMJeKHJg4lxjEI/present?slide=id.g995514d5c_1_45 | |
| 147 [malloc-dp]: https://chromium.googlesource.com/chromium/src.git/+/master/base/ trace_event/malloc_dump_provider.cc | |
| 148 [mailtracing]: mailto:tracing@chromium.org | |
| 149 | |
| 150 Design documents: | |
| 151 | |
| 152 * [Architectural](https://drive.google.com/a/google.com/embeddedfolderview?id=0 B3KuDeqD-lVJfmp0cW1VcE5XVWNxZndxelV5T19kT2NFSndYZlNFbkFpc3pSa2VDN0hlMm8) | |
|
Primiano Tucci (use gerrit)
2016/01/18 15:45:28
Hmm I'd like you kept the <iframes> here, as reduc
Ruud van Asseldonk
2016/01/18 16:25:21
Done, so the one person who actually looks at thes
| |
| 153 * [Chrome-side design docs](https://drive.google.com/a/google.com/embeddedfolde rview?id=0B3KuDeqD-lVJfndSa2dleUQtMnZDeWpPZk1JV0QtbVM5STkwWms4YThzQ0pGTmU1QU9kNV k) | |
| 154 * [Catapult-side design docs](https://drive.google.com/a/google.com/embeddedfol derview?id=0B3KuDeqD-lVJfm10bXd5YmRNWUpKOElOWS0xdU1tMmV1S3F4aHo0ZDJLTmtGRy1qVnQt VWM) | |
| OLD | NEW |