Title: [212043] trunk/Source/WebCore
Revision
212043
Author
simon.fra...@apple.com
Date
2017-02-09 21:26:08 -0800 (Thu, 09 Feb 2017)

Log Message

Improve IOSurfacePool logging
https://bugs.webkit.org/show_bug.cgi?id=168098

Reviewed by Tim Horton.

Pass a string to DUMP_POOL_STATISTICS so we can tell what's triggering the
logging.

* platform/graphics/cg/IOSurfacePool.cpp:
(WebCore::IOSurfacePool::takeSurface):
(WebCore::IOSurfacePool::addSurface):
(WebCore::IOSurfacePool::evict):
(WebCore::IOSurfacePool::collectionTimerFired):
(WebCore::IOSurfacePool::showPoolStatistics):
* platform/graphics/cg/IOSurfacePool.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (212042 => 212043)


--- trunk/Source/WebCore/ChangeLog	2017-02-10 05:08:59 UTC (rev 212042)
+++ trunk/Source/WebCore/ChangeLog	2017-02-10 05:26:08 UTC (rev 212043)
@@ -1,3 +1,21 @@
+2017-02-09  Simon Fraser  <simon.fra...@apple.com>
+
+        Improve IOSurfacePool logging
+        https://bugs.webkit.org/show_bug.cgi?id=168098
+
+        Reviewed by Tim Horton.
+
+        Pass a string to DUMP_POOL_STATISTICS so we can tell what's triggering the
+        logging.
+
+        * platform/graphics/cg/IOSurfacePool.cpp:
+        (WebCore::IOSurfacePool::takeSurface):
+        (WebCore::IOSurfacePool::addSurface):
+        (WebCore::IOSurfacePool::evict):
+        (WebCore::IOSurfacePool::collectionTimerFired):
+        (WebCore::IOSurfacePool::showPoolStatistics):
+        * platform/graphics/cg/IOSurfacePool.h:
+
 2017-02-09  Alex Christensen  <achristen...@webkit.org>
 
         Unreviewed, rolling out r212040.

Modified: trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp (212042 => 212043)


--- trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp	2017-02-10 05:08:59 UTC (rev 212042)
+++ trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp	2017-02-10 05:26:08 UTC (rev 212043)
@@ -41,11 +41,11 @@
 // they can't be immediately returned when requested (but will be freed up in the future).
 const size_t maximumInUseBytes = defaultMaximumBytesCached / 2;
 
-#define ENABLE_IOSURFACE_POOL_STATISTICS false
+#define ENABLE_IOSURFACE_POOL_STATISTICS 0
 #if ENABLE_IOSURFACE_POOL_STATISTICS
-#define DUMP_POOL_STATISTICS() do { showPoolStatistics(); } while (0);
+#define DUMP_POOL_STATISTICS(reason) do { showPoolStatistics(reason); } while (0);
 #else
-#define DUMP_POOL_STATISTICS() ((void)0)
+#define DUMP_POOL_STATISTICS(reason) ((void)0)
 #endif
 
 namespace WebCore {
@@ -112,7 +112,7 @@
     CachedSurfaceMap::iterator mapIter = m_cachedSurfaces.find(size);
 
     if (mapIter == m_cachedSurfaces.end()) {
-        DUMP_POOL_STATISTICS();
+        DUMP_POOL_STATISTICS("takeSurface - none with matching size");
         return nullptr;
     }
 
@@ -134,7 +134,7 @@
 
         surface->setIsVolatile(false);
 
-        DUMP_POOL_STATISTICS();
+        DUMP_POOL_STATISTICS("takeSurface - taking");
         return surface;
     }
 
@@ -151,11 +151,11 @@
 
         surface->setIsVolatile(false);
 
-        DUMP_POOL_STATISTICS();
+        DUMP_POOL_STATISTICS("takeSurface - taking in-use");
         return surface;
     }
 
-    DUMP_POOL_STATISTICS();
+    DUMP_POOL_STATISTICS("takeSurface - failing");
     return nullptr;
 }
 
@@ -184,12 +184,12 @@
     if (surfaceIsInUse) {
         m_inUseSurfaces.prepend(WTFMove(surface));
         scheduleCollectionTimer();
-        DUMP_POOL_STATISTICS();
+        DUMP_POOL_STATISTICS("addSurface - in-use");
         return;
     }
 
     insertSurfaceIntoPool(WTFMove(surface));
-    DUMP_POOL_STATISTICS();
+    DUMP_POOL_STATISTICS("addSurface");
 }
 
 void IOSurfacePool::insertSurfaceIntoPool(std::unique_ptr<IOSurface> surface)
@@ -240,8 +240,11 @@
 
 void IOSurfacePool::evict(size_t additionalSize)
 {
+    DUMP_POOL_STATISTICS("before evict");
+
     if (additionalSize >= m_maximumBytesCached) {
         discardAllSurfaces();
+        DUMP_POOL_STATISTICS("after evict all");
         return;
     }
 
@@ -261,6 +264,8 @@
 
     while (m_inUseBytesCached > maximumInUseBytes || m_bytesCached > targetSize)
         tryEvictInUseSurface();
+
+    DUMP_POOL_STATISTICS("after evict");
 }
 
 void IOSurfacePool::collectInUseSurfaces()
@@ -310,7 +315,7 @@
         m_collectionTimer.stop();
 
     platformGarbageCollectNow();
-    DUMP_POOL_STATISTICS();
+    DUMP_POOL_STATISTICS("collectionTimerFired");
 }
 
 void IOSurfacePool::scheduleCollectionTimer()
@@ -331,10 +336,10 @@
     platformGarbageCollectNow();
 }
 
-void IOSurfacePool::showPoolStatistics()
+void IOSurfacePool::showPoolStatistics(const char* reason)
 {
 #if ENABLE_IOSURFACE_POOL_STATISTICS
-    WTFLogAlways("IOSurfacePool Statistics\n");
+    WTFLogAlways("IOSurfacePool Statistics: %s\n", reason);
     unsigned totalSurfaces = 0;
     size_t totalSize = 0;
     size_t totalPurgeableSize = 0;
@@ -356,7 +361,7 @@
         totalSize += queueSize;
         totalPurgeableSize += queuePurgeableSize;
 
-        WTFLogAlways("   %d x %d: %zu surfaces for %zd KB (%zd KB purgeable)", keyAndSurfaces.key.width(), keyAndSurfaces.key.height(), keyAndSurfaces.value.size(), queueSize / 1024, queuePurgeableSize / 1024);
+        WTFLogAlways("   %d x %d: %zu surfaces for %.2f MB (%.2f MB purgeable)", keyAndSurfaces.key.width(), keyAndSurfaces.key.height(), keyAndSurfaces.value.size(), queueSize / (1024.0 * 1024.0), queuePurgeableSize / (1024.0 * 1024.0));
     }
 
     size_t inUseSize = 0;
@@ -366,13 +371,15 @@
     }
 
     totalSize += inUseSize;
-    WTFLogAlways("   IN USE: %zu surfaces for %zd KB", m_inUseSurfaces.size(), inUseSize / 1024);
+    WTFLogAlways("   IN USE: %zu surfaces for %.2f MB", m_inUseSurfaces.size(), inUseSize / (1024.0 * 1024.0));
 
     // FIXME: Should move consistency checks elsewhere, and always perform them in debug builds.
     ASSERT(m_bytesCached == totalSize);
     ASSERT(m_bytesCached <= m_maximumBytesCached);
 
-    WTFLogAlways("   TOTAL: %d surfaces for %zd KB (%zd KB purgeable)\n", totalSurfaces, totalSize / 1024, totalPurgeableSize / 1024);
+    WTFLogAlways("   TOTAL: %d surfaces for %.2f MB (%.2f MB purgeable)\n", totalSurfaces, totalSize / (1024.0 * 1024.0), totalPurgeableSize / (1024.0 * 1024.0));
+#else
+    UNUSED_PARAM(reason);
 #endif
 }
 

Modified: trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.h (212042 => 212043)


--- trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.h	2017-02-10 05:08:59 UTC (rev 212042)
+++ trunk/Source/WebCore/platform/graphics/cg/IOSurfacePool.h	2017-02-10 05:26:08 UTC (rev 212043)
@@ -53,8 +53,6 @@
 
     WEBCORE_EXPORT void setPoolSize(size_t);
 
-    void showPoolStatistics();
-
 private:
     IOSurfacePool();
 
@@ -92,6 +90,8 @@
 
     void platformGarbageCollectNow();
 
+    void showPoolStatistics(const char*);
+
     Timer m_collectionTimer;
     CachedSurfaceMap m_cachedSurfaces;
     CachedSurfaceQueue m_inUseSurfaces;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to