Optimizing Performance with the GPU Counters Instrument

Examine your app's use of GPU resources in Instruments, and tune your app as needed.


The Metal GPU Counters instrument is part of Instruments in Xcode 11. Use an iOS or iPadOS device with an A11 or later processor and this instrument to profile how effectively your app uses the GPU. When the GPU is being underutilized, look for bottlenecks that are preventing work from getting to it, or find more work to send to it. When the GPU has enough work, find the commands that take the longest to execute and optimize them to use the GPU more efficiently.

The Metal GPU Counters instrument analyzes data you collect and tells you where your GPU bottlenecks might be. For example, you can determine whether the GPU is waiting for memory accesses or mathematical operations to complete, and whether you are sending it enough work to hide any latency from these operations. Use this data in conjunction with data from other tools, such as the Metal System Trace instrument or Shader Profiler, to determine whether your app is using the GPU effectively.

The Metal GPU Counters instrument provides three types of counters:

  • Occupancy counters — For measuring the number of threads the GPU is executing and which shader stages it is executing on those threads.

  • Limiter counters — For measuring activity in GPU subsystems. These measurements include time the GPU spends executing work and any stalls in a subsystem that prevent the GPU from starting new work.

  • Bandwidth counters — For measuring the overall memory bandwidth the GPU is using to read from or write to system memory.

Enable GPU Counters in the Metal System Trace Template

Because the GPU counters work well in tandem with Metal System Trace, the best way to use them is to enable them as part of a Metal System Trace capture.

In Instruments, after selecting the Metal System Trace template, click and hold the Record button until the menu appears, then choose the Recording Options menu item:

A screenshot showing the record button options.

Then, select the Performance Limiters option:

A screenshot showing the options for capturing different GPU counter sets. Performance Limiters is selected.


App Analysis Using the GPU Counters Instrument

Finding Your App's GPU Shader Occupancy

Determine how much of the GPU's potential concurrency is in use.

Reducing Shader Bottlenecks

Determine where your shaders spend the most time by using limiter counters, and take action to alleviate the problems.

Measuring the GPU's Use of Memory Bandwidth

Determine whether your app accesses memory correctly by using bandwidth counters.

See Also


Developing Metal Apps that Run in Simulator

Prototype and test your Metal apps in Simulator.

Supporting Simulator in a Metal App

Modify Metal Apps to Run in Simulator.

Frame Capture Debugging Tools

Analyze and optimize your app performance at runtime.

Using Metal System Trace in Instruments to Profile Your App

Smooth out your frame rate by checking for issues in your app's CPU and GPU utilization.