Bug 80707 - Presentation attribute cache
Summary: Presentation attribute cache
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-09 09:58 PST by Antti Koivisto
Modified: 2012-03-09 12:16 PST (History)
4 users (show)

See Also:


Attachments
patch (7.57 KB, patch)
2012-03-09 10:20 PST, Antti Koivisto
webkit-ews: commit-queue-
Details | Formatted Diff | Diff
try to silence the gcc warning, implement some comments (7.60 KB, patch)
2012-03-09 10:58 PST, Antti Koivisto
kling: review+
webkit.review.bot: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Koivisto 2012-03-09 09:58:50 PST
It is common for the same presentation attribute values repeat. We should introduce a cache that uses presentation attribute names and values as key. This will help to avoid repeated parsing of the same attribute values, reduce memory consumption and speed up the style resolve .
Comment 1 Antti Koivisto 2012-03-09 10:20:25 PST
Created attachment 131054 [details]
patch
Comment 2 Early Warning System Bot 2012-03-09 10:30:04 PST
Comment on attachment 131054 [details]
patch

Attachment 131054 [details] did not pass qt-wk2-ews (qt):
Output: http://queues.webkit.org/results/11898650
Comment 3 Early Warning System Bot 2012-03-09 10:34:31 PST
Comment on attachment 131054 [details]
patch

Attachment 131054 [details] did not pass qt-ews (qt):
Output: http://queues.webkit.org/results/11906670
Comment 4 WebKit Review Bot 2012-03-09 10:34:41 PST
Comment on attachment 131054 [details]
patch

Attachment 131054 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/11904652
Comment 5 Andreas Kling 2012-03-09 10:43:34 PST
Comment on attachment 131054 [details]
patch

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

> Source/WebCore/dom/StyledElement.cpp:73
> +    static PresentationAttributeCache* cache = new PresentationAttributeCache();
> +    return *cache;

Needs more common WebKit patterns:
DEFINE_STATIC_LOCAL(PresentationAttributeCache, cache, ());
return cache;

> Source/WebCore/dom/StyledElement.cpp:204
> +        if (!attribute->namespaceURI().isNull())
> +            return;

Perhaps this could be an assertion instead?

> Source/WebCore/dom/StyledElement.cpp:236
> +    PresentationAttributeCache::iterator cacheIterator;
> +    if (cacheHash) {
> +        cacheIterator = presentationAttributeCache().add(cacheHash, nullptr).first;

We could grab the PresentationAttributeCacheEntry* instead of holding on to a PresentationAttributeCache::iterator here to make the following code a little prettier.
Comment 6 Antti Koivisto 2012-03-09 10:58:50 PST
Created attachment 131063 [details]
try to silence the gcc warning, implement some comments
Comment 7 Antti Koivisto 2012-03-09 11:01:22 PST
(In reply to comment #5)
> We could grab the PresentationAttributeCacheEntry* instead of holding on to a PresentationAttributeCache::iterator here to make the following code a little prettier.

I need the iterator to avoid the second hash lookup in case of insertion.
Comment 8 Andreas Kling 2012-03-09 11:27:50 PST
Comment on attachment 131063 [details]
try to silence the gcc warning, implement some comments

r=me.

I wonder if we can make this cache case-insensitive. That should provide a solid increase in sharing on Y2K content.
Comment 9 WebKit Review Bot 2012-03-09 11:57:38 PST
Comment on attachment 131063 [details]
try to silence the gcc warning, implement some comments

Attachment 131063 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/11894738

New failing tests:
fast/forms/input-type-change.html
Comment 10 Antti Koivisto 2012-03-09 12:16:32 PST
http://trac.webkit.org/changeset/110316 (with a fix for the failing test)