Bug 76460

Summary: Perf improvement via caching Element::styleForRenderer()
Product: WebKit Reporter: Peter Kotwicz <pkotwicz>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: UNCONFIRMED ---    
Severity: Normal CC: jamesr, koivisto, simon.fraser
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
test case none

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%