Macrobenchmark tweaks & gpu memory dumping
Add support for glob matching
Ensure glob matches are alphabetically sorted
Add feature to dump GPU memory usage after a test pass
Adjust gpu memory dump to be a bit more compact (skip empty outputs)
Test: this
Bug: 187718492
Change-Id: I6dc80b2d3379d8d10001116e1240727d9914bc10
diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp
index d998e50..5047be9 100644
--- a/libs/hwui/renderthread/CacheManager.cpp
+++ b/libs/hwui/renderthread/CacheManager.cpp
@@ -140,7 +140,6 @@
log.appendFormat(" Size: %.2f kB \n", SkGraphics::GetFontCacheUsed() / 1024.0f);
log.appendFormat(" Glyph Count: %d \n", SkGraphics::GetFontCacheCountUsed());
- log.appendFormat("CPU Caches:\n");
std::vector<skiapipeline::ResourcePair> cpuResourceMap = {
{"skia/sk_resource_cache/bitmap_", "Bitmaps"},
{"skia/sk_resource_cache/rrect-blur_", "Masks"},
@@ -149,20 +148,20 @@
};
skiapipeline::SkiaMemoryTracer cpuTracer(cpuResourceMap, false);
SkGraphics::DumpMemoryStatistics(&cpuTracer);
- cpuTracer.logOutput(log);
+ if (cpuTracer.hasOutput()) {
+ log.appendFormat("CPU Caches:\n");
+ cpuTracer.logOutput(log);
+ }
- log.appendFormat("GPU Caches:\n");
skiapipeline::SkiaMemoryTracer gpuTracer("category", true);
mGrContext->dumpMemoryStatistics(&gpuTracer);
- gpuTracer.logOutput(log);
+ if (gpuTracer.hasOutput()) {
+ log.appendFormat("GPU Caches:\n");
+ gpuTracer.logOutput(log);
+ }
- log.appendFormat("Other Caches:\n");
- log.appendFormat(" Current / Maximum\n");
-
- if (renderState) {
- if (renderState->mActiveLayers.size() > 0) {
- log.appendFormat(" Layer Info:\n");
- }
+ if (renderState && renderState->mActiveLayers.size() > 0) {
+ log.appendFormat("Layer Info:\n");
const char* layerType = Properties::getRenderPipelineType() == RenderPipelineType::SkiaGL
? "GlLayer"
diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp
index 1b4b4b9..ad325cf 100644
--- a/libs/hwui/renderthread/RenderProxy.cpp
+++ b/libs/hwui/renderthread/RenderProxy.cpp
@@ -249,10 +249,10 @@
});
}
-void RenderProxy::dumpGraphicsMemory(int fd) {
+void RenderProxy::dumpGraphicsMemory(int fd, bool includeProfileData) {
if (RenderThread::hasInstance()) {
auto& thread = RenderThread::getInstance();
- thread.queue().runSync([&]() { thread.dumpGraphicsMemory(fd); });
+ thread.queue().runSync([&]() { thread.dumpGraphicsMemory(fd, includeProfileData); });
}
}
diff --git a/libs/hwui/renderthread/RenderProxy.h b/libs/hwui/renderthread/RenderProxy.h
index 288f555..662b445 100644
--- a/libs/hwui/renderthread/RenderProxy.h
+++ b/libs/hwui/renderthread/RenderProxy.h
@@ -109,7 +109,7 @@
// Not exported, only used for testing
void resetProfileInfo();
uint32_t frameTimePercentile(int p);
- static void dumpGraphicsMemory(int fd);
+ static void dumpGraphicsMemory(int fd, bool includeProfileData = true);
static void rotateProcessStatsBuffer();
static void setProcessStatsBuffer(int fd);
diff --git a/libs/hwui/renderthread/RenderThread.cpp b/libs/hwui/renderthread/RenderThread.cpp
index 3421e01..308352d 100644
--- a/libs/hwui/renderthread/RenderThread.cpp
+++ b/libs/hwui/renderthread/RenderThread.cpp
@@ -302,30 +302,25 @@
return *mVkManager.get();
}
-void RenderThread::dumpGraphicsMemory(int fd) {
- globalProfileData()->dump(fd);
-
- String8 cachesOutput;
- String8 pipeline;
- auto renderType = Properties::getRenderPipelineType();
- switch (renderType) {
- case RenderPipelineType::SkiaGL: {
- mCacheManager->dumpMemoryUsage(cachesOutput, mRenderState);
- pipeline.appendFormat("Skia (OpenGL)");
- break;
- }
- case RenderPipelineType::SkiaVulkan: {
- mCacheManager->dumpMemoryUsage(cachesOutput, mRenderState);
- pipeline.appendFormat("Skia (Vulkan)");
- break;
- }
+static const char* pipelineToString() {
+ switch (auto renderType = Properties::getRenderPipelineType()) {
+ case RenderPipelineType::SkiaGL:
+ return "Skia (OpenGL)";
+ case RenderPipelineType::SkiaVulkan:
+ return "Skia (Vulkan)";
default:
LOG_ALWAYS_FATAL("canvas context type %d not supported", (int32_t)renderType);
- break;
+ }
+}
+
+void RenderThread::dumpGraphicsMemory(int fd, bool includeProfileData) {
+ if (includeProfileData) {
+ globalProfileData()->dump(fd);
}
- dprintf(fd, "\n%s\n", cachesOutput.string());
- dprintf(fd, "\nPipeline=%s\n", pipeline.string());
+ String8 cachesOutput;
+ mCacheManager->dumpMemoryUsage(cachesOutput, mRenderState);
+ dprintf(fd, "\nPipeline=%s\n%s\n", pipelineToString(), cachesOutput.string());
}
Readback& RenderThread::readback() {
diff --git a/libs/hwui/renderthread/RenderThread.h b/libs/hwui/renderthread/RenderThread.h
index cd9b923..afd5750 100644
--- a/libs/hwui/renderthread/RenderThread.h
+++ b/libs/hwui/renderthread/RenderThread.h
@@ -150,7 +150,7 @@
VulkanManager& vulkanManager();
sk_sp<Bitmap> allocateHardwareBitmap(SkBitmap& skBitmap);
- void dumpGraphicsMemory(int fd);
+ void dumpGraphicsMemory(int fd, bool includeProfileData);
void requireGlContext();
void requireVkContext();