From f2d8413aa586869089149fa6ff9129ae7cff42d0 Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Wed, 6 Mar 2019 11:32:50 -0800 Subject: [PATCH] Game Driver Metrics: apply worst case limits for stats tracking Bug: 123529932 Test: adb shell dumpsys gpu --gpustats --app Change-Id: Id0bd408f62806ca4f297d5c07566a2c53e66177e --- services/gpuservice/gpustats/GpuStats.cpp | 2 ++ services/gpuservice/gpustats/GpuStats.h | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/services/gpuservice/gpustats/GpuStats.cpp b/services/gpuservice/gpustats/GpuStats.cpp index b7dc8cd3f7..618530523a 100644 --- a/services/gpuservice/gpustats/GpuStats.cpp +++ b/services/gpuservice/gpustats/GpuStats.cpp @@ -53,10 +53,12 @@ static void addLoadingTime(GraphicsEnv::Driver driver, int64_t driverLoadingTime switch (driver) { case GraphicsEnv::Driver::GL: case GraphicsEnv::Driver::GL_UPDATED: + if (outAppInfo->glDriverLoadingTime.size() >= GpuStats::MAX_NUM_LOADING_TIMES) break; outAppInfo->glDriverLoadingTime.emplace_back(driverLoadingTime); break; case GraphicsEnv::Driver::VULKAN: case GraphicsEnv::Driver::VULKAN_UPDATED: + if (outAppInfo->vkDriverLoadingTime.size() >= GpuStats::MAX_NUM_LOADING_TIMES) break; outAppInfo->vkDriverLoadingTime.emplace_back(driverLoadingTime); break; default: diff --git a/services/gpuservice/gpustats/GpuStats.h b/services/gpuservice/gpustats/GpuStats.h index 3e5604043f..d942154cbb 100644 --- a/services/gpuservice/gpustats/GpuStats.h +++ b/services/gpuservice/gpustats/GpuStats.h @@ -44,15 +44,18 @@ public: // Pull gpu app stats void pullAppStats(std::vector* outStats); + // This limits the worst case number of loading times tracked. + static const size_t MAX_NUM_LOADING_TIMES = 50; + private: // Dump global stats void dumpGlobalLocked(std::string* result); // Dump app stats void dumpAppLocked(std::string* result); - // This limits the memory usage of GpuStats to be less than 30KB. This is - // the maximum atom size statsd could afford. - static const size_t MAX_NUM_APP_RECORDS = 300; + // Below limits the memory usage of GpuStats to be less than 10KB. This is + // the preferred number for statsd while maintaining nice data quality. + static const size_t MAX_NUM_APP_RECORDS = 100; // GpuStats access should be guarded by mLock. std::mutex mLock; // Key is driver version code. -- 2.11.0