Changeset 179494 in webkit


Ignore:
Timestamp:
Feb 2, 2015 1:25:24 PM (9 years ago)
Author:
akling@apple.com
Message:

[Cocoa] Make decoded image data purgeable ASAP.
<https://webkit.org/b/140298>
<rdar://problem/19623377>

Reviewed by Antti Koivisto.

Re-landing this patch since it turned out to not be the cause of
the memory regression we saw around that revision.

Mark decoded images as "transient" which makes CoreGraphics mark
the backing stores as purgeable shortly after they're used.

The decoded representation will remain in CoreGraphics's caches
indefinitely unless the kernel gets starved and needs the pages.

Most resources will now reach a state where the encoded data is
mmap'ed from disk cache (once the entire resource is downloaded)
and the decoded data is purgeable.

This also has the side effect of making the MemoryCache more
palatial since the decoded data cost can be deducted for images,
allowing us to cache more resources.

Note that the worst case for this new behavior would be something
like hovering below 100% memory utilization and constantly having
to drop and re-decode images. While churny, it still beats
crashing the process, plus there's tiling to remove many of the
reasons we'd need the decoded data.

  • platform/graphics/cg/ImageSourceCG.cpp:

(WebCore::ImageSource::createFrameAtIndex):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r179493 r179494  
     12015-02-02  Andreas Kling  <akling@apple.com>
     2
     3        [Cocoa] Make decoded image data purgeable ASAP.
     4        <https://webkit.org/b/140298>
     5        <rdar://problem/19623377>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        Re-landing this patch since it turned out to not be the cause of
     10        the memory regression we saw around that revision.
     11
     12        Mark decoded images as "transient" which makes CoreGraphics mark
     13        the backing stores as purgeable shortly after they're used.
     14
     15        The decoded representation will remain in CoreGraphics's caches
     16        indefinitely unless the kernel gets starved and needs the pages.
     17
     18        Most resources will now reach a state where the encoded data is
     19        mmap'ed from disk cache (once the entire resource is downloaded)
     20        and the decoded data is purgeable.
     21
     22        This also has the side effect of making the MemoryCache more
     23        palatial since the decoded data cost can be deducted for images,
     24        allowing us to cache more resources.
     25
     26        Note that the worst case for this new behavior would be something
     27        like hovering below 100% memory utilization and constantly having
     28        to drop and re-decode images. While churny, it still beats
     29        crashing the process, plus there's tiling to remove many of the
     30        reasons we'd need the decoded data.
     31
     32        * platform/graphics/cg/ImageSourceCG.cpp:
     33        (WebCore::ImageSource::createFrameAtIndex):
     34
    1352015-02-02  Joseph Pecoraro  <pecoraro@apple.com>
    236
  • trunk/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp

    r179458 r179494  
    348348    RetainPtr<CGImageRef> image = adoptCF(CGImageSourceCreateImageAtIndex(m_decoder, index, imageSourceOptions(subsamplingLevel).get()));
    349349
    350 #if PLATFORM(IOS)
    351     // <rdar://problem/7371198> - CoreGraphics changed the default caching behaviour in iOS 4.0 to kCGImageCachingTransient
    352     // which caused a performance regression for us since the images had to be resampled/recreated every time we called
    353     // CGContextDrawImage. We now tell CG to cache the drawn images. See also <rdar://problem/14366755> -
    354     // CoreGraphics needs to un-deprecate kCGImageCachingTemporary since it's still not the default.
    355 #if COMPILER(CLANG)
    356 #pragma clang diagnostic push
    357 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
    358 #endif
    359     CGImageSetCachingFlags(image.get(), kCGImageCachingTemporary);
    360 #if COMPILER(CLANG)
    361 #pragma clang diagnostic pop
    362 #endif
    363 #endif // PLATFORM(IOS)
     350    CGImageSetCachingFlags(image.get(), kCGImageCachingTransient);
    364351
    365352    CFStringRef imageUTI = CGImageSourceGetType(m_decoder);
     
    368355    if (!imageUTI)
    369356        return image.leakRef();
    370 
    371 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
    372     if (CFEqual(imageUTI, kUTTypeGIF)) {
    373         CGImageSetCachingFlags(image.get(), kCGImageCachingTransient);
    374         return image.leakRef();
    375     }
    376 #endif
    377357
    378358    if (!CFEqual(imageUTI, xbmUTI))
Note: See TracChangeset for help on using the changeset viewer.