Changeset 232098 in webkit
- Timestamp:
- May 22, 2018 7:36:04 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r232094 r232098 1 2018-05-22 Simon Fraser <simon.fraser@apple.com> 2 3 Add notifyutil callbacks to dump the memory cache, and the list of live Pages and Documents 4 https://bugs.webkit.org/show_bug.cgi?id=185853 5 6 Reviewed by Keith Miller. 7 8 Add a notifyutil callback to dump the PageCache, which dumps the stats, and the list of live pages. 9 This can be invoked on iOS and macOS via "notifyutil -p com.apple.WebKit.showPageCache". 10 11 Add a notifyutil callback that dumps the list of all Pages, and the list of all Documents, with 12 Document pointer address and URL. 13 This can be invoked on iOS and macOS via "notifyutil -p com.apple.WebKit.showAllDocuments". 14 15 * history/PageCache.cpp: 16 (WebCore::PageCache::PageCache): 17 (WebCore::PageCache::dump const): 18 * history/PageCache.h: 19 * loader/cache/CachedResource.h: 20 (WebCore::CachedResource::numberOfClients const): 21 (WebCore::CachedResource::count const): Deleted. 22 * loader/cache/MemoryCache.cpp: 23 (WebCore::MemoryCache::MemoryCache): 24 (WebCore::MemoryCache::pruneLiveResourcesToSize): 25 (WebCore::MemoryCache::dumpStats): 26 (WebCore::MemoryCache::dumpLRULists const): 27 * loader/cache/MemoryCache.h: 28 * page/mac/PageMac.mm: 29 (WebCore::Page::platformInitialize): 30 1 31 2018-05-22 Dean Jackson <dino@apple.com> 2 32 -
trunk/Source/WebCore/PAL/ChangeLog
r232069 r232098 1 2018-05-22 Simon Fraser <simon.fraser@apple.com> 2 3 Add notifyutil callbacks to dump the memory cache, and the list of live Pages and Documents 4 https://bugs.webkit.org/show_bug.cgi?id=185853 5 6 Reviewed by Keith Miller. 7 8 Compile registerNotifyCallback in release builds. 9 10 * pal/Logging.cpp: 11 (PAL::registerNotifyCallback): 12 * pal/Logging.h: 13 1 14 2018-05-22 Ryan Haddad <ryanhaddad@apple.com> 2 15 -
trunk/Source/WebCore/PAL/pal/Logging.cpp
r223206 r232098 82 82 } 83 83 84 #ifndef NDEBUG 84 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED 85 85 86 void registerNotifyCallback(const String& notifyID, WTF::Function<void()>&& callback) 86 87 { … … 95 96 #endif 96 97 } 97 #endif98 99 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED100 98 101 99 } // namespace WebCore -
trunk/Source/WebCore/PAL/pal/Logging.h
r223206 r232098 46 46 bool isLogChannelEnabled(const String& name); 47 47 PAL_EXPORT void setLogChannelToAccumulate(const String& name); 48 #ifndef NDEBUG49 void registerNotifyCallback(const String& notifyID, WTF::Function<void()>&& callback);50 #endif51 48 52 49 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED 53 50 51 PAL_EXPORT void registerNotifyCallback(const String&, WTF::Function<void()>&&); 52 54 53 } // namespace PAL 55 54 -
trunk/Source/WebCore/history/PageCache.cpp
r230211 r232098 49 49 #include "Settings.h" 50 50 #include "SubframeLoader.h" 51 #include <pal/Logging.h> 51 52 #include <wtf/MemoryPressureHandler.h> 52 53 #include <wtf/NeverDestroyed.h> … … 278 279 return globalPageCache; 279 280 } 280 281 282 PageCache::PageCache() 283 { 284 static std::once_flag onceFlag; 285 std::call_once(onceFlag, [] { 286 PAL::registerNotifyCallback("com.apple.WebKit.showPageCache", [] { 287 PageCache::singleton().dump(); 288 }); 289 }); 290 } 291 292 void PageCache::dump() const 293 { 294 WTFLogAlways("\nPage Cache:"); 295 for (auto& item : m_items) { 296 CachedPage& cachedPage = *item->m_cachedPage; 297 WTFLogAlways(" Page %p, document %p %s", &cachedPage.page(), cachedPage.document(), cachedPage.document() ? cachedPage.document()->url().string().utf8().data() : ""); 298 } 299 } 300 281 301 bool PageCache::canCache(Page& page) const 282 302 { -
trunk/Source/WebCore/history/PageCache.h
r219501 r232098 69 69 70 70 private: 71 PageCache() = default; // Use singleton() instead.71 PageCache(); 72 72 ~PageCache() = delete; // Make sure nobody accidentally calls delete -- WebCore does not delete singletons. 73 73 … … 75 75 76 76 void prune(PruningReason); 77 void dump() const; 77 78 78 79 ListHashSet<RefPtr<HistoryItem>> m_items; -
trunk/Source/WebCore/loader/cache/CachedResource.h
r229585 r232098 145 145 void destroyDecodedDataIfNeeded(); 146 146 147 unsigned count() const { return m_clients.size(); }147 unsigned numberOfClients() const { return m_clients.size(); } 148 148 149 149 Status status() const { return static_cast<Status>(m_status); } -
trunk/Source/WebCore/loader/cache/MemoryCache.cpp
r229209 r232098 40 40 #include "WorkerLoaderProxy.h" 41 41 #include "WorkerThread.h" 42 #include <pal/Logging.h> 42 43 #include <stdio.h> 43 44 #include <wtf/MathExtras.h> … … 60 61 61 62 MemoryCache::MemoryCache() 62 : m_disabled(false) 63 , m_inPruneResources(false) 64 , m_capacity(cDefaultCacheCapacity) 65 , m_minDeadCapacity(0) 63 : m_capacity(cDefaultCacheCapacity) 66 64 , m_maxDeadCapacity(cDefaultCacheCapacity) 67 , m_liveSize(0)68 , m_deadSize(0)69 65 , m_pruneTimer(*this, &MemoryCache::prune) 70 66 { 71 67 static_assert(sizeof(long long) > sizeof(unsigned), "Numerical overflow can happen when adjusting the size of the cached memory."); 68 69 static std::once_flag onceFlag; 70 std::call_once(onceFlag, [] { 71 PAL::registerNotifyCallback("com.apple.WebKit.showMemoryCache", [] { 72 MemoryCache::singleton().dumpStats(); 73 MemoryCache::singleton().dumpLRULists(true); 74 }); 75 }); 72 76 } 73 77 … … 330 334 // Destroy our decoded data. This will remove us from m_liveDecodedResources, and possibly move us 331 335 // to a different LRU list in m_allResources. 336 WTFLogAlways("pruneLiveResourcesToSize: trying to prune %p", current); 332 337 current->destroyDecodedData(); 333 338 … … 734 739 } 735 740 736 #ifndef NDEBUG737 741 void MemoryCache::dumpStats() 738 742 { 739 743 Statistics s = getStatistics(); 740 printf("%-13s %-13s %-13s %-13s %-13s\n", "", "Count", "Size", "LiveSize", "DecodedSize"); 741 printf("%-13s %-13s %-13s %-13s %-13s\n", "-------------", "-------------", "-------------", "-------------", "-------------"); 742 printf("%-13s %13d %13d %13d %13d\n", "Images", s.images.count, s.images.size, s.images.liveSize, s.images.decodedSize); 743 printf("%-13s %13d %13d %13d %13d\n", "CSS", s.cssStyleSheets.count, s.cssStyleSheets.size, s.cssStyleSheets.liveSize, s.cssStyleSheets.decodedSize); 744 WTFLogAlways("\nMemory Cache"); 745 WTFLogAlways("%-13s %-13s %-13s %-13s %-13s\n", "", "Count", "Size", "LiveSize", "DecodedSize"); 746 WTFLogAlways("%-13s %-13s %-13s %-13s %-13s\n", "-------------", "-------------", "-------------", "-------------", "-------------"); 747 WTFLogAlways("%-13s %13d %13d %13d %13d\n", "Images", s.images.count, s.images.size, s.images.liveSize, s.images.decodedSize); 748 WTFLogAlways("%-13s %13d %13d %13d %13d\n", "CSS", s.cssStyleSheets.count, s.cssStyleSheets.size, s.cssStyleSheets.liveSize, s.cssStyleSheets.decodedSize); 744 749 #if ENABLE(XSLT) 745 printf("%-13s %13d %13d %13d %13d\n", "XSL", s.xslStyleSheets.count, s.xslStyleSheets.size, s.xslStyleSheets.liveSize, s.xslStyleSheets.decodedSize);750 WTFLogAlways("%-13s %13d %13d %13d %13d\n", "XSL", s.xslStyleSheets.count, s.xslStyleSheets.size, s.xslStyleSheets.liveSize, s.xslStyleSheets.decodedSize); 746 751 #endif 747 printf("%-13s %13d %13d %13d %13d\n", "JavaScript", s.scripts.count, s.scripts.size, s.scripts.liveSize, s.scripts.decodedSize); 748 printf("%-13s %13d %13d %13d %13d\n", "Fonts", s.fonts.count, s.fonts.size, s.fonts.liveSize, s.fonts.decodedSize); 749 printf("%-13s %-13s %-13s %-13s %-13s\n\n", "-------------", "-------------", "-------------", "-------------", "-------------"); 752 WTFLogAlways("%-13s %13d %13d %13d %13d\n", "JavaScript", s.scripts.count, s.scripts.size, s.scripts.liveSize, s.scripts.decodedSize); 753 WTFLogAlways("%-13s %13d %13d %13d %13d\n", "Fonts", s.fonts.count, s.fonts.size, s.fonts.liveSize, s.fonts.decodedSize); 754 WTFLogAlways("%-13s %-13s %-13s %-13s %-13s\n\n", "-------------", "-------------", "-------------", "-------------", "-------------"); 755 756 unsigned countTotal = s.images.count + s.cssStyleSheets.count + s.scripts.count + s.fonts.count; 757 unsigned sizeTotal = s.images.size + s.cssStyleSheets.size + s.scripts.size + s.fonts.size; 758 unsigned liveSizeTotal = s.images.liveSize + s.cssStyleSheets.liveSize + s.scripts.liveSize + s.fonts.liveSize; 759 unsigned decodedSizeTotal = s.images.decodedSize + s.cssStyleSheets.decodedSize + s.scripts.decodedSize + s.fonts.decodedSize; 760 #if ENABLE(XSLT) 761 countTotal += s.xslStyleSheets.count; 762 sizeTotal += s.xslStyleSheets.size; 763 liveSizeTotal += s.xslStyleSheets.liveSize; 764 decodedSizeTotal += s.xslStyleSheets.decodedSize; 765 #endif 766 767 WTFLogAlways("%-13s %13d %11.2fKB %11.2fKB %11.2fKB\n", "Total", countTotal, sizeTotal / 1024., liveSizeTotal / 1024., decodedSizeTotal / 1024.); 750 768 } 751 769 752 770 void MemoryCache::dumpLRULists(bool includeLive) const 753 771 { 754 printf("LRU-SP lists in eviction order (Kilobytes decoded, Kilobytes encoded, Access count, Referenced):\n");772 WTFLogAlways("LRU-SP lists in eviction order (Kilobytes decoded, Kilobytes encoded, Access count, Referenced):\n"); 755 773 756 774 int size = m_allResources.size(); 757 775 for (int i = size - 1; i >= 0; i--) { 758 printf("\n\nList %d:", i);776 WTFLogAlways("\nList %d:\n", i); 759 777 for (auto* resource : *m_allResources[i]) { 760 778 if (includeLive || !resource->hasClients()) 761 printf("(%.1fK, %.1fK, %uA, %dR); ", resource->decodedSize() / 1024.0f, (resource->encodedSize() + resource->overheadSize()) / 1024.0f, resource->accessCount(), resource->hasClients()); 762 } 763 } 764 } 765 #endif 779 WTFLogAlways(" %.100s %.1fK, %.1fK, accesses: %u, clients: %d\n", resource->url().string().utf8().data(), resource->decodedSize() / 1024.0f, (resource->encodedSize() + resource->overheadSize()) / 1024.0f, resource->accessCount(), resource->numberOfClients()); 780 } 781 } 782 } 766 783 767 784 } // namespace WebCore -
trunk/Source/WebCore/loader/cache/MemoryCache.h
r220887 r232098 177 177 178 178 LRUList& lruListFor(CachedResource&); 179 #ifndef NDEBUG 179 180 180 void dumpStats(); 181 181 void dumpLRULists(bool includeLive) const; 182 #endif183 182 184 183 unsigned liveCapacity() const; … … 191 190 CachedResourceMap* sessionResourceMap(PAL::SessionID) const; 192 191 193 bool m_disabled ; // Whether or not the cache is enabled.194 bool m_inPruneResources ;192 bool m_disabled { false }; 193 bool m_inPruneResources { false }; 195 194 196 195 unsigned m_capacity; 197 unsigned m_minDeadCapacity ;196 unsigned m_minDeadCapacity { 0 }; 198 197 unsigned m_maxDeadCapacity; 199 198 Seconds m_deadDecodedDataDeletionInterval; 200 199 201 unsigned m_liveSize ; // The number of bytes currently consumed by "live" resources in the cache.202 unsigned m_deadSize ; // The number of bytes currently consumed by "dead" resources in the cache.200 unsigned m_liveSize { 0 }; // The number of bytes currently consumed by "live" resources in the cache. 201 unsigned m_deadSize { 0 }; // The number of bytes currently consumed by "dead" resources in the cache. 203 202 204 203 // Size-adjusted and popularity-aware LRU list collection for cache objects. This collection can hold -
trunk/Source/WebCore/page/mac/PageMac.mm
r231141 r232098 53 53 #endif 54 54 55 #if ENABLE(TREE_DEBUGGING)56 55 static std::once_flag onceFlag; 57 56 std::call_once(onceFlag, [] { 57 #if ENABLE(TREE_DEBUGGING) 58 58 PAL::registerNotifyCallback("com.apple.WebKit.showRenderTree", printRenderTreeForLiveDocuments); 59 59 PAL::registerNotifyCallback("com.apple.WebKit.showLayerTree", printLayerTreeForLiveDocuments); … … 61 61 PAL::registerNotifyCallback("com.apple.WebKit.showLayoutTree", Layout::printLayoutTreeForLiveDocuments); 62 62 #endif 63 #endif // ENABLE(TREE_DEBUGGING) 64 65 PAL::registerNotifyCallback("com.apple.WebKit.showAllDocuments", [] { 66 unsigned numPages = 0; 67 Page::forEachPage([&numPages](Page&) { 68 ++numPages; 69 }); 70 71 WTFLogAlways("%u live pages:", numPages); 72 73 Page::forEachPage([](Page& page) { 74 const auto* mainFrameDocument = page.mainFrame().document(); 75 WTFLogAlways("Page %p with main document %p %s", &page, mainFrameDocument, mainFrameDocument ? mainFrameDocument->url().string().utf8().data() : ""); 76 }); 77 78 WTFLogAlways("%u live documents:", Document::allDocuments().size()); 79 for (const auto* document : Document::allDocuments()) { 80 WTFLogAlways("Document %p %s", document, document->url().string().utf8().data()); 81 } 82 }); 63 83 }); 64 #endif65 84 } 66 85
Note: See TracChangeset
for help on using the changeset viewer.