skia: Add tracing for skia's budget
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
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index aed31b7..8b44568 100644
--- a/src/gpu/GrResourceCache.cpp
+++ b/src/gpu/GrResourceCache.cpp
@@ -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 @@
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 @@
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 @@
#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 @@
--fBudgetedCount;
fBudgetedBytes -= size;
}
+ TRACE_COUNTER2(TRACE_DISABLED_BY_DEFAULT("skia.gpu.cache"), "skia budget", "used",
+ fBudgetedBytes, "free", fMaxBytes - fBudgetedBytes);
this->validate();
}