Bug 90059

Summary: Performance: Optimize Dromaeo/dom-query.html by caching NodeRareData on Document
Product: WebKit Reporter: Kentaro Hara <haraken>
Component: DOMAssignee: Kentaro Hara <haraken>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, morrita, rniwa, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
patch for landing none

Description Kentaro Hara 2012-06-27 03:58:41 PDT
document.getElementsByClassName(), document.getElementsByTagName() and document.getElementsByName() are considered to be frequently used in the real world. Dromaeo/dom-query.html is also testing the performance of the three methods.

We can optimize the performance by caching a pointer to NodeRareData on Document.
Comment 1 Kentaro Hara 2012-06-27 04:01:28 PDT
Created attachment 149721 [details]
Patch
Comment 2 Kentaro Hara 2012-06-27 19:43:02 PDT
Created attachment 149856 [details]
Patch
Comment 3 Ryosuke Niwa 2012-06-27 19:49:08 PDT
Comment on attachment 149856 [details]
Patch

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

This seems like a good optimization. Make sure we're getting the same benefit for ElementRareData as things like document.images, document.all, etc... are all hanging out off ElementRareData as well.

> Source/WebCore/dom/Document.h:437
> +    NodeRareData* rareData() const { return m_rareData; };
> +    void setRareData(NodeRareData*);

Not sure if it's such a good idea to overload Node's rareData().

> Source/WebCore/dom/Node.cpp:500
> +        NodeRareData* data = static_cast<Document*>(this)->rareData();

We should probably declare a Document* local variable.
Comment 4 Kentaro Hara 2012-06-27 19:51:50 PDT
Comment on attachment 149856 [details]
Patch

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

>> Source/WebCore/dom/Document.h:437
>> +    void setRareData(NodeRareData*);
> 
> Not sure if it's such a good idea to overload Node's rareData().

What is your suggestion? (I thought that in IRC you suggested to rename cachedRareData() to rareData().)

>> Source/WebCore/dom/Node.cpp:500
>> +        NodeRareData* data = static_cast<Document*>(this)->rareData();
> 
> We should probably declare a Document* local variable.

Will fix.
Comment 5 Kentaro Hara 2012-06-27 21:55:43 PDT
Created attachment 149865 [details]
patch for landing
Comment 6 WebKit Review Bot 2012-06-27 23:29:42 PDT
Comment on attachment 149865 [details]
patch for landing

Clearing flags on attachment: 149865

Committed r121412: <http://trac.webkit.org/changeset/121412>