Bug 117637 - Improve the number of style resolutions for NodeRenderingContext
Summary: Improve the number of style resolutions for NodeRenderingContext
Status: RESOLVED DUPLICATE of bug 118300
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mihai Maerean
URL:
Keywords:
Depends on:
Blocks: 74144
  Show dependency treegraph
 
Reported: 2013-06-14 05:43 PDT by Mihai Maerean
Modified: 2013-07-02 23:24 PDT (History)
5 users (show)

See Also:


Attachments
patch (3.87 KB, patch)
2013-06-17 05:51 PDT, Mihai Maerean
simon.fraser: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mihai Maerean 2013-06-14 05:43:21 PDT
Answer Simon Fraser's concerns raised on https://bugs.webkit.org/show_bug.cgi?id=74144 that there could be less calls to styleForRenderer() in NodeRenderingContext.
Comment 1 Mihai Maerean 2013-06-17 05:51:00 PDT
Created attachment 204813 [details]
patch

This patch reduces the number of style resolutions (an expensive operation) by checking for
moveToFlowThreadIfNeeded in 2 steps:
* 1st step: we determine if the node is the child of a region.
* 2nd step: after calling shouldCreateRenderer, we call moveToFlowThreadIfNeeded for all other nodes and, by
that time, the style has already been computed.

The number of style resolutions are as follows:
WHEN OPENING                            STYLE RESOLUTIONS WITH THE _OLD_ CODE   STYLE RESOLUTIONS WITH THE _PATCH_
http://www.whitehouse.gov/              4027                                    3257
http://en.wikipedia.org/wiki/Main_Page  7513                                    5638

The results of running PerformanceTests/Parser/ are as follows:
TEST                            UNIT    NEW CODE    DELTA           OLD CODE
/Parser/textarea-parsing:Runs   runs/s  77.32       5.72% BETTER    73.14
/Parser/tiny-innerHTML:Runs     runs/s  3.65        4.81% BETTER    3.48
/Parser/html-parser:Time        ms      2423.15     0.49% BETTER    2435.15
/Parser/css-parser-yui:Runs     runs/s  280.09      0.44% BETTER    278.87
/Parser/xml-parser:Runs         runs/s  6.08        4.85% WORSE     6.39
/Parser/innerHTML-setter:Runs   runs/s  185.71      4.61% WORSE     194.69
Comment 2 Simon Fraser (smfr) 2013-06-17 08:51:35 PDT
Comment on attachment 204813 [details]
patch

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

I find it very hard to follow this code, because both Element and NodeRenderContext have moveToFlowThread* functions. I think some renaming first would improve understanding of the code.

> Source/WebCore/dom/NodeRenderingContext.cpp:250
> +    bool haveTestedForMoveToFlowThread = false;
> +    for (const Element* parentElement = m_node->parentElement(); parentElement; parentElement = parentElement->parentElement()) {

You're adding a parent-chain walk here, which I assume will kick in for every renderer creation, which is bad too.
Comment 3 Radu Stavila 2013-07-02 13:43:28 PDT
Considering https://bugs.webkit.org/show_bug.cgi?id=118300, is this issue still valid?
Comment 4 Mihai Maerean 2013-07-02 23:24:39 PDT

*** This bug has been marked as a duplicate of bug 118300 ***