Changeset 122920 in webkit


Ignore:
Timestamp:
Jul 17, 2012 10:58:49 PM (12 years ago)
Author:
loislo@chromium.org
Message:

Web Inspector: show loaders memory consumption on the memory chart.
https://bugs.webkit.org/show_bug.cgi?id=90686

Reviewed by Pavel Feldman.

Size of FrameLoader, DocumentLoader, ResourceLoader and their resources should be shown on the memory pie chart.

It is covered by existing WebInspector performance tests infrastructure.

  • WebCore.exp.in:
  • dom/MemoryInstrumentation.h:

(MemoryInstrumentation):
(WebCore::MemoryInstrumentation::addRawBuffer):
(WebCore::MemoryInstrumentation::addInstrumentedMemberImpl):
(WebCore):
(WebCore::MemoryClassInfo::addInstrumentedHashSet):
(WebCore::MemoryClassInfo::addRawBuffer):
(WebCore::MemoryInstrumentation::addInstrumentedHashSet):
(WebCore::MemoryInstrumentation::addVector):

  • inspector/InspectorMemoryAgent.cpp:

(WebCore):
(WebCore::domTreeInfo):

  • loader/DocumentLoader.cpp:

(WebCore::DocumentLoader::reportMemoryUsage):
(WebCore):

  • loader/DocumentLoader.h:

(WebCore):
(DocumentLoader):

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::reportMemoryUsage):
(WebCore):

  • loader/FrameLoader.h:

(WebCore):
(FrameLoader):

  • loader/ResourceLoader.cpp:

(WebCore::ResourceLoader::reportMemoryUsage):
(WebCore):

  • loader/ResourceLoader.h:

(WebCore):
(ResourceLoader):

  • page/Frame.cpp:

(WebCore::Frame::reportMemoryUsage):
(WebCore):

  • page/Frame.h:

(WebCore):
(Frame):

  • platform/SharedBuffer.cpp:

(WebCore::SharedBuffer::reportMemoryUsage):
(WebCore):

  • platform/SharedBuffer.h:

(WebCore):
(SharedBuffer):

Location:
trunk/Source/WebCore
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r122918 r122920  
     12012-07-17  Ilya Tikhonovsky  <loislo@chromium.org>
     2
     3        Web Inspector: show loaders memory consumption on the memory chart.
     4        https://bugs.webkit.org/show_bug.cgi?id=90686
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Size of FrameLoader, DocumentLoader, ResourceLoader and their resources should be shown on the memory pie chart.
     9
     10        It is covered by existing WebInspector performance tests infrastructure.
     11
     12        * WebCore.exp.in:
     13        * dom/MemoryInstrumentation.h:
     14        (MemoryInstrumentation):
     15        (WebCore::MemoryInstrumentation::addRawBuffer):
     16        (WebCore::MemoryInstrumentation::addInstrumentedMemberImpl):
     17        (WebCore):
     18        (WebCore::MemoryClassInfo::addInstrumentedHashSet):
     19        (WebCore::MemoryClassInfo::addRawBuffer):
     20        (WebCore::MemoryInstrumentation::addInstrumentedHashSet):
     21        (WebCore::MemoryInstrumentation::addVector):
     22        * inspector/InspectorMemoryAgent.cpp:
     23        (WebCore):
     24        (WebCore::domTreeInfo):
     25        * loader/DocumentLoader.cpp:
     26        (WebCore::DocumentLoader::reportMemoryUsage):
     27        (WebCore):
     28        * loader/DocumentLoader.h:
     29        (WebCore):
     30        (DocumentLoader):
     31        * loader/FrameLoader.cpp:
     32        (WebCore::FrameLoader::reportMemoryUsage):
     33        (WebCore):
     34        * loader/FrameLoader.h:
     35        (WebCore):
     36        (FrameLoader):
     37        * loader/ResourceLoader.cpp:
     38        (WebCore::ResourceLoader::reportMemoryUsage):
     39        (WebCore):
     40        * loader/ResourceLoader.h:
     41        (WebCore):
     42        (ResourceLoader):
     43        * page/Frame.cpp:
     44        (WebCore::Frame::reportMemoryUsage):
     45        (WebCore):
     46        * page/Frame.h:
     47        (WebCore):
     48        (Frame):
     49        * platform/SharedBuffer.cpp:
     50        (WebCore::SharedBuffer::reportMemoryUsage):
     51        (WebCore):
     52        * platform/SharedBuffer.h:
     53        (WebCore):
     54        (SharedBuffer):
     55
    1562012-07-17  Kent Tamura  <tkent@chromium.org>
    257
  • trunk/Source/WebCore/WebCore.exp.in

    r122806 r122920  
    251251__ZN7WebCore14DocumentLoaderC2ERKNS_15ResourceRequestERKNS_14SubstituteDataE
    252252__ZN7WebCore14DocumentLoaderD2Ev
     253__ZNK7WebCore14DocumentLoader17reportMemoryUsageEPNS_16MemoryObjectInfoE
    253254__ZN7WebCore14DocumentWriter11setEncodingERKN3WTF6StringEb
    254255__ZN7WebCore14FileIconLoader14notifyFinishedEN3WTF10PassRefPtrINS_4IconEEE
  • trunk/Source/WebCore/dom/MemoryInstrumentation.h

    r122735 r122920  
    3131#ifndef MemoryInstrumentation_h
    3232#define MemoryInstrumentation_h
     33#include <stdio.h>
    3334
    3435#include <wtf/Assertions.h>
     
    5152        CSS,
    5253        Binding,
     54        Loader,
    5355        LastTypeEntry
    5456    };
     
    6668    template <typename HashMapType> void addHashMap(const HashMapType&, ObjectType, bool contentOnly = false);
    6769    template <typename HashSetType> void addHashSet(const HashSetType&, ObjectType, bool contentOnly = false);
     70    template <typename HashSetType> void addInstrumentedHashSet(const HashSetType&, ObjectType, bool contentOnly = false);
    6871    template <typename ListHashSetType> void addListHashSet(const ListHashSetType&, ObjectType, bool contentOnly = false);
    6972    template <typename VectorType> void addVector(const VectorType&, ObjectType, bool contentOnly = false);
     73    void addRawBuffer(const void* const& buffer, ObjectType objectType, size_t size)
     74    {
     75        if (!buffer || visited(buffer))
     76            return;
     77        countObjectSize(objectType, size);
     78    }
    7079
    7180protected:
     
    8796    };
    8897
    89     template <typename T>
    90     void addInstrumentedMemberImpl(const T* const& object, OwningType owningType);
     98    template <typename T> void addInstrumentedMemberImpl(const T* const&, OwningType);
     99    template <typename T> void addInstrumentedMemberImpl(const OwnPtr<T>* const& object, MemoryInstrumentation::OwningType owningType) { addInstrumentedMemberImpl(object->get(), owningType); }
     100    template <typename T> void addInstrumentedMemberImpl(const RefPtr<T>* const& object, MemoryInstrumentation::OwningType owningType) { addInstrumentedMemberImpl(object->get(), owningType); }
    91101
    92102    template <typename T>
     
    165175template <> void MemoryInstrumentation::addMemberImpl<String>(const String* const&, MemoryInstrumentation::ObjectType, MemoryInstrumentation::OwningType);
    166176
     177
    167178template <typename T>
    168179void MemoryInstrumentation::addInstrumentedMemberImpl(const T* const& object, MemoryInstrumentation::OwningType owningType)
     
    176187        deferInstrumentedPointer(adoptPtr(new InstrumentedPointer<T>(object)));
    177188}
     189
    178190
    179191template <typename T>
     
    195207    template <typename HashMapType> void addHashMap(const HashMapType& map) { m_memoryInstrumentation->addHashMap(map, m_objectType, true); }
    196208    template <typename HashSetType> void addHashSet(const HashSetType& set) { m_memoryInstrumentation->addHashSet(set, m_objectType, true); }
     209    template <typename HashSetType> void addInstrumentedHashSet(const HashSetType& set) { m_memoryInstrumentation->addInstrumentedHashSet(set, m_objectType, true); }
    197210    template <typename ListHashSetType> void addListHashSet(const ListHashSetType& set) { m_memoryInstrumentation->addListHashSet(set, m_objectType, true); }
    198211    template <typename VectorType> void addVector(const VectorType& vector) { m_memoryInstrumentation->addVector(vector, m_objectType, true); }
     212    void addRawBuffer(const void* const& buffer, size_t size) { m_memoryInstrumentation->addRawBuffer(buffer, m_objectType, size); }
    199213
    200214    void addString(const String& string) { m_memoryInstrumentation->addString(string, m_objectType); }
     
    221235}
    222236
     237template<typename HashSetType>
     238void MemoryInstrumentation::addInstrumentedHashSet(const HashSetType& hashSet, ObjectType objectType, bool contentOnly)
     239{
     240    if (visited(&hashSet))
     241        return;
     242    countObjectSize(objectType, calculateContainerSize(hashSet, contentOnly));
     243    for (typename HashSetType::const_iterator i = hashSet.begin(); i != hashSet.end(); ++i)
     244        addInstrumentedMember(*i);
     245}
     246
    223247template<typename ListHashSetType>
    224248void MemoryInstrumentation::addListHashSet(const ListHashSetType& hashSet, ObjectType objectType, bool contentOnly)
     
    233257void MemoryInstrumentation::addVector(const VectorType& vector, ObjectType objectType, bool contentOnly)
    234258{
    235     if (visited(vector.data()))
     259    if (!vector.data() || visited(vector.data()))
    236260        return;
    237261    countObjectSize(objectType, calculateContainerSize(vector, contentOnly));
     
    246270}
    247271
     272
    248273} // namespace WebCore
    249274
  • trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp

    r122717 r122920  
    546546    }
    547547
     548    void visitFrame(Frame* frame)
     549    {
     550        m_domMemoryUsage.addInstrumentedMember(frame);
     551        m_domMemoryUsage.processDeferredInstrumentedPointers();
     552    }
     553
    548554    void visitBindings()
    549555    {
     
    571577    // Make sure all documents reachable from the main frame are accounted.
    572578    for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
    573         if (Document* doc = frame->document())
     579        if (Document* doc = frame->document()) {
    574580            domTreesIterator.visitNode(doc);
     581            domTreesIterator.visitFrame(frame);
     582        }
    575583    }
    576584
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r121912 r122920  
    4848#include "Logging.h"
    4949#include "MainResourceLoader.h"
     50#include "MemoryInstrumentation.h"
    5051#include "Page.h"
    5152#include "PlatformString.h"
     
    355356}
    356357
     358void DocumentLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     359{
     360    MemoryClassInfo<DocumentLoader> info(memoryObjectInfo, this, MemoryInstrumentation::Loader);
     361    info.addInstrumentedMember(m_frame);
     362    info.addInstrumentedMember(m_mainResourceLoader);
     363    info.addInstrumentedHashSet(m_subresourceLoaders);
     364    info.addInstrumentedHashSet(m_multipartSubresourceLoaders);
     365    info.addInstrumentedHashSet(m_plugInStreamLoaders);
     366    info.addString(m_pageTitle.string());
     367    info.addString(m_overrideEncoding);
     368    info.addVector(m_responses);
     369    info.addHashMap(m_pendingSubstituteResources);
     370    info.addHashSet(m_resourcesClientKnowsAbout);
     371    info.addVector(m_resourcesLoadedFromMemoryCacheForClientNotification);
     372    info.addString(m_clientRedirectSourceForHistory);
     373    info.addInstrumentedMember(m_mainResourceData);
     374}
     375
    357376bool DocumentLoader::doesProgressiveLoad(const String& MIMEType) const
    358377{
  • trunk/Source/WebCore/loader/DocumentLoader.h

    r115654 r122920  
    5656    class FrameLoader;
    5757    class MainResourceLoader;
     58    class MemoryObjectInfo;
    5859    class Page;
    5960    class ResourceLoader;
     
    243244        ApplicationCacheHost* applicationCacheHost() const { return m_applicationCacheHost.get(); }
    244245
     246        virtual void reportMemoryUsage(MemoryObjectInfo*) const;
     247
    245248    protected:
    246249        DocumentLoader(const ResourceRequest&, const SubstituteData&);
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r121434 r122920  
    7878#include "MIMETypeRegistry.h"
    7979#include "MainResourceLoader.h"
     80#include "MemoryInstrumentation.h"
    8081#include "Page.h"
    8182#include "PageCache.h"
     
    32213222}
    32223223
     3224void FrameLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     3225{
     3226    MemoryClassInfo<FrameLoader> info(memoryObjectInfo, this, MemoryInstrumentation::Loader);
     3227    info.addInstrumentedMember(m_documentLoader.get());
     3228    info.addInstrumentedMember(m_provisionalDocumentLoader.get());
     3229    info.addInstrumentedMember(m_policyDocumentLoader.get());
     3230    info.addString(m_outgoingReferrer);
     3231    info.addInstrumentedHashSet(m_openedFrames);
     3232}
     3233
    32233234bool FrameLoaderClient::hasHTMLView() const
    32243235{
  • trunk/Source/WebCore/loader/FrameLoader.h

    r121434 r122920  
    6262class FrameLoaderClient;
    6363class FrameNetworkingContext;
     64class MemoryObjectInfo;
    6465class NavigationAction;
    6566class NetworkingContext;
     
    284285    NetworkingContext* networkingContext() const;
    285286
     287    void reportMemoryUsage(MemoryObjectInfo*) const;
     288
    286289private:
    287290    bool allChildrenAreComplete() const; // immediate children, not all descendants
  • trunk/Source/WebCore/loader/ResourceLoader.cpp

    r121929 r122920  
    529529#endif
    530530
    531 }
     531void ResourceLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     532{
     533    MemoryClassInfo<ResourceLoader> info(memoryObjectInfo, this, MemoryInstrumentation::Loader);
     534    info.addMember(m_handle.get());
     535    info.addInstrumentedMember(m_frame);
     536    info.addInstrumentedMember(m_documentLoader);
     537    info.addMember(m_request);
     538    info.addMember(m_originalRequest);
     539    info.addInstrumentedMember(m_resourceData);
     540    info.addMember(m_deferredRequest);
     541    info.addMember(m_options);
     542}
     543
     544}
  • trunk/Source/WebCore/loader/ResourceLoader.h

    r115223 r122920  
    4545    class FrameLoader;
    4646    class KURL;
     47    class MemoryObjectInfo;
    4748    class ResourceHandle;
    4849    class SharedBuffer;
     
    145146        void setShouldBufferData(DataBufferingPolicy);
    146147
     148        virtual void reportMemoryUsage(MemoryObjectInfo*) const;
     149
    147150    protected:
    148151        ResourceLoader(Frame*, ResourceLoaderOptions);
  • trunk/Source/WebCore/page/Frame.cpp

    r121388 r122920  
    686686#endif
    687687
     688void Frame::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     689{
     690    MemoryClassInfo<Frame> info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
     691    info.addInstrumentedMember(m_doc.get());
     692    info.addInstrumentedMember(m_loader);
     693}
     694
    688695DOMWindow* Frame::domWindow() const
    689696{
  • trunk/Source/WebCore/page/Frame.h

    r120005 r122920  
    6767    class FrameView;
    6868    class HTMLTableCellElement;
     69    class MemoryObjectInfo;
    6970    class RegularExpression;
    7071    class RenderPart;
     
    118119#endif
    119120
     121        void reportMemoryUsage(MemoryObjectInfo*) const;
     122
    120123    // ======== All public functions below this point are candidates to move out of Frame into another class. ========
    121124
  • trunk/Source/WebCore/platform/SharedBuffer.cpp

    r112642 r122920  
    2828#include "SharedBuffer.h"
    2929
     30#include "MemoryInstrumentation.h"
    3031#include "PurgeableBuffer.h"
    3132#include <wtf/PassOwnPtr.h>
     
    246247}
    247248
     249void SharedBuffer::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     250{
     251    MemoryClassInfo<SharedBuffer> info(memoryObjectInfo, this, MemoryInstrumentation::Other);
     252    info.addVector(m_buffer);
     253    info.addVector(m_segments);
     254    for (unsigned i = 0; i < m_segments.size(); ++i)
     255        info.addRawBuffer(m_segments[i], segmentSize);
     256    info.addMember(m_purgeableBuffer.get());
     257}
     258
    248259unsigned SharedBuffer::getSomeData(const char*& someData, unsigned position) const
    249260{
  • trunk/Source/WebCore/platform/SharedBuffer.h

    r112642 r122920  
    4444namespace WebCore {
    4545   
     46class MemoryObjectInfo;
    4647class PurgeableBuffer;
    4748
     
    115116    unsigned getSomeData(const char*& data, unsigned position = 0) const;
    116117
     118    void reportMemoryUsage(MemoryObjectInfo*) const;
     119
    117120private:
    118121    SharedBuffer();
Note: See TracChangeset for help on using the changeset viewer.