Bug 90059 - Performance: Optimize Dromaeo/dom-query.html by caching NodeRareData on Document
Summary: Performance: Optimize Dromaeo/dom-query.html by caching NodeRareData on Document
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kentaro Hara
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-27 03:58 PDT by Kentaro Hara
Modified: 2012-06-27 23:32 PDT (History)
4 users (show)

See Also:


Attachments
Patch (5.12 KB, patch)
2012-06-27 04:01 PDT, Kentaro Hara
no flags Details | Formatted Diff | Diff
Patch (7.12 KB, patch)
2012-06-27 19:43 PDT, Kentaro Hara
no flags Details | Formatted Diff | Diff
patch for landing (7.23 KB, patch)
2012-06-27 21:55 PDT, Kentaro Hara
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>