Bug 115902 - Caching of generated images in CSS should be smarter.
Summary: Caching of generated images in CSS should be smarter.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Andreas Kling
URL:
Keywords: InRadar, Performance
Depends on:
Blocks:
 
Reported: 2013-05-10 05:52 PDT by Andreas Kling
Modified: 2013-05-10 10:34 PDT (History)
12 users (show)

See Also:


Attachments
Possibly a patch (19.71 KB, patch)
2013-05-10 06:39 PDT, Andreas Kling
eflews.bot: commit-queue-
Details | Formatted Diff | Diff
Probably a patch (16.99 KB, patch)
2013-05-10 08:58 PDT, Andreas Kling
koivisto: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Kling 2013-05-10 05:52:33 PDT
<rdar://problem/13542727>
Comment 1 Andreas Kling 2013-05-10 06:39:43 PDT
Created attachment 201341 [details]
Possibly a patch
Comment 2 EFL EWS Bot 2013-05-10 06:43:37 PDT
Comment on attachment 201341 [details]
Possibly a patch

Attachment 201341 [details] did not pass efl-wk2-ews (efl-wk2):
Output: http://webkit-queues.appspot.com/results/321065
Comment 3 EFL EWS Bot 2013-05-10 06:44:39 PDT
Comment on attachment 201341 [details]
Possibly a patch

Attachment 201341 [details] did not pass efl-ews (efl):
Output: http://webkit-queues.appspot.com/results/265092
Comment 4 Early Warning System Bot 2013-05-10 06:45:01 PDT
Comment on attachment 201341 [details]
Possibly a patch

Attachment 201341 [details] did not pass qt-ews (qt):
Output: http://webkit-queues.appspot.com/results/456021
Comment 5 Early Warning System Bot 2013-05-10 06:45:30 PDT
Comment on attachment 201341 [details]
Possibly a patch

Attachment 201341 [details] did not pass qt-wk2-ews (qt-wk2):
Output: http://webkit-queues.appspot.com/results/427091
Comment 6 Antti Koivisto 2013-05-10 06:56:04 PDT
Comment on attachment 201341 [details]
Possibly a patch

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

> Source/WebCore/css/CSSImageGeneratorValue.cpp:64
> +    auto it = m_clients.find(renderer);

Hi Anders!

> Source/WebCore/css/CSSImageGeneratorValue.cpp:82
> +    GeneratedImageCache* cache = m_clients.get(renderer);
> +    if (!cache)
> +        return 0;
> +
> +    CachedGeneratedImage* cachedGeneratedImage = cache->images.get(size);
> +    if (!cachedGeneratedImage)
> +        return 0;

If I understand correctly the cache entries can no longer be shared between multiple (same sized) renderers.Could this be a problem? Is there are solution that would keep this property?
Comment 7 kov's GTK+ EWS bot 2013-05-10 08:57:43 PDT
Comment on attachment 201341 [details]
Possibly a patch

Attachment 201341 [details] did not pass gtk-ews (gtk):
Output: http://webkit-queues.appspot.com/results/276232
Comment 8 Andreas Kling 2013-05-10 08:58:57 PDT
Created attachment 201354 [details]
Probably a patch
Comment 9 Andreas Kling 2013-05-10 09:45:19 PDT
(In reply to comment #6)
> (From update of attachment 201341 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=201341&action=review
> 
> > Source/WebCore/css/CSSImageGeneratorValue.cpp:82
> > +    GeneratedImageCache* cache = m_clients.get(renderer);
> > +    if (!cache)
> > +        return 0;
> > +
> > +    CachedGeneratedImage* cachedGeneratedImage = cache->images.get(size);
> > +    if (!cachedGeneratedImage)
> > +        return 0;
> 
> If I understand correctly the cache entries can no longer be shared between multiple (same sized) renderers.Could this be a problem? Is there are solution that would keep this property?

Having per-RenderObject caches was never a requirement in the first place, I simplified things in the new patch by making the cache a simple IntSize=>GeneratorGeneratedImage map.
Comment 10 Antti Koivisto 2013-05-10 10:15:21 PDT
Comment on attachment 201354 [details]
Probably a patch

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

r=me, looks so much better.

> Source/WebCore/css/CSSImageGeneratorValue.cpp:38
> +static const double timeToKeepCachedGeneratedImagesInSeconds = 3;

Is there science behind this number?

> Source/WebCore/css/CSSImageGeneratorValue.cpp:100
> +void CSSImageGeneratorValue::CachedGeneratedImage::evictionTimerFired(DeferrableOneShotTimer<CachedGeneratedImage>*)
>  {
> -    m_images.add(size, image);
> +    m_owner.evictCachedGeneratedImage(m_size);

This is essentially "delete this" right? It would be good to add a comment pointing out that the object is dead afterwards.
Comment 11 Andreas Kling 2013-05-10 10:34:07 PDT
Committed r149886: <http://trac.webkit.org/changeset/149886>