Search Unity

Unity Introducing System Metrics Mali package

Discussion in 'Profiler Previews' started by antonk-unity, Jun 15, 2021.

  1. antonk-unity


    Unity Technologies

    Oct 4, 2016
    System Metrics Mali Package (SMM)

    Welcome to the System Metrics Mali discussion thread. You can use this thread to ask for help, share feedback, and have discussions about the experimental System Metrics Mali package.

    System Metrics Mali provides a simple and extensible interface for reading GPU hardware counters on Arm GPUs. Hardware counters provide a low-level view of application performance. These metrics can provide insight into what impact your changes produce on the hardware level. System Metrics Mali package exposes a set of hardware metrics via Unity Profiler window and Unity ProfilerRecorder API.

    Disclaimer: This package is still under development and anything could change on the API side.

    High-level features summary
    It allows access to and monitoring of GPU low-level counters. Sampling of the counters is performed on a per-frame level, so you can monitor changes in hardware system metrics along with other Unity Profiler frame stats.

    For more information, please have a look at:
    • The minimum required Unity version is 2021.2
    • Supports Samsung Exynos, HiSilicon Kirin, or MediaTek CPUs (as these use Mali GPU's)
    • Doesn’t support Qualcomm Snapdragon CPUs (as these use Adreno GPU's)
    Getting started
    • Download Unity 2021.2.0a17 or newer through the Hub.
    • Create or open a Unity project.
    • Go to Window > Package Manager.
    • Follow “Adding a registry package by name” instructions and add “com.unity.profiling.systemmetrics.mali
    • Build and run your application
    • Go to Window > Analysis > Profiler
    • Connect to a device and start capturing
    • Click on Profiler Module > Gear Icon

    • Click Add icon > Add counters from User group
    Current state
    The experimental System Metrics Mali Package is still under development and only a limited number of counters are currently available. When using this package you can expect that:
    • It should have zero CPU overhead if no hardware counters are being read through ProfilerRecorder API and/or Profiler isn’t attached
    • It has minimal fixed memory overhead of around 5-10Kb

    Hardware counters are sampled on a per-frame basis. Currently, whenever an application has CPU spikes that might cause System Metrics Mali to sample a portion of the next frame that looks like a spike up followed by a spike down. This is caused by captured frame interval and GPU frame interval misalignment.

    Most values are provided as absolute GPU cycles. This is due to the fact that GPU frequency is unavailable on most phones and we can’t measure relative performance.

    Older phones might have outdated implementations, but generally, the plugin should work on any phone released after 2010.

    What's next
    • We plan to significantly improve UI usability by introducing of custom Profiler Module which would allow providing pre-configured Profiler Module and have custom visualization for the counters
    • Replace absolute value counters with relative counters related to specific GPU pipeline stage
    • Add more hardware counters for different GPU pipeline stages to have high-level for each stage which might be an application bottleneck
    • Add support for non-mobile platforms and CPUs
    In terms of feedback, we're especially looking for:
    • Are there any workflows that are unclear or missing?
    • Any hardware compatibility or stability issues?
    • Are there any issues or unclear parts in the documentation?

    Please feel free to post any feedback in this sub-forum.

    How to report bugs
    Ideally, we'd like any bugs reported through the built-in bug reporter tool, as that will automatically provide us with some relevant context. When reporting bugs, please:
    • Report exact mobile phone model name and number
    • Attach logcat logs files if available

    Once you have submitted a bug report through the bug reporter, please feel free to start a discussion about it in this thread.

    Thank you for your interest, we're looking forward to your feedback!
    Last edited: Jun 16, 2021
    Jes28 and alexeyzakharov like this.
  2. antonk-unity


    Unity Technologies

    Oct 4, 2016
    0.2.0 update is available


    • Updated HWCP library to the latest version.
    • Added custom Profiler Module "Mali System Metrics" with an improved detailed view,
    • Added more hardware and derivated counters. See "Available metrics" for more details.
    • Improved metrics description documentation

    Newly added metrics:
    • GpuShaderCoreUtilization - % Shader Core Utilization
    • GpuNonFragmentUtilization - % Vertex And Compute Utilization
    • GpuFragmentUtilization - % Fragment Utilization
    • GpuShaderFragmentActive - Shader Fragment Cycles
    • GpuShaderComputeActive - Shader Compute Cycles
    • GpuShaderTripipeActive - Shader Tri-Pipe Cycles
    • GpuShaderFragmentUtilization - % Shader Fragment Utilization
    • GpuShaderComputeUtilization - % Shader Compute Utilization
    • GpuShaderTripipeUtilization - % Shader Tri-Pipe Utilization
    • GpuShaderArithmeticUtilization - % Shader Arithmetic Utilization
    • GpuShaderLoadStoreUtilization - % Shader Load/Store Utilization
    • GpuShaderTextureUtilization - % Shader Texture Unit Utilization
    • GpuReadStallRate - % Memory Read Stalled
    • GpuWriteStallRate - % Memory Write Stalled
    • GpuInputPrimitives - Input Primitives
    • GpuCulledPrimitives - Culled Primitives
    • GpuClippedPrimitives - Clipped Primitives
    • GpuVisiblePrimitives - Visible Primitives
    • GpuCulledPrimitivesPercentage - % Culled Primitives
    • GpuClippedPrimitivesPercentage - % Clipped Primitives
    • GpuVisiblePrimitivesPercentage - % Visible Primitives
    New custom profiler detailed view:

    image (7).png
  3. Jes28


    Sep 3, 2012
    Thanks very useful package :)

    Adding GPU Utilisation metrics on graphs and in detailed view will be very appreciated :) as much as adding description in tooltip for every metric in detailed view :)
    alexeyzakharov likes this.
  4. Kleptine


    Dec 23, 2013
    Wish we could use this! Do you know of any way to get these counters from Adreno GPUs?
  5. antonk-unity


    Unity Technologies

    Oct 4, 2016
    Unfortunately, Qualcomm doesn't provide API or documentation on how to access Adreno GPU hardware counters.

    Although it might be possible through kernel IOCTL. Here is an article on the topic.
    Sampling Performance Counters from Mobile GPU Drivers | Lei.Chat()
    Haven't tried it myself yet, but it seems it's possible while not easy though.