| MetalPerformanceHUD | LOCAL | MetalPerformanceHUD |
MetalPerformanceHUD —
Metal Performance HUD overview and configuration
The Metal Performance HUD (heads-up display) is a real-time overlay that displays graphics performance information for Metal apps. The overlay helps developers spot subtle performance issues such as large variations in rendering time and identify scopes worth capturing in Xcode or Instruments.
The HUD can also log per-frame statistics to the console, but console logging is deprecated; see LOGGING and COLLECTING PERFORMANCE DATA.
By default, the top of the HUD shows the Metal device, the layer resolution, an indicator for whether the present mode is direct or composited, the amount of memory allocated by the app and Metal, and whether Game Mode is on or off. The bottom section shows the average frames per second (FPS), GPU time, and frame interval, with a chart graphing the frame interval for the past 120 frames. The HUD can be customized to include additional metrics; see METRICS below.
The HUD recognizes a family of
MTL_HUD_LOG_* environment variables
(MTL_HUD_LOG_ENABLED and
MTL_HUD_LOG_SHADER_ENABLED) that write per-frame
statistics to the console.
Avoid using these variables. Console logging is deprecated and should not be used for new workflows. It emits unstructured text, cannot be opened in Instruments, and captures only a subset of the available metrics. For recording and analyzing performance data, use metalperftrace(1) instead; see COLLECTING PERFORMANCE DATA.
The Metal Performance HUD can be enabled in several ways.
Use the runtime diagnostics options in the scheme settings:
On iOS, iPadOS, or tvOS, the HUD is enabled in the Developer settings:
The Metal Performance HUD appears for apps you build and install yourself to your development devices. The device must have a development provisioning profile installed for the Developer options to appear in the Settings app.
Either of the following enables the HUD without setting environment variables or scheme options:
MetalHudEnabled to the app's
Info.plist file.MetalHUDForceEnabled=1 to the app's
NSUserDefaults.The metalperftrace(1) tool can enable the HUD in
an already-running Metal process without relaunching it. Use the
setup subcommand with the
hud feature, targeting the process by PID:
metalperftrace setup --enable hud --pid 1234
Disable it again with --disable
hud. This is useful for turning the overlay on for a
process that was launched without any of the options above. See
COLLECTING PERFORMANCE
DATA.
The HUD recognizes the following environment variables. The same
keys may also be set as entries in the
developerHUDProperties dictionary of a
CAMetalLayer to apply the same effects
programmatically.
MTL_HUD_ENABLEDAccepted values: 1 (or any non-zero
integer) to enable; 0 to disable.
Default: 0 (disabled).
MTL_HUD_CONFIG_FILEAccepted values: an absolute or relative path to a .plist file.
Default: none.
MTL_HUD_OPACITYAccepted values: a floating-point number; values are clamped
to the range [0.0, 1.0].
Default: 1.0 (fully opaque).
MTL_HUD_SCALEAccepted values: a floating-point number; values are clamped
to the range [0.1, 1.0].
Default: 0.2 (20% of the drawable
width).
MTL_HUD_ALIGNMENTAccepted values: topleft,
topcenter, topright,
centerleft, centered,
centerright, bottomleft,
bottomcenter, or
bottomright. The corresponding short forms
tl, tc,
tr, cl,
c, cr,
bl, bc, and
br are also accepted.
Default: topright.
MTL_HUD_POSITION_X,
MTL_HUD_POSITION_YMTL_HUD_ALIGNMENT.
Accepted values: a number of pixels, measured from the
top-left of the drawable, in the ranges [0,
drawableWidth] and [0, drawableHeight],
respectively.
Default: 0.
MTL_HUD_ELEMENTSAccepted values: a comma-separated list of metric names (see
METRICS), or one of the named layouts
FPS, Lite,
Default, Rich, or
Full.
Default: the Lite layout.
MTL_HUD_ENCODER_TIMING_ENABLEDAccepted values: 1 to enable;
0 to disable.
Default: 0 (disabled).
MTL_HUD_ENCODER_GPU_TIMELINE_FRAME_COUNTAccepted values: an integer; values are clamped to the range
[1, 10].
Default: 6.
MTL_HUD_ENCODER_GPU_TIMELINE_SWAP_DELTAAccepted values: a floating-point number of seconds; values
are clamped to the range [0.1, 10.0].
Default: 1.0.
MTL_HUD_SHOW_ZERO_METRICS0 since the app
launched or since the last reset. The HUD hides such metrics by default,
since they may not be available or are not used in the current context.
Accepted values: 1 to show zero-valued
metrics; 0 to hide them.
Default: 0 (hidden).
MTL_HUD_SHOW_METRICS_RANGEAccepted values: 1 to enable;
0 to disable.
Default: 0 (disabled).
MTL_HUD_INSIGHTS_ENABLEDAccepted values: 1 to enable;
0 to disable.
Default: 0 (disabled).
MTL_HUD_INSIGHT_TIMEOUTAccepted values: a floating-point number of seconds; values
below 1.0 are raised to
1.0.
Default: 10.0.
MTL_HUD_INSIGHT_REPORT_INTERVALAccepted values: a floating-point number of seconds; values
below 1.0 are raised to
1.0.
Default: 5.0.
MTL_HUD_RUSAGE_UPDATE_INTERVALAccepted values: a floating-point number of seconds; values
below 0.1 are raised to
0.1.
Default: 3.0.
MTL_HUD_METRIC_TIMEOUTAccepted values: a floating-point number of seconds; values
below 0.1 are raised to
0.1.
Default: 1.0.
MTL_HUD_REPORT_URLAccepted values: a writable file path.
Default: none.
MTL_HUD_DISABLE_MENU_BARAccepted values: 1 to disable the menu
bar item; 0 to show it.
Default: 0 on macOS (menu bar item
shown); 1 on iOS and tvOS, where there is no
menu bar.
MTL_HUD_STATE_REPORTER_DOMAINSAccepted values: a comma-separated list of StateReporting
domain names; the list may be wrapped in double quotes. The literal
value ALL or * enables
every available domain.
Default: none.
MTL_HUD_MFX_JITTER_VISAccepted values: 1 to enable;
0 to disable.
Default: 0 (disabled).
MTL_HUD_MFX_JITTER_OFFSET_RANGEAccepted values: a floating-point number; a value of
n produces sliders that span [-n,
+n].
Default: 5.0 (sliders spanning
[-5.0, +5.0]).
MTL_HUD_LOG_ENABLEDAccepted values: 1 to enable;
0 to disable.
Default: 0 (disabled).
The HUD can be configured programmatically by populating the
developerHUDProperties dictionary on a
CAMetalLayer instance:
myMetalLayer.developerHUDProperties = [
"mode": "default",
"positionX": 0,
"positionY": 0,
// ...
]
The dictionary accepts the following well-known keys:
modedefault, main, or
disabled. Enables or disables the HUD for this
layer. For apps that use multiple layers, set the value to
main to designate the primary layer, since certain
metrics (such as GPU time) are calculated based on the presentation
interval of the main layer. By default, the main layer is the first layer
the app creates.positionX[0, drawableWidth].positionY[0, drawableHeight].Any of the MTL_HUD_* environment variables
documented in ENVIRONMENT may also be
supplied as keys in the same dictionary.
The MTL_HUD_ELEMENTS environment variable
accepts a comma-separated list of metric names. The available names are:
devicerosettalayersizelayerscalememorycurrentAllocatedSize of the
MTLDevice.thermalProcessInfo.thermalState.fpsfpsgraphgputimeMTLCommandBuffer
gpuStartTime and
gpuEndTime.presentdelaypresentDrawable and the drawable hitting
the display.frameintervalMTLDrawable presents over the past 120
frames.frameintervalgraphframeintervalhistogrammetalcpushadersdiskrusage_info_current.gputimelineMTL_HUD_ENCODER_TIMING_ENABLED.toplabeledcommandbuffersMTLCommandBuffer.label. Requires encoder GPU time
tracking.toplabeledencodersMTLCommandEncoder.label. Requires encoder GPU time
tracking.The HUD also reports MetalFX metrics (scaling method, input and target resolution, exposure, and frame interpolator state) when an app uses the corresponding MetalFX effects.
When the HUD is enabled, a Metal HUD menu is added to the menu bar. This menu provides quick access to common HUD controls, performance report generation, and the configuration panel. The configuration panel can also be opened by triple-clicking the HUD overlay.
The configuration panel exposes three sections:
A custom configuration can be exported as a property
list using Export HUD Configuration, then re-applied at
launch by setting MTL_HUD_CONFIG_FILE to the file's
path. The Copy HUD
Configuration menu item exports the current state as a list of
environment variables suitable for passing to the app at launch.
On iOS or iPadOS, the HUD can be customized in the Developer settings:
These device settings apply to all apps that enable the Metal Performance HUD. Environment variables can be used to override the settings when debugging from Xcode.
Enable the HUD for a single launch from a shell:
MTL_HUD_ENABLED=1
./MyMetalAppPosition the HUD in the top-left corner at half opacity:
MTL_HUD_ENABLED=1
MTL_HUD_ALIGNMENT=topleft \ MTL_HUD_OPACITY=0.5
./MyMetalAppShow only FPS, GPU time, and the frame interval graph:
MTL_HUD_ENABLED=1 \
MTL_HUD_ELEMENTS=fps,gputime,frameintervalgraph \ ./MyMetalAppEnable encoder GPU time tracking and the value range display:
MTL_HUD_ENABLED=1
MTL_HUD_ENCODER_TIMING_ENABLED=1 \ MTL_HUD_SHOW_METRICS_RANGE=1
./MyMetalAppApply an exported HUD configuration file:
MTL_HUD_ENABLED=1 \
MTL_HUD_CONFIG_FILE=~/HUDConfig.plist ./MyMetalAppThe system continuously records frame timing and related statistics for all Metal layers, independently of whether the HUD overlay is visible. The metalperftrace(1) command-line tool retrieves this always-on data and is the recommended way to capture performance information for later analysis, replacing console logging.
metalperftrace(1) can:
collect).overview).listen).setup).For example, to enable the HUD in a running process and then stream its live statistics:
metalperftrace setup --enable hud --pid 1234 metalperftrace listen --pid 1234
See metalperftrace(1) for the full set of subcommands and options.
Monitoring your Metal app's graphics performance
| May 26, 2026 | macOS 26 |