skia: Add tracing for skia's budget
authorhendrikw <hendrikw@chromium.org>
Wed, 4 Mar 2015 18:33:49 +0000 (10:33 -0800)
committerCommit bot <commit-bot@chromium.org>
Wed, 4 Mar 2015 18:33:50 +0000 (10:33 -0800)
We've run into several places where GPU rasterization slows down a lot,
and in some cases, it's due to use reaching skia's budget.  This shows a
graph of skia's used and free budgeted memory.

Review URL: https://codereview.chromium.org/977143002

src/gpu/GrResourceCache.cpp

index aed31b73d2af4ff3cacedd358d9497a3cd0fb7f6..8b445683385528983c48be4bf4b91beefd5a8ca9 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "GrResourceCache.h"
 #include "GrGpuResourceCacheAccess.h"
+#include "GrTracing.h"
 #include "SkChecksum.h"
 #include "SkGr.h"
 #include "SkMessageBus.h"
@@ -108,6 +109,8 @@ void GrResourceCache::insertResource(GrGpuResource* resource) {
     if (resource->resourcePriv().isBudgeted()) {
         ++fBudgetedCount;
         fBudgetedBytes += size;
+        TRACE_COUNTER2(TRACE_DISABLED_BY_DEFAULT("skia.gpu.cache"), "skia budget", "used",
+                       fBudgetedBytes, "free", fMaxBytes - fBudgetedBytes);
 #if GR_CACHE_STATS
         fBudgetedHighWaterCount = SkTMax(fBudgetedCount, fBudgetedHighWaterCount);
         fBudgetedHighWaterBytes = SkTMax(fBudgetedBytes, fBudgetedHighWaterBytes);
@@ -137,6 +140,8 @@ void GrResourceCache::removeResource(GrGpuResource* resource) {
     if (resource->resourcePriv().isBudgeted()) {
         --fBudgetedCount;
         fBudgetedBytes -= size;
+        TRACE_COUNTER2(TRACE_DISABLED_BY_DEFAULT("skia.gpu.cache"), "skia budget", "used",
+                       fBudgetedBytes, "free", fMaxBytes - fBudgetedBytes);
     }
 
     if (resource->resourcePriv().getScratchKey().isValid()) {
@@ -351,6 +356,8 @@ void GrResourceCache::didChangeGpuMemorySize(const GrGpuResource* resource, size
 #endif
     if (resource->resourcePriv().isBudgeted()) {
         fBudgetedBytes += delta;
+        TRACE_COUNTER2(TRACE_DISABLED_BY_DEFAULT("skia.gpu.cache"), "skia budget", "used",
+                       fBudgetedBytes, "free", fMaxBytes - fBudgetedBytes);
 #if GR_CACHE_STATS
         fBudgetedHighWaterBytes = SkTMax(fBudgetedBytes, fBudgetedHighWaterBytes);
 #endif
@@ -378,6 +385,8 @@ void GrResourceCache::didChangeBudgetStatus(GrGpuResource* resource) {
         --fBudgetedCount;
         fBudgetedBytes -= size;
     }
+    TRACE_COUNTER2(TRACE_DISABLED_BY_DEFAULT("skia.gpu.cache"), "skia budget", "used",
+                   fBudgetedBytes, "free", fMaxBytes - fBudgetedBytes);
 
     this->validate();
 }