WebKit Bugzilla
Attachment 340930 Details for
Bug 185853
: Add notifyutil callbacks to dump the memory cache, and the list of live Pages and Documents
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185853-20180521172009.patch (text/plain), 16.10 KB, created by
Simon Fraser (smfr)
on 2018-05-21 17:20:10 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Simon Fraser (smfr)
Created:
2018-05-21 17:20:10 PDT
Size:
16.10 KB
patch
obsolete
>Subversion Revision: 231939 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 89853a77b099dddbd9efdbfb07a498cb398aa671..7f121cb3a61b698945f35c47ddbff86a1701891d 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,31 @@ >+2018-05-21 Simon Fraser <simon.fraser@apple.com> >+ >+ Add notifyutil callbacks to dump the memory cache, and the list of live Pages and Documents >+ https://bugs.webkit.org/show_bug.cgi?id=185853 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a notifyutil callback to dump the PageCache, which dumps the stats, and the list of live pages. >+ >+ Add a notifyutil callback that dumps the list of all Pages, and the list of all Documents, with >+ Document pointer address and URL. >+ >+ * history/PageCache.cpp: >+ (WebCore::PageCache::PageCache): >+ (WebCore::PageCache::dump const): >+ * history/PageCache.h: >+ * loader/cache/CachedResource.h: >+ (WebCore::CachedResource::numberOfClients const): >+ (WebCore::CachedResource::count const): Deleted. >+ * loader/cache/MemoryCache.cpp: >+ (WebCore::MemoryCache::MemoryCache): >+ (WebCore::MemoryCache::pruneLiveResourcesToSize): >+ (WebCore::MemoryCache::dumpStats): >+ (WebCore::MemoryCache::dumpLRULists const): >+ * loader/cache/MemoryCache.h: >+ * page/mac/PageMac.mm: >+ (WebCore::Page::platformInitialize): >+ > 2018-05-17 Nan Wang <n_wang@apple.com> > > AX: [macOS] Expose the primary screen height through AX API >diff --git a/Source/WebCore/PAL/ChangeLog b/Source/WebCore/PAL/ChangeLog >index 0b97a9b9e84962e6d9b2e8126bdca13efe8858d2..28c42133b36ab82f563fa5b1b5ed35d55ee332ed 100644 >--- a/Source/WebCore/PAL/ChangeLog >+++ b/Source/WebCore/PAL/ChangeLog >@@ -1,3 +1,16 @@ >+2018-05-21 Simon Fraser <simon.fraser@apple.com> >+ >+ Add notifyutil callbacks to dump the memory cache, and the list of live Pages and Documents >+ https://bugs.webkit.org/show_bug.cgi?id=185853 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Compile registerNotifyCallback in release builds. >+ >+ * pal/Logging.cpp: >+ (PAL::registerNotifyCallback): >+ * pal/Logging.h: >+ > 2018-05-16 Andy VanWagoner <andy@vanwagoner.family> > > Add support for Intl NumberFormat formatToParts >diff --git a/Source/WebCore/PAL/pal/Logging.cpp b/Source/WebCore/PAL/pal/Logging.cpp >index af817ad75d0c75cfa6dcb4368299332cf3bdf0b2..93d67ff9364fb4f996f86332487edcc2fb384fd1 100644 >--- a/Source/WebCore/PAL/pal/Logging.cpp >+++ b/Source/WebCore/PAL/pal/Logging.cpp >@@ -81,7 +81,6 @@ void initializeLogChannelsIfNecessary(std::optional<String> logChannelString) > WTFInitializeLogChannelStatesFromString(logChannels, logChannelCount, enabledChannelsString.utf8().data()); > } > >-#ifndef NDEBUG > void registerNotifyCallback(const String& notifyID, WTF::Function<void()>&& callback) > { > #if PLATFORM(COCOA) >@@ -94,7 +93,6 @@ void registerNotifyCallback(const String& notifyID, WTF::Function<void()>&& call > UNUSED_PARAM(callback); > #endif > } >-#endif > > #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED > >diff --git a/Source/WebCore/PAL/pal/Logging.h b/Source/WebCore/PAL/pal/Logging.h >index a1cddd844919705fcd1b598cce19fea53880b88e..45f57caa01d7be399eb968458af8732e04421ccf 100644 >--- a/Source/WebCore/PAL/pal/Logging.h >+++ b/Source/WebCore/PAL/pal/Logging.h >@@ -45,9 +45,7 @@ PAL_LOG_CHANNELS(DECLARE_LOG_CHANNEL) > String logLevelString(); > bool isLogChannelEnabled(const String& name); > PAL_EXPORT void setLogChannelToAccumulate(const String& name); >-#ifndef NDEBUG >-void registerNotifyCallback(const String& notifyID, WTF::Function<void()>&& callback); >-#endif >+void registerNotifyCallback(const String&, WTF::Function<void()>&&); > > #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED > >diff --git a/Source/WebCore/history/PageCache.cpp b/Source/WebCore/history/PageCache.cpp >index edb75c2289bec853f89b962366f0c11c783b4f5a..44906cef649d05ef8d2df6d7ca447f83c4f86c82 100644 >--- a/Source/WebCore/history/PageCache.cpp >+++ b/Source/WebCore/history/PageCache.cpp >@@ -48,6 +48,7 @@ > #include "ScriptDisallowedScope.h" > #include "Settings.h" > #include "SubframeLoader.h" >+#include <pal/Logging.h> > #include <wtf/MemoryPressureHandler.h> > #include <wtf/NeverDestroyed.h> > #include <wtf/SetForScope.h> >@@ -277,7 +278,26 @@ PageCache& PageCache::singleton() > static NeverDestroyed<PageCache> globalPageCache; > return globalPageCache; > } >- >+ >+PageCache::PageCache() >+{ >+ static std::once_flag onceFlag; >+ std::call_once(onceFlag, [] { >+ PAL::registerNotifyCallback("com.apple.WebKit.showPageCache", [] { >+ PageCache::singleton().dump(); >+ }); >+ }); >+} >+ >+void PageCache::dump() const >+{ >+ WTFLogAlways("\nPage Cache:"); >+ for (auto& item : m_items) { >+ CachedPage& cachedPage = *item->m_cachedPage; >+ WTFLogAlways(" Page %p, document %p %s", &cachedPage.page(), cachedPage.document(), cachedPage.document() ? cachedPage.document()->url().string().utf8().data() : ""); >+ } >+} >+ > bool PageCache::canCache(Page& page) const > { > if (!m_maxSize) { >diff --git a/Source/WebCore/history/PageCache.h b/Source/WebCore/history/PageCache.h >index 51c1e0547e0136edf8694985197d6ad588bf491c..a62df9ac857489cd1d391030a83987803852de6f 100644 >--- a/Source/WebCore/history/PageCache.h >+++ b/Source/WebCore/history/PageCache.h >@@ -68,12 +68,13 @@ public: > #endif > > private: >- PageCache() = default; // Use singleton() instead. >+ PageCache(); > ~PageCache() = delete; // Make sure nobody accidentally calls delete -- WebCore does not delete singletons. > > static bool canCachePageContainingThisFrame(Frame&); > > void prune(PruningReason); >+ void dump() const; > > ListHashSet<RefPtr<HistoryItem>> m_items; > unsigned m_maxSize {0}; >diff --git a/Source/WebCore/loader/cache/CachedResource.h b/Source/WebCore/loader/cache/CachedResource.h >index 01913bcb371e2dad9ebeab7e85c64aa19e2280a8..f3290f51c722917a7ce4090173587639c9527270 100644 >--- a/Source/WebCore/loader/cache/CachedResource.h >+++ b/Source/WebCore/loader/cache/CachedResource.h >@@ -144,7 +144,7 @@ public: > virtual void allClientsRemoved(); > void destroyDecodedDataIfNeeded(); > >- unsigned count() const { return m_clients.size(); } >+ unsigned numberOfClients() const { return m_clients.size(); } > > Status status() const { return static_cast<Status>(m_status); } > void setStatus(Status status) { m_status = status; } >diff --git a/Source/WebCore/loader/cache/MemoryCache.cpp b/Source/WebCore/loader/cache/MemoryCache.cpp >index 8c486b3ec233d56305b8718be7d3cc1f8042c13e..945803c20ae10b3b845a211f2fe96efdfa62d41e 100644 >--- a/Source/WebCore/loader/cache/MemoryCache.cpp >+++ b/Source/WebCore/loader/cache/MemoryCache.cpp >@@ -39,6 +39,7 @@ > #include "WorkerGlobalScope.h" > #include "WorkerLoaderProxy.h" > #include "WorkerThread.h" >+#include <pal/Logging.h> > #include <stdio.h> > #include <wtf/MathExtras.h> > #include <wtf/NeverDestroyed.h> >@@ -59,16 +60,19 @@ MemoryCache& MemoryCache::singleton() > } > > MemoryCache::MemoryCache() >- : m_disabled(false) >- , m_inPruneResources(false) >- , m_capacity(cDefaultCacheCapacity) >- , m_minDeadCapacity(0) >+ : m_capacity(cDefaultCacheCapacity) > , m_maxDeadCapacity(cDefaultCacheCapacity) >- , m_liveSize(0) >- , m_deadSize(0) > , m_pruneTimer(*this, &MemoryCache::prune) > { > static_assert(sizeof(long long) > sizeof(unsigned), "Numerical overflow can happen when adjusting the size of the cached memory."); >+ >+ static std::once_flag onceFlag; >+ std::call_once(onceFlag, [] { >+ PAL::registerNotifyCallback("com.apple.WebKit.showMemoryCache", [] { >+ MemoryCache::singleton().dumpStats(); >+ MemoryCache::singleton().dumpLRULists(true); >+ }); >+ }); > } > > auto MemoryCache::sessionResourceMap(PAL::SessionID sessionID) const -> CachedResourceMap* >@@ -329,6 +333,7 @@ void MemoryCache::pruneLiveResourcesToSize(unsigned targetSize, bool shouldDestr > > // Destroy our decoded data. This will remove us from m_liveDecodedResources, and possibly move us > // to a different LRU list in m_allResources. >+ WTFLogAlways("pruneLiveResourcesToSize: trying to prune %p", current); > current->destroyDecodedData(); > > if (targetSize && m_liveSize <= targetSize) >@@ -733,35 +738,47 @@ void MemoryCache::pruneSoon() > m_pruneTimer.startOneShot(0_s); > } > >-#ifndef NDEBUG > void MemoryCache::dumpStats() > { > Statistics s = getStatistics(); >- printf("%-13s %-13s %-13s %-13s %-13s\n", "", "Count", "Size", "LiveSize", "DecodedSize"); >- printf("%-13s %-13s %-13s %-13s %-13s\n", "-------------", "-------------", "-------------", "-------------", "-------------"); >- printf("%-13s %13d %13d %13d %13d\n", "Images", s.images.count, s.images.size, s.images.liveSize, s.images.decodedSize); >- printf("%-13s %13d %13d %13d %13d\n", "CSS", s.cssStyleSheets.count, s.cssStyleSheets.size, s.cssStyleSheets.liveSize, s.cssStyleSheets.decodedSize); >+ WTFLogAlways("\nMemory Cache"); >+ WTFLogAlways("%-13s %-13s %-13s %-13s %-13s\n", "", "Count", "Size", "LiveSize", "DecodedSize"); >+ WTFLogAlways("%-13s %-13s %-13s %-13s %-13s\n", "-------------", "-------------", "-------------", "-------------", "-------------"); >+ WTFLogAlways("%-13s %13d %13d %13d %13d\n", "Images", s.images.count, s.images.size, s.images.liveSize, s.images.decodedSize); >+ WTFLogAlways("%-13s %13d %13d %13d %13d\n", "CSS", s.cssStyleSheets.count, s.cssStyleSheets.size, s.cssStyleSheets.liveSize, s.cssStyleSheets.decodedSize); > #if ENABLE(XSLT) >- printf("%-13s %13d %13d %13d %13d\n", "XSL", s.xslStyleSheets.count, s.xslStyleSheets.size, s.xslStyleSheets.liveSize, s.xslStyleSheets.decodedSize); >+ WTFLogAlways("%-13s %13d %13d %13d %13d\n", "XSL", s.xslStyleSheets.count, s.xslStyleSheets.size, s.xslStyleSheets.liveSize, s.xslStyleSheets.decodedSize); > #endif >- printf("%-13s %13d %13d %13d %13d\n", "JavaScript", s.scripts.count, s.scripts.size, s.scripts.liveSize, s.scripts.decodedSize); >- printf("%-13s %13d %13d %13d %13d\n", "Fonts", s.fonts.count, s.fonts.size, s.fonts.liveSize, s.fonts.decodedSize); >- printf("%-13s %-13s %-13s %-13s %-13s\n\n", "-------------", "-------------", "-------------", "-------------", "-------------"); >+ WTFLogAlways("%-13s %13d %13d %13d %13d\n", "JavaScript", s.scripts.count, s.scripts.size, s.scripts.liveSize, s.scripts.decodedSize); >+ WTFLogAlways("%-13s %13d %13d %13d %13d\n", "Fonts", s.fonts.count, s.fonts.size, s.fonts.liveSize, s.fonts.decodedSize); >+ WTFLogAlways("%-13s %-13s %-13s %-13s %-13s\n\n", "-------------", "-------------", "-------------", "-------------", "-------------"); >+ >+ unsigned countTotal = s.images.count + s.cssStyleSheets.count + s.scripts.count + s.fonts.count; >+ unsigned sizeTotal = s.images.size + s.cssStyleSheets.size + s.scripts.size + s.fonts.size; >+ unsigned liveSizeTotal = s.images.liveSize + s.cssStyleSheets.liveSize + s.scripts.liveSize + s.fonts.liveSize; >+ unsigned decodedSizeTotal = s.images.decodedSize + s.cssStyleSheets.decodedSize + s.scripts.decodedSize + s.fonts.decodedSize; >+#if ENABLE(XSLT) >+ countTotal += s.xslStyleSheets.count; >+ sizeTotal += s.xslStyleSheets.size; >+ liveSizeTotal += s.xslStyleSheets.liveSize; >+ decodedSizeTotal += s.xslStyleSheets.decodedSize; >+#endif >+ >+ WTFLogAlways("%-13s %13d %11.2fKB %11.2fKB %11.2fKB\n", "Total", countTotal, sizeTotal / 1024., liveSizeTotal / 1024., decodedSizeTotal / 1024.); > } > > void MemoryCache::dumpLRULists(bool includeLive) const > { >- printf("LRU-SP lists in eviction order (Kilobytes decoded, Kilobytes encoded, Access count, Referenced):\n"); >+ WTFLogAlways("LRU-SP lists in eviction order (Kilobytes decoded, Kilobytes encoded, Access count, Referenced):\n"); > > int size = m_allResources.size(); > for (int i = size - 1; i >= 0; i--) { >- printf("\n\nList %d: ", i); >+ WTFLogAlways("\nList %d:\n", i); > for (auto* resource : *m_allResources[i]) { > if (includeLive || !resource->hasClients()) >- printf("(%.1fK, %.1fK, %uA, %dR); ", resource->decodedSize() / 1024.0f, (resource->encodedSize() + resource->overheadSize()) / 1024.0f, resource->accessCount(), resource->hasClients()); >+ 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()); > } > } > } >-#endif > > } // namespace WebCore >diff --git a/Source/WebCore/loader/cache/MemoryCache.h b/Source/WebCore/loader/cache/MemoryCache.h >index d26eec152eb7d3b67a8ad325556645407b1c0952..d716798a4ce1d97d61d313e9518b7dc2269f705c 100644 >--- a/Source/WebCore/loader/cache/MemoryCache.h >+++ b/Source/WebCore/loader/cache/MemoryCache.h >@@ -176,10 +176,9 @@ private: > ~MemoryCache(); // Not implemented to make sure nobody accidentally calls delete -- WebCore does not delete singletons. > > LRUList& lruListFor(CachedResource&); >-#ifndef NDEBUG >+ > void dumpStats(); > void dumpLRULists(bool includeLive) const; >-#endif > > unsigned liveCapacity() const; > unsigned deadCapacity() const; >@@ -190,16 +189,16 @@ private: > CachedResourceMap& ensureSessionResourceMap(PAL::SessionID); > CachedResourceMap* sessionResourceMap(PAL::SessionID) const; > >- bool m_disabled; // Whether or not the cache is enabled. >- bool m_inPruneResources; >+ bool m_disabled { false }; >+ bool m_inPruneResources { false }; > > unsigned m_capacity; >- unsigned m_minDeadCapacity; >+ unsigned m_minDeadCapacity { 0 }; > unsigned m_maxDeadCapacity; > Seconds m_deadDecodedDataDeletionInterval; > >- unsigned m_liveSize; // The number of bytes currently consumed by "live" resources in the cache. >- unsigned m_deadSize; // The number of bytes currently consumed by "dead" resources in the cache. >+ unsigned m_liveSize { 0 }; // The number of bytes currently consumed by "live" resources in the cache. >+ unsigned m_deadSize { 0 }; // The number of bytes currently consumed by "dead" resources in the cache. > > // Size-adjusted and popularity-aware LRU list collection for cache objects. This collection can hold > // more resources than the cached resource map, since it can also hold "stale" multiple versions of objects that are >diff --git a/Source/WebCore/page/mac/PageMac.mm b/Source/WebCore/page/mac/PageMac.mm >index edf18107e2004eed48c3b1293a31cbe174e22543..e743d6ea87c05b00770639524658384c9050d34a 100644 >--- a/Source/WebCore/page/mac/PageMac.mm >+++ b/Source/WebCore/page/mac/PageMac.mm >@@ -52,16 +52,35 @@ void Page::platformInitialize() > addSchedulePair(SchedulePair::create([[NSRunLoop currentRunLoop] getCFRunLoop], kCFRunLoopCommonModes)); > #endif > >-#if ENABLE(TREE_DEBUGGING) > static std::once_flag onceFlag; > std::call_once(onceFlag, [] { >+#if ENABLE(TREE_DEBUGGING) > PAL::registerNotifyCallback("com.apple.WebKit.showRenderTree", printRenderTreeForLiveDocuments); > PAL::registerNotifyCallback("com.apple.WebKit.showLayerTree", printLayerTreeForLiveDocuments); > #if ENABLE(LAYOUT_FORMATTING_CONTEXT) > PAL::registerNotifyCallback("com.apple.WebKit.showLayoutTree", Layout::printLayoutTreeForLiveDocuments); > #endif >+#endif // ENABLE(TREE_DEBUGGING) >+ >+ PAL::registerNotifyCallback("com.apple.WebKit.showAllDocuments", [] { >+ unsigned numPages = 0; >+ Page::forEachPage([&numPages](Page&) { >+ ++numPages; >+ }); >+ >+ WTFLogAlways("%u live pages:", numPages); >+ >+ Page::forEachPage([](Page& page) { >+ const auto* mainFrameDocument = page.mainFrame().document(); >+ WTFLogAlways("Page %p with main document %p %s", &page, mainFrameDocument, mainFrameDocument ? mainFrameDocument->url().string().utf8().data() : ""); >+ }); >+ >+ WTFLogAlways("%u live documents:", Document::allDocuments().size()); >+ for (const auto* document : Document::allDocuments()) { >+ WTFLogAlways("Document %p %s", document, document->url().string().utf8().data()); >+ } >+ }); > }); >-#endif > } > > void Page::addSchedulePair(Ref<SchedulePair>&& pair)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
keith_miller
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185853
: 340930 |
341029
|
341043
|
341044