Bug 23050 - Copying Fonts by value makes GraphicsContext::save() and restore() expensive
Summary: Copying Fonts by value makes GraphicsContext::save() and restore() expensive
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Nobody
URL: https://bugs.webkit.org/attachment.cg...
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-30 22:12 PST by Simon Fraser (smfr)
Modified: 2009-01-17 18:29 PST (History)
4 users (show)

See Also:


Attachments
Shark session (2.47 MB, application/octet-stream)
2009-01-01 19:08 PST, Simon Fraser (smfr)
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Fraser (smfr) 2008-12-30 22:12:19 PST
I have a Shark sample (generated from the testcase in bug 19312) that shows that GraphicsContext::save() and restore() are pretty expensive; in this test. they take 11.7% and 23% of the entire sample (of which 87% is in painting).

Focusing on GraphicsContext::restore(), GraphicsContext::operator= is 65%, including 58% from Font::operator=. Vector::removeLast is 19%, and restorePlatformState() is 14%. Of the Font::operator= cost, almost all is in the GlyphPageTreeNode hash table copy.

Inside GraphicsContext::save(), 62% is in the Font constructor, and 22% is savePlatformState.
Comment 1 Simon Fraser (smfr) 2009-01-01 19:07:21 PST
Testcase in the URL field.
Comment 2 Simon Fraser (smfr) 2009-01-01 19:08:45 PST
Created attachment 26358 [details]
Shark session
Comment 3 Simon Fraser (smfr) 2009-01-01 19:10:36 PST
My initial analysis was done on a debug build (stupid!). In a release build, things aren't nearly as bad. In the attached Shark profile of the testcase, GraphicsContext::restore() is 1.4%, and GraphicsContext::save() 0.6%.

However, Font::operator= is still 39% of the time spent in GraphicsContext::restore(), so I think there's still a win to be had here.
Comment 4 Simon Fraser (smfr) 2009-01-01 19:27:44 PST
Another good testcase: http://www.bel.fi/~alankila/plasma.html
Comment 5 Simon Fraser (smfr) 2009-01-17 18:29:05 PST
Obviated by http://trac.webkit.org/changeset/40007