Bug 76460 - Perf improvement via caching Element::styleForRenderer()
Summary: Perf improvement via caching Element::styleForRenderer()
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
Depends on:
Reported: 2012-01-17 08:36 PST by Peter Kotwicz
Modified: 2012-01-17 13:00 PST (History)
3 users (show)

See Also:

test case (192 bytes, text/html)
2012-01-17 11:07 PST, Peter Kotwicz
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Kotwicz 2012-01-17 08:36:18 PST
styleForRenderer() is a pretty heavy function. In some cases we compute it twice in "Element::recalcStyle" and "NodeRendererFactory::createRendererIfNeeded". NdeRendererFactory is called via Element::attach

I have attached a file where this improvement does improve the performance of Element::recalc. For the attached file, the improvement is on the order of 3-4us. On measurements on a reasonably complex page, doing the caching results in a .1 - .5ms improvement in processing Element::recalc
Comment 1 Antti Koivisto 2012-01-17 10:54:45 PST
I'm planning to get rid of NodeRenderingFactory class which just confuses things. Computing the style twice in case of attach() triggered from recalcStyle is indeed a problem that should be fixed.
Comment 2 Peter Kotwicz 2012-01-17 11:07:20 PST
Created attachment 122784 [details]
test case
Comment 3 Peter Kotwicz 2012-01-17 13:00:51 PST
I did a bit more measurements. For a reasonable web site, for a page where the recalc is done twice, this produces a performance improvement in Element::recalcStyle of about 1%