Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f2d8413a authored by Yiwei Zhang's avatar Yiwei Zhang
Browse files

Game Driver Metrics: apply worst case limits for stats tracking

Bug: 123529932
Test: adb shell dumpsys gpu --gpustats --app
Change-Id: Id0bd408f62806ca4f297d5c07566a2c53e66177e
parent 178e067e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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:
+6 −3
Original line number Diff line number Diff line
@@ -44,15 +44,18 @@ public:
    // Pull gpu app stats
    void pullAppStats(std::vector<GpuStatsAppInfo>* 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.