haikuwebkit/PerformanceTests/Canvas/reuse.html

32 lines
682 B
HTML
Raw Permalink Normal View History

Allow ImageBuffer to re-use IOSurfaces https://bugs.webkit.org/show_bug.cgi?id=125477 Source/WebCore: Reviewed by Geoff Garen. Modifications reviewed by Tim Horton. This patch is taken from r160945, but the modifications to ImageBufferCG.cpp have been reverted. This test adds a static class, ImageBufferBackingStoreCache, that vends IOSurfaces. It remembers IOSurfaces that have been returned to it until a configurable timeout. The storage used by this class is in the form of a HashMap from a bucketed size to the IOSurface. There are many other data structures that could be used, but this implementation gives a 80% hit rate on normal browsing of some example sites with Canvas and text-decoration-skip: ink. Because the buckets are fairly small (rounding the width and height up to multiples of 8), traversing the bucket contents takes on average 2 steps. Test: fast/canvas/canvas-backing-store-reuse.html * WebCore.xcodeproj/project.pbxproj: Added new caching class * platform/graphics/cg/ImageBufferBackingStoreCache.cpp: Added. (WebCore::createIOSurface): Copied from ImageBufferCG.cpp (WebCore::ImageBufferBackingStoreCache::timerFired): Forget the cache contents (WebCore::ImageBufferBackingStoreCache::schedulePurgeTimer): (WebCore::ImageBufferBackingStoreCache::get): Static getter (WebCore::ImageBufferBackingStoreCache::ImageBufferBackingStoreCache): (WebCore::ImageBufferBackingStoreCache::insertIntoCache): Memory-management creation function (WebCore::ImageBufferBackingStoreCache::takeFromCache): Memory-management deletion function (WebCore::ImageBufferBackingStoreCache::isAcceptableSurface): Does this cached IOSurface fit the bill? (WebCore::ImageBufferBackingStoreCache::tryTakeFromCache): Lookup a bucket and walk through its contents (WebCore::ImageBufferBackingStoreCache::getOrAllocate): Public function for clients who want a IOSurface from the cache (WebCore::ImageBufferBackingStoreCache::deallocate): Public function for clients to return an IOSurface to the pool * platform/graphics/cg/ImageBufferBackingStoreCache.h: Added. (WebCore::ImageBuffer::ImageBuffer): (WebCore::ImageBuffer::~ImageBuffer): PerformanceTests: Reviewed by Geoff Garen. This test times creating a variety of different sizes of canvases once some have already been created. The second creation of the canvases should re-use the existing IOSurfaces. * Canvas/reuse.html: Added. LayoutTests: Reviewed by Geoff Garen. Now that we're re-using the backing store of canvases, this test makes sure that if we draw to a canvas, then destroy it, then create a new canvas (which should share the same backing store) that it doesn't have the stale data in it * fast/canvas/canvas-backing-store-reuse-expected.txt: Added. * fast/canvas/canvas-backing-store-reuse.html: Added. Canonical link: https://commits.webkit.org/144308@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@161235 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-01-02 23:32:47 +00:00
<!DOCTYPE html>
<html>
<body>
<script src="../resources/runner.js"></script>
<script>
[CG] Have Canvas use the IOSurfacePool https://bugs.webkit.org/show_bug.cgi?id=142417 <rdar://problem/20044440> Reviewed by Darin Adler. PerformanceTests: Lower the number of different canvas sizes from 1000 to 100 so that the test does not require such a huge cache size. With 100, we now get over 90% cache hit rate with the default IOSurfacePool size. * Canvas/reuse.html: Source/WebCore: Have ImageBufferDataCG use the IOSurfacePool so that Canvas can benefit from it. I see a ~75% progression on Canvas/reuse.html performance test on my Macbook Pro with 1000 different canvas sizes and ~110% progression with 100 different canvas sizes. I also see a ~65% cache hit rate on the mobile version of cnn.com. Note that ImageData calls CGContextClearRect() after calling IOSurface::create() so recycling IOSurfaces in this case should be safe. Performance test: Canvas/reuse.html * platform/graphics/ImageBuffer.h: (WebCore::ImageBuffer::baseTransform): * platform/graphics/cg/ImageBufferCG.cpp: (WebCore::ImageBuffer::ImageBuffer): (WebCore::ImageBuffer::context): (WebCore::ImageBuffer::copyImage): (WebCore::ImageBuffer::copyNativeImage): (WebCore::ImageBuffer::draw): (WebCore::ImageBuffer::clip): (WebCore::ImageBuffer::putByteArray): (WebCore::ImageBuffer::toDataURL): * platform/graphics/cg/ImageBufferDataCG.cpp: (WebCore::ImageBufferData::~ImageBufferData): (WebCore::ImageBufferData::getData): (WebCore::ImageBufferData::putData): (WebCore::ImageBufferData::ImageBufferData): Deleted. * platform/graphics/cg/ImageBufferDataCG.h: * platform/graphics/cocoa/IOSurface.h: * platform/graphics/cocoa/IOSurface.mm: (IOSurface::surfaceFromPool): (IOSurface::create): (IOSurface::createFromSendRight): (IOSurface::createFromImage): (IOSurface::setContextSize): Canonical link: https://commits.webkit.org/160549@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181301 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-03-10 01:24:14 +00:00
var numCreated = 100;
Allow ImageBuffer to re-use IOSurfaces https://bugs.webkit.org/show_bug.cgi?id=125477 Source/WebCore: Reviewed by Geoff Garen. Modifications reviewed by Tim Horton. This patch is taken from r160945, but the modifications to ImageBufferCG.cpp have been reverted. This test adds a static class, ImageBufferBackingStoreCache, that vends IOSurfaces. It remembers IOSurfaces that have been returned to it until a configurable timeout. The storage used by this class is in the form of a HashMap from a bucketed size to the IOSurface. There are many other data structures that could be used, but this implementation gives a 80% hit rate on normal browsing of some example sites with Canvas and text-decoration-skip: ink. Because the buckets are fairly small (rounding the width and height up to multiples of 8), traversing the bucket contents takes on average 2 steps. Test: fast/canvas/canvas-backing-store-reuse.html * WebCore.xcodeproj/project.pbxproj: Added new caching class * platform/graphics/cg/ImageBufferBackingStoreCache.cpp: Added. (WebCore::createIOSurface): Copied from ImageBufferCG.cpp (WebCore::ImageBufferBackingStoreCache::timerFired): Forget the cache contents (WebCore::ImageBufferBackingStoreCache::schedulePurgeTimer): (WebCore::ImageBufferBackingStoreCache::get): Static getter (WebCore::ImageBufferBackingStoreCache::ImageBufferBackingStoreCache): (WebCore::ImageBufferBackingStoreCache::insertIntoCache): Memory-management creation function (WebCore::ImageBufferBackingStoreCache::takeFromCache): Memory-management deletion function (WebCore::ImageBufferBackingStoreCache::isAcceptableSurface): Does this cached IOSurface fit the bill? (WebCore::ImageBufferBackingStoreCache::tryTakeFromCache): Lookup a bucket and walk through its contents (WebCore::ImageBufferBackingStoreCache::getOrAllocate): Public function for clients who want a IOSurface from the cache (WebCore::ImageBufferBackingStoreCache::deallocate): Public function for clients to return an IOSurface to the pool * platform/graphics/cg/ImageBufferBackingStoreCache.h: Added. (WebCore::ImageBuffer::ImageBuffer): (WebCore::ImageBuffer::~ImageBuffer): PerformanceTests: Reviewed by Geoff Garen. This test times creating a variety of different sizes of canvases once some have already been created. The second creation of the canvases should re-use the existing IOSurfaces. * Canvas/reuse.html: Added. LayoutTests: Reviewed by Geoff Garen. Now that we're re-using the backing store of canvases, this test makes sure that if we draw to a canvas, then destroy it, then create a new canvas (which should share the same backing store) that it doesn't have the stale data in it * fast/canvas/canvas-backing-store-reuse-expected.txt: Added. * fast/canvas/canvas-backing-store-reuse.html: Added. Canonical link: https://commits.webkit.org/144308@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@161235 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-01-02 23:32:47 +00:00
function testCreation() {
(function() {
var canvases = [];
for (var i = 0; i < numCreated; i += 16) {
var canvas = document.createElement("canvas");
canvas.width = i;
canvas.height = i;
var context = canvas.getContext("2d");
context.fillRect(0, 0, 1, 1);
canvases.push(canvas);
}
})();
if (window.GCController)
window.GCController.collect();
}
PerfTestRunner.measureRunsPerSecond({run: function() {
testCreation();
}});
</script>
</body>
</html>