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

Commit 637ba5e8 authored by Stan Iliev's avatar Stan Iliev
Browse files

Expose HWUI metrics via statsd

Add atom definition for HWUI stats. Implement a C++
statsd puller inside GraphicsStatsService service.
GraphicsStatsService has new private API, which
returns a serialized proto with HWUI stats grouped
by application package and version.

Test: Ran "adb shell cmd stats pull-source 10068"
Test: Ran "statsd_testdrive 10068" and it looks OK
Bug: 142665516
Change-Id: I400c0dbf9e25181d36f9018688b03d86839ac3de
parent f2be9da2
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -415,6 +415,13 @@ filegroup {
    path: "core/java",
}

filegroup {
    name: "graphicsstats_proto",
    srcs: [
        "libs/hwui/protos/graphicsstats.proto",
    ],
}

filegroup {
    name: "libvibrator_aidl",
    srcs: [
+68 −1
Original line number Diff line number Diff line
@@ -336,7 +336,7 @@ message Atom {
    }

    // Pulled events will start at field 10000.
    // Next: 10068
    // Next: 10069
    oneof pulled {
        WifiBytesTransfer wifi_bytes_transfer = 10000;
        WifiBytesTransferByFgBg wifi_bytes_transfer_by_fg_bg = 10001;
@@ -405,6 +405,7 @@ message Atom {
        VmsClientStats vms_client_stats = 10065;
        NotificationRemoteViews notification_remote_views = 10066;
        DangerousPermissionStateSampled dangerous_permission_state_sampled = 10067;
        GraphicsStats graphics_stats = 10068;
    }

    // DO NOT USE field numbers above 100,000 in AOSP.
@@ -7553,3 +7554,69 @@ message DangerousPermissionStateSampled {
    optional int32 permission_flags = 4;
}

/**
 * HWUI renders pipeline type: GL (0) or Vulkan (1).
 */
enum PipelineType {
    GL = 0;
    VULKAN = 1;
}

/**
 * HWUI stats for a given app.
 */
message GraphicsStats {
    // The package name of the app
    optional string package_name = 1;

    // The version code of the app
    optional int64 version_code = 2;

    // The start & end timestamps in UTC as
    // milliseconds since January 1, 1970
    // Compatible with java.util.Date#setTime()
    optional int64 stats_start = 3;

    optional int64 stats_end = 4;

    // HWUI renders pipeline type: GL or Vulkan.
    optional PipelineType pipeline = 5;

    // Distinct frame count.
    optional int32 total_frames = 6;

    // Number of "missed vsync" events.
    optional int32 missed_vsync_count = 7;

    // Number of frames in triple-buffering scenario (high input latency)
    optional int32 high_input_latency_count = 8;

    // Number of "slow UI thread" events.
    optional int32 slow_ui_thread_count = 9;

    // Number of "slow bitmap upload" events.
    optional int32 slow_bitmap_upload_count = 10;

    // Number of "slow draw" events.
    optional int32 slow_draw_count = 11;

    // Number of frames that missed their deadline (aka, visibly janked)
    optional int32 missed_deadline_count = 12;

    // The frame time histogram for the package
    optional FrameTimingHistogram cpu_histogram = 13
    [(android.os.statsd.log_mode) = MODE_BYTES];

    // The gpu frame time histogram for the package
    optional FrameTimingHistogram gpu_histogram = 14
    [(android.os.statsd.log_mode) = MODE_BYTES];

    // UI mainline module version.
    optional int64 version_ui_module = 15;

    // If true, these are HWUI stats for up to a 24h period for a given app from today.
    // If false, these are HWUI stats for a 24h period for a given app from the last complete
    // day (yesterday). Stats from yesterday stay constant, while stats from today may change as
    // more apps are running / rendering.
    optional bool is_today = 16;
}
+7 −0
Original line number Diff line number Diff line
@@ -32,6 +32,10 @@ message GraphicsStatsServiceDumpProto {
}

message GraphicsStatsProto {
    enum PipelineType {
        GL = 0;
        VULKAN = 1;
    }
    option (android.msg_privacy).dest = DEST_AUTOMATIC;

    // The package name of the app
@@ -54,6 +58,9 @@ message GraphicsStatsProto {

    // The gpu frame time histogram for the package
    repeated GraphicsStatsHistogramBucketProto gpu_histogram = 7;

    // HWUI renders pipeline type: GL or Vulkan
    optional PipelineType pipeline = 8;
}

message GraphicsStatsJankSummaryProto {
+3 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */

#include "ProfileData.h"
#include "Properties.h"

#include <cinttypes>

@@ -102,6 +103,7 @@ void ProfileData::mergeWith(const ProfileData& other) {
        mGPUFrameCounts[i] >>= divider;
        mGPUFrameCounts[i] += other.mGPUFrameCounts[i];
    }
    mPipelineType = other.mPipelineType;
}

void ProfileData::dump(int fd) const {
@@ -157,6 +159,7 @@ void ProfileData::reset() {
    mTotalFrameCount = 0;
    mJankFrameCount = 0;
    mStatStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
    mPipelineType = Properties::getRenderPipelineType();
}

void ProfileData::reportFrame(int64_t duration) {
+5 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

#pragma once

#include "Properties.h"
#include "utils/Macros.h"

#include <utils/Timers.h>
@@ -65,6 +66,7 @@ public:
    uint32_t jankFrameCount() const { return mJankFrameCount; }
    nsecs_t statsStartTime() const { return mStatStartTime; }
    uint32_t jankTypeCount(JankType type) const { return mJankTypeCounts[static_cast<int>(type)]; }
    RenderPipelineType pipelineType() const { return mPipelineType; }

    struct HistogramEntry {
        uint32_t renderTimeMs;
@@ -103,6 +105,9 @@ private:
    uint32_t mTotalFrameCount;
    uint32_t mJankFrameCount;
    nsecs_t mStatStartTime;

    // true if HWUI renders with Vulkan pipeline
    RenderPipelineType mPipelineType;
};

// For testing
Loading