Changeset 196780 in webkit
- Timestamp:
- Feb 18, 2016 3:35:42 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r196779 r196780 1 2016-02-18 Andreas Kling <akling@apple.com> 2 3 Fake memory pressure handler should log detailed memory breakdown. 4 <https://webkit.org/b/154415> 5 6 Reviewed by Antti Koivisto. 7 8 Piggyback on the RESOURCE_USAGE code to implement some detailed memory footprint diffing 9 and have the fake memory handler dump before/after/diff after it runs. 10 11 * page/ResourceUsageThread.h: 12 (WebCore::TagInfo::TagInfo): 13 * page/cocoa/ResourceUsageThreadCocoa.mm: 14 (WebCore::logFootprintComparison): 15 (WebCore::displayNameForVMTag): 16 (WebCore::pagesPerVMTag): 17 (WebCore::TagInfo::TagInfo): Deleted. 18 * platform/cocoa/MemoryPressureHandlerCocoa.mm: 19 (WebCore::MemoryPressureHandler::install): 20 1 21 2016-02-18 Brady Eidson <beidson@apple.com> 2 22 -
trunk/Source/WebCore/page/ResourceUsageThread.h
r195644 r196780 30 30 31 31 #include "ResourceUsageData.h" 32 #include <array> 32 33 #include <functional> 33 34 #include <wtf/Condition.h> … … 73 74 }; 74 75 76 #if PLATFORM(COCOA) 77 struct TagInfo { 78 TagInfo() { } 79 size_t dirty { 0 }; 80 size_t reclaimable { 0 }; 81 }; 82 83 const char* displayNameForVMTag(unsigned); 84 std::array<TagInfo, 256> pagesPerVMTag(); 85 void logFootprintComparison(const std::array<TagInfo, 256>&, const std::array<TagInfo, 256>&); 86 #endif 87 75 88 } // namespace WebCore 76 89 -
trunk/Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm
r195644 r196780 52 52 } 53 53 54 struct TagInfo { 55 TagInfo() { } 56 size_t dirty { 0 }; 57 size_t reclaimable { 0 }; 58 }; 59 60 static std::array<TagInfo, 256> pagesPerVMTag() 54 void logFootprintComparison(const std::array<TagInfo, 256>& before, const std::array<TagInfo, 256>& after) 55 { 56 const size_t pageSize = vmPageSize(); 57 58 WTFLogAlways("Per-tag breakdown of memory reclaimed by pressure handler:"); 59 WTFLogAlways(" ## %16s %10s %10s %10s", "VM Tag", "Before", "After", "Diff"); 60 for (unsigned i = 0; i < 256; ++i) { 61 ssize_t dirtyBefore = before[i].dirty * pageSize; 62 ssize_t dirtyAfter = after[i].dirty * pageSize; 63 ssize_t dirtyDiff = dirtyAfter - dirtyBefore; 64 if (!dirtyBefore && !dirtyAfter) 65 continue; 66 String tagName = displayNameForVMTag(i); 67 if (!tagName) 68 tagName = String::format("Tag %u", i); 69 WTFLogAlways(" %02X %16s %10ld %10ld %10ld", 70 i, 71 tagName.ascii().data(), 72 dirtyBefore, 73 dirtyAfter, 74 dirtyDiff 75 ); 76 } 77 } 78 79 const char* displayNameForVMTag(unsigned tag) 80 { 81 switch (tag) { 82 case VM_MEMORY_IOKIT: return "IOKit"; 83 case VM_MEMORY_LAYERKIT: return "CoreAnimation"; 84 case VM_MEMORY_IMAGEIO: return "ImageIO"; 85 case VM_MEMORY_CGIMAGE: return "CG image"; 86 case VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR: return "JSC JIT"; 87 case VM_MEMORY_MALLOC: return "malloc"; 88 case VM_MEMORY_MALLOC_HUGE: return "malloc (huge)"; 89 case VM_MEMORY_MALLOC_LARGE: return "malloc (large)"; 90 case VM_MEMORY_MALLOC_SMALL: return "malloc (small)"; 91 case VM_MEMORY_MALLOC_TINY: return "malloc (tiny)"; 92 case VM_MEMORY_MALLOC_NANO: return "malloc (nano)"; 93 case VM_MEMORY_TCMALLOC: return "bmalloc"; 94 case VM_MEMORY_FOUNDATION: return "Foundation"; 95 case VM_MEMORY_STACK: return "Stack"; 96 case VM_MEMORY_SQLITE: return "SQLite"; 97 case VM_MEMORY_UNSHARED_PMAP: return "pmap (unshared)"; 98 case VM_MEMORY_DYLIB: return "dylib"; 99 case VM_MEMORY_CORESERVICES: return "CoreServices"; 100 case VM_MEMORY_OS_ALLOC_ONCE: return "os_alloc_once"; 101 case VM_MEMORY_LIBDISPATCH: return "libdispatch"; 102 default: return nullptr; 103 } 104 } 105 106 std::array<TagInfo, 256> pagesPerVMTag() 61 107 { 62 108 std::array<TagInfo, 256> tags; -
trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm
r196753 r196780 33 33 #import "LayerPool.h" 34 34 #import "Logging.h" 35 #import "ResourceUsageThread.h" 35 36 #import "WebCoreSystemInterface.h" 36 37 #import <mach/mach.h> … … 39 40 #import <notify.h> 40 41 #import <wtf/CurrentTime.h> 42 #import <sys/sysctl.h> 41 43 42 44 #if PLATFORM(IOS) … … 129 131 // Allow simulation of memory pressure with "notifyutil -p org.WebKit.lowMemory" 130 132 notify_register_dispatch("org.WebKit.lowMemory", &_notifyToken, dispatch_get_main_queue(), ^(int) { 133 #if ENABLE(RESOURCE_USAGE) 134 auto footprintBefore = pagesPerVMTag(); 135 #endif 136 131 137 bool wasUnderMemoryPressure = m_underMemoryPressure; 132 138 m_underMemoryPressure = true; … … 137 143 138 144 malloc_zone_pressure_relief(nullptr, 0); 145 146 #if ENABLE(RESOURCE_USAGE) 147 auto footprintAfter = pagesPerVMTag(); 148 logFootprintComparison(footprintBefore, footprintAfter); 149 #endif 139 150 140 151 // Since this is a simulation, unset the "under memory pressure" flag on next runloop.
Note: See TracChangeset
for help on using the changeset viewer.