Bug 103232 - Web Inspector: NMI introduce heap graph recording API
Summary: Web Inspector: NMI introduce heap graph recording API
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Yury Semikhatsky
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-26 02:37 PST by Ilya Tikhonovsky
Modified: 2012-12-04 14:03 PST (History)
11 users (show)

See Also:


Attachments
Patch (25.31 KB, patch)
2012-11-26 04:04 PST, Ilya Tikhonovsky
buildbot: commit-queue-
Details | Formatted Diff | Diff
WIP (8.92 KB, patch)
2012-12-03 10:29 PST, Yury Semikhatsky
buildbot: commit-queue-
Details | Formatted Diff | Diff
WIP (10.68 KB, patch)
2012-12-03 16:43 PST, Yury Semikhatsky
no flags Details | Formatted Diff | Diff
Patch (14.04 KB, patch)
2012-12-03 17:17 PST, Yury Semikhatsky
no flags Details | Formatted Diff | Diff
Patch (15.99 KB, patch)
2012-12-03 18:20 PST, Yury Semikhatsky
vsevik: review+
buildbot: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ilya Tikhonovsky 2012-11-26 02:37:03 PST
Currently we have a plain memory usage statistic based on types.
Unfortunately this 'type' to 'size' information couldn't help to web developers.
They need an information about instances and owners.

As example even about:blank page has ~5MB of Page.Image.
This fact confuses the developers. Actually this image is a part of Inspector backend
because it creates and uses a canvas in InspectorOverlay.

After long offline discussion we came to the conclusion that we need to record a heap graph.

We need to have 2 methods for that. reportNode and reportEdge.
But due to c++ multiple inheritance we need a helper method reportAssociation which associates a pointer to parent class with pointer to descendant class.

patch to follow.
Comment 1 Ilya Tikhonovsky 2012-11-26 04:04:46 PST
Created attachment 175966 [details]
Patch
Comment 2 Yury Semikhatsky 2012-11-26 04:27:34 PST
Comment on attachment 175966 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=175966&action=review

Let's split the patch into smaller parts.

> Source/WTF/ChangeLog:8
> +        reportNode, reportEdge and reportAssociation were added to the client API

There is no reportAssociation.

> Source/WTF/ChangeLog:10
> +        InstrumentedPointerBase and InstrumentedPointer<T> wer renamed to PointerBase

wer-> were

> Source/WTF/ChangeLog:13
> +        Pointer<T>::m_pointer was upstreamed to PointerBase because it needs to PointerBase::process method.

it needs to PointerBase::process method ->  PointerBase::process uses it
Comment 3 Build Bot 2012-11-26 04:31:48 PST
Comment on attachment 175966 [details]
Patch

Attachment 175966 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/14981638
Comment 4 Build Bot 2012-11-26 04:51:27 PST
Comment on attachment 175966 [details]
Patch

Attachment 175966 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/14992601
Comment 5 Yury Semikhatsky 2012-12-03 10:29:23 PST
Created attachment 177282 [details]
WIP
Comment 6 Ilya Tikhonovsky 2012-12-03 10:38:43 PST
Comment on attachment 177282 [details]
WIP

View in context: https://bugs.webkit.org/attachment.cgi?id=177282&action=review

> Source/WTF/wtf/MemoryInstrumentation.h:45
> +class String;

unnecessary line

> Source/WTF/wtf/MemoryInstrumentation.h:169
> +    template<typename T> void addObjectImpl(const T* const&, MemoryObjectInfo*, MemoryOwningType, const char* name);

I think it should be called edgeName.
Comment 7 Build Bot 2012-12-03 11:04:49 PST
Comment on attachment 177282 [details]
WIP

Attachment 177282 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/15120419
Comment 8 Build Bot 2012-12-03 11:07:00 PST
Comment on attachment 177282 [details]
WIP

Attachment 177282 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/15132023
Comment 9 Ilya Tikhonovsky 2012-12-03 12:14:41 PST
Comment on attachment 177282 [details]
WIP

View in context: https://bugs.webkit.org/attachment.cgi?id=177282&action=review

> Source/WTF/wtf/MemoryInstrumentation.h:63
> +    virtual void reportHeapObject(const MemoryObjectInfo&) { }

I prefer reportNode method name.

> Source/WTF/wtf/MemoryInstrumentation.h:64
> +    virtual void reportEdge(const void* source, const void* target, const char* name) { }

looks like we need a method for leafs: reportNodeLeaf
which will be used for reporting private buffers with no pointer. 
it is required because we have no pointer and have to report the size together with edge.
Comment 10 Yury Semikhatsky 2012-12-03 16:43:08 PST
Created attachment 177371 [details]
WIP
Comment 11 Yury Semikhatsky 2012-12-03 16:44:47 PST
(In reply to comment #9)
> (From update of attachment 177282 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=177282&action=review
> 
> > Source/WTF/wtf/MemoryInstrumentation.h:63
> > +    virtual void reportHeapObject(const MemoryObjectInfo&) { }
> 
> I prefer reportNode method name.
> 
Done.

> > Source/WTF/wtf/MemoryInstrumentation.h:64
> > +    virtual void reportEdge(const void* source, const void* target, const char* name) { }
> 
> looks like we need a method for leafs: reportNodeLeaf
> which will be used for reporting private buffers with no pointer. 
> it is required because we have no pointer and have to report the size together with edge.
Added reportLeaf for that.
Comment 12 Ilya Tikhonovsky 2012-12-03 16:49:37 PST
Comment on attachment 177371 [details]
WIP

View in context: https://bugs.webkit.org/attachment.cgi?id=177371&action=review

> Source/WTF/wtf/MemoryInstrumentation.cpp:115
> +    m_memoryInstrumentation->addRawBuffer(m_memoryObjectInfo->reportedPointer(), buffer, m_objectType, size);

I think we need a node name argument here with default value 0

> Source/WTF/wtf/MemoryInstrumentation.cpp:125
> +    m_memoryInstrumentation->reportLinkToBuffer(m_memoryObjectInfo->reportedPointer(), 0, ownerObjectType, size);

ditto

> Source/WTF/wtf/MemoryInstrumentation.h:45
> +class String;

unnecessary forward declaration

> Source/WTF/wtf/MemoryInstrumentation.h:146
> +    template<typename T> void addObject(const T& t, MemoryObjectInfo* ownerObjectInfo, const char* name) { OwningTraits<T>::addObject(this, t, ownerObjectInfo, name); }

name -> edgeName
Comment 13 Yury Semikhatsky 2012-12-03 17:17:58 PST
Created attachment 177380 [details]
Patch
Comment 14 Yury Semikhatsky 2012-12-03 17:34:51 PST
(In reply to comment #12)
> (From update of attachment 177371 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=177371&action=review
> 
> > Source/WTF/wtf/MemoryInstrumentation.cpp:115
> > +    m_memoryInstrumentation->addRawBuffer(m_memoryObjectInfo->reportedPointer(), buffer, m_objectType, size);
> 
> I think we need a node name argument here with default value 0
> 
Done.

> > Source/WTF/wtf/MemoryInstrumentation.cpp:125
> > +    m_memoryInstrumentation->reportLinkToBuffer(m_memoryObjectInfo->reportedPointer(), 0, ownerObjectType, size);
> 
> ditto
> 
Done.

> > Source/WTF/wtf/MemoryInstrumentation.h:45
> > +class String;
> 
> unnecessary forward declaration
> 
Done.

> > Source/WTF/wtf/MemoryInstrumentation.h:146
> > +    template<typename T> void addObject(const T& t, MemoryObjectInfo* ownerObjectInfo, const char* name) { OwningTraits<T>::addObject(this, t, ownerObjectInfo, name); }
> 
> name -> edgeName
Done.
Comment 15 Ilya Tikhonovsky 2012-12-03 17:54:10 PST
Comment on attachment 177380 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=177380&action=review

> Source/WTF/wtf/MemoryInstrumentation.cpp:71
> +    memoryObjectInfo.reportObjectInfo(buffer, ownerObjectType, size);

What about assigning nodeName?
Comment 16 Build Bot 2012-12-03 17:57:39 PST
Comment on attachment 177380 [details]
Patch

Attachment 177380 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/15135001
Comment 17 Ilya Tikhonovsky 2012-12-03 18:13:02 PST
Comment on attachment 177380 [details]
Patch

otherwise looks good
Comment 18 Yury Semikhatsky 2012-12-03 18:20:02 PST
Created attachment 177388 [details]
Patch
Comment 19 Build Bot 2012-12-03 20:17:42 PST
Comment on attachment 177388 [details]
Patch

Attachment 177388 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/15098851
Comment 20 Yury Semikhatsky 2012-12-04 14:03:15 PST
Committed r136563: <http://trac.webkit.org/changeset/136563>