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. | |
|
petrcermak
2016/01/19 10:15:45
Shouldn't this be an enumeration (1, 2, 3, ...)?
| |
| 13 | |
| 14 * [Record a trace as usual][record-trace]: open [chrome://tracing][tracing] on | |
| 15 Desktop Chrome or [chrome://inspect?tracing][inspect-tracing] to trace Chrome | |
| 16 for Android. | |
| 17 | |
| 18 * 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 * 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-t os/trace-event-profiling-tool/recording-tracing-runs | |
| 27 [tracing]: chrome://tracing | |
| 28 [inspect-tracing]: chrome://inspect?tracing | |
| 29 [memory-infra-box]: https://drive.google.com/uc?export=view&id=0Bx14iZPZRgb5RHBJ M1llY1g4cDg | |
| 30 | |
| 31 ![Timeline View and Analysis View][tracing-views] | |
| 32 | |
| 33 After recording a trace, you will see the **timeline view**. Timeline view | |
| 34 shows: | |
| 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 | |
| 40 Click one of the ![M][m-blue] dots to bring up the **analysis view**. Click | |
| 41 on a cell in analysis view to reveal more information about its subsystem. | |
| 42 PartitionAlloc for instance, has more details about its partitions. | |
| 43 | |
| 44 ![Component details for PartitionAlloc][partalloc-details] | |
| 45 | |
| 46 The purple ![M][m-purple] dots represent heavy dumps. In these dumps, components | |
| 47 can provide more details than in the regular dumps. The full details of the | |
| 48 MemoryInfra UI are explained in its [design doc][mi-ui-doc]. | |
| 49 | |
| 50 [tracing-views]: https://drive.google.com/uc?export=view&id=0Bx14iZPZRgb5dFV YV2dtZmNxQjg | |
| 51 [m-blue]: https://drive.google.com/uc?export=view&id=0Bx14iZPZRgb5b1Z TcWY4em42a0U | |
| 52 [partalloc-details]: https://drive.google.com/uc?export=view&id=0Bx14iZPZRgb5eVp PR09yTW9Ebjg | |
| 53 [m-purple]: https://drive.google.com/uc?export=view&id=0Bx14iZPZRgb5RFF Gc0xZZEJWVFk | |
| 54 [mi-ui-doc]: https://docs.google.com/document/d/1b5BSBEd1oB-3zj_CBAQWiQZ 0cmI0HmjmXG-5iNveLqw/edit | |
| 55 | |
| 56 ## Columns | |
| 57 | |
| 58 **Columns in blue** reflect the amount of actual physical memory used by the | |
| 59 process. This is what exerts memory pressure on the system. | |
| 60 | |
| 61 * **Total Resident**: (TODO: document this). | |
| 62 * **Peak Total Resident**: (TODO: document this). | |
| 63 * **PSS**: (TODO: document this). | |
| 64 * **Private Dirty**: (TODO: document this). | |
| 65 * **Swapped**: (TODO: document this). | |
| 66 | |
| 67 **Columns in black** reflect a best estimation of the the amount of physical | |
| 68 memory used by various subsystems of Chrome. | |
| 69 | |
| 70 * **Blink GC**: Memory used by [Oilpan][oilpan]. | |
| 71 * **CC**: Memory used by the compositor. | |
| 72 See [cc/memory][cc-memory] for the full details. | |
| 73 * **Discardable**: (TODO: document this). | |
| 74 * **Font Caches**: (TODO: document this). | |
| 75 * **GPU**: (TODO: document this). | |
| 76 * **GPU Memory Buffer**: (TODO: document this). | |
| 77 * **LevelDB**: (TODO: document this). | |
| 78 * **Malloc**: Memory allocated by calls to `malloc`, or `new` for most | |
| 79 non-Blink objects. | |
| 80 * **PartitionAlloc**: Memory allocated via [PartitionAlloc][partalloc]. | |
| 81 Blink objects that are not managed by Oilpan are allocated with | |
| 82 PartitionAlloc. | |
| 83 * **Skia**: (TODO: document this). | |
| 84 * **SQLite**: (TODO: document this). | |
| 85 * **V8**: (TODO: document this). | |
| 86 * **Web Cache**: (TODO: document this). | |
| 87 | |
| 88 The **tracing column in gray** reports memory that is used to collect all of the | |
| 89 above information. This memory would not be used if tracing were not enabled, | |
| 90 and it is discounted from malloc and the blue columns. | |
| 91 | |
| 92 <!-- TODO(primiano): Improve this. https://crbug.com/??? --> | |
| 93 | |
| 94 [oilpan]: /third_party/WebKit/Source/platform/heap/BlinkGCDesign.md | |
| 95 [cc-memory]: /cc/memory.md | |
| 96 [partalloc]: /third_party/WebKit/Source/wtf/PartitionAlloc.md | |
| 97 | |
| 98 ## Rationale | |
| 99 | |
| 100 Another memory profiler? What is wrong with tool X? | |
| 101 Most of the existing tools: | |
| 102 | |
| 103 * Are hard to get working with Chrome. (Massive symbols, require OS-specific | |
| 104 tricks.) | |
| 105 * Lack Chrome-related context. | |
| 106 * Don't deal with multi-process scenarios. | |
| 107 | |
| 108 MemoryInfra leverages the existing tracing infrastructure in Chrome and provides | |
| 109 contextual data: | |
| 110 | |
| 111 * **It speaks Chrome slang.** | |
| 112 The Chromium codebase is instrumented. Its memory subsystems (allocators, | |
| 113 caches, etc.) uniformly report their stats into the trace in a way that can | |
| 114 be understood by Chrome developers. No more | |
| 115 `__gnu_cxx::new_allocator< std::_Rb_tree_node< std::pair< std::string const, base::Value*>>> ::allocate`. | |
| 116 * **Timeline data that can be correlated with other events.** | |
| 117 Did memory suddenly increase during a specific Blink / V8 / HTML parsing | |
| 118 event? Which subsystem increased? Did memory not go down as expected after | |
| 119 closing a tab? Which other threads were active during a bloat? | |
| 120 * **Works out of the box on desktop and mobile.** | |
| 121 No recompilations with unmaintained `GYP_DEFINES`, no time-consuming | |
| 122 symbolizations stages. All the logic is already into Chrome, ready to dump at | |
| 123 any time. | |
| 124 * **The same technology is used for telemetry and the ChromePerf dashboard.** | |
| 125 See [the slides][chromeperf-slides] and take a look at | |
| 126 [some ChromePerf dashboards][chromeperf] and | |
| 127 [telemetry documentation][telemetry]. | |
| 128 | |
| 129 [chromeperf-slides]: https://docs.google.com/presentation/d/1OyxyT1sfg50lA36A7ib Z7-bBRXI1kVlvCW0W9qAmM_0/present?slide=id.gde150139b_0_137 | |
| 130 [chromeperf]: https://chromeperf.appspot.com/report?sid=3b54e60c995165657 4e19252fadeca846813afe04453c98a49136af4c8820b8d | |
| 131 [telemetry]: https://catapult.gsrc.io/telemetry | |
| 132 | |
| 133 ## Development | |
| 134 | |
| 135 MemoryInfra is based on a simple and extensible architecture. See | |
| 136 [the slides][dp-slides] on how to get your subsystem reported in MemoryInfra, | |
| 137 or take a look at one of the existing examples such as | |
| 138 [malloc_dump_provider.cc][malloc-dp]. The crbug label is | |
| 139 [Hotlist-MemoryInfra][hotlist]. Don't hesitate to contact | |
| 140 [tracing@chromium.org][mailtracing] for questions and support. | |
| 141 | |
| 142 [dp-slides]: https://docs.google.com/presentation/d/1GI3HY3Mm5-Mvp6eZyVB0JiaJ- u3L1MMJeKHJg4lxjEI/present?slide=id.g995514d5c_1_45 | |
| 143 [malloc-dp]: https://chromium.googlesource.com/chromium/src.git/+/master/base/ trace_event/malloc_dump_provider.cc | |
| 144 [hotlist]: https://code.google.com/p/chromium/issues/list?q=label:Hotlist-Me moryInfra | |
| 145 [mailtracing]: mailto:tracing@chromium.org | |
| 146 | |
| 147 ## Design documents | |
| 148 | |
| 149 Architectural: | |
| 150 | |
| 151 <iframe width="100%" height="300px" src="https://docs.google.com/a/google.com/em beddedfolderview?id=0B3KuDeqD-lVJfmp0cW1VcE5XVWNxZndxelV5T19kT2NFSndYZlNFbkFpc3p Sa2VDN0hlMm8"> | |
| 152 </iframe> | |
| 153 | |
| 154 Chrome-side design docs: | |
| 155 | |
| 156 <iframe width="100%" height="300px" src="https://docs.google.com/a/google.com/em beddedfolderview?id=0B3KuDeqD-lVJfndSa2dleUQtMnZDeWpPZk1JV0QtbVM5STkwWms4YThzQ0p GTmU1QU9kNVk"> | |
| 157 </iframe> | |
| 158 | |
| 159 Catapult-side design docs: | |
| 160 | |
| 161 <iframe width="100%" height="300px" src="https://docs.google.com/a/google.com/em beddedfolderview?id=0B3KuDeqD-lVJfm10bXd5YmRNWUpKOElOWS0xdU1tMmV1S3F4aHo0ZDJLTmt GRy1qVnQtVWM"> | |
| 162 </iframe> | |
| OLD | NEW |