SlideShare a Scribd company logo
Optimize your game with the Profile Analyzer - Unite Copenhagen 2019
CPU Performance
Analysis with Unity’s
Profile Analyzer
Lyndon Homewood
Platforms Performance Team
Contents
3
— Introduction to Performance Analysis
— What is the Profile Analyzer?
— UI Overview
— Examples
— UI Breakdown
— Recap, links
Performance Analysis
4
Where to start?
5
— Have you ever wondered where to focus your performance efforts?
– Frame time data is so noisy
– How can you identify a representative frame
Comparing Performance
6
— Have you ever tried to compare performance after a change?
– Code change
– Asset / Data change
– Changing a project setting
– Updating to a new Unity version
– Switching platform
— Or just compare between representative frame and a slow frame
Explaining performance
7
— How you ever needed to report on performance changes?
– For your Technical Lead, CTO or investor
– To help guide optimisation efforts of your team
– Provide data in bug reports for Unity
A tool would help
— The Profile Analyzer was written to solve those problems
– Helps identify where to focus
– Supports comparison between profile captures
– Provides visual representations to aid understanding
Profile Analyzer
— Complements the Unity Profiler
— Multi frame CPU performance
analysis
– Statistics with visualisations
— Comprehensive Filtering support
— Allows comparison of two data sets
Introductory Video
10
11
Where do I get it from?
12
— Available as a preview package
– 2018.4 LTS +
— Or download directly
– Drop into assets folder
– 5.6 +
How do I launch it?
13
Launch from Window Menu :
— Window / Analysis / Profile Analyzer
Older versions :
— Window / Profile Analyzer
UI Overview
14
— Key areas of the UI
— Version 0.5
UI Overview
15
1. Frame Time graph
1
UI Overview
1. Frame Time graph
2. Filtering options
16
2
1
UI Overview
17
1. Frame Time graph
2. Filtering options
3. Top 10 Markers
3
1
2
UI Overview
18
1. Frame Time graph
2. Filtering options
3. Top 10 Markers
4. Marker Table
4
3
2
1
UI Overview
19
1. Frame Time graph
2. Filtering options
3. Top 10 Markers
4. Marker Table
Summary areas
3
2
1
4
UI Overview
20
1. Frame Time graph
2. Filtering options
3. Top 10 Markers
4. Marker Table
5. Frame Summary
5
4
3
2
1
UI Overview
21
1. Frame Time graph
2. Filtering options
3. Top 10 Markers
4. Marker Table
5. Frame Summary
6. Thread Summary
6
5
4
3
2
1
UI Overview
22
1. Frame Time graph
2. Filtering options
3. Top 10 Markers
4. Marker Table
5. Frame Summary
6. Thread Summary
7. Marker Summary
7
6
5
4
3
2
1
Profiling Tips
23
Profiling tips
— Setup repeatable capture
– FPS Sample has random spawn point
– Hacked in PreviewGameLoop.cs to fixed spawn point
var offset = 3;// Random.Range(0, spawnpoints.Length);
24
Profiling tips
— Close all applications other than the one you’re profiling
– Use C# Profile.logFile to write out profile log file (.raw)
– so you don’t need to have the editor running
– https://docs.unity3d.com/ScriptReference/Profiling.Profiler-logFile.html
— Disable CPU performance scaling
– E.g. Intel Speed Step or Turbo Boost
25
Examples
26
— Check if function called
— Finding Representative Frames
— Changing a project setting
— Are we GPU bound?
Check if function called
27
First we need to get some data
Entry point
28
Open the Unity Profiler
Unity Profiler
29
Open the Unity Profiler
Unity Profiler
30
Pull data from Unity Profiler
Or load previously saved data
Acquire Data
31
Data
32
Frame Time graph
— White for frame durations
— Cyan for currently selected marker
Search for marker
33
Use Filter area
— Type marker name
— E.g. FindObjectsOfType
Search for marker
34
Marker table shows filtered list
Search for marker
35
This marker only appears once
Search for marker
36
Marker shown in frame time graph
Search for marker
37
Marker shown in frame time graph
Search for marker
38
— Select marker
— View Summary
Search for marker
39
— Top section of Summary
Search for marker
40
— Shows first frame marker present on
Sync Unity Profiler
41
— Click to jump to frame in Profiler (*)
(*) If Profiler has same data set loaded
— Highlights selected marker
– (first instance)
Sync Unity Profiler
42
Finding Representative Frames
43
Selecting a
Representative Frame
44
— Use the Frame Summary
Selecting a
Representative Frame
45
— Find the median frame
– Here 17.5ms on frame 12
Selecting a
Representative Frame
46
— Find the median frame
– Here 17.5ms on frame 12
— Worst frame (max value)
– Here 38.15ms on frame 239
Sync Unity Profiler
47
Click button to jump to frame in the Unity Profiler
Filter frame selection in Profile Analyzer
— Right click on the Frame Time Graph
– Select Median Frame
— All stats are filtered to the selected frame
– Useful, but just one data point ...
48
Selecting a range of Representative frames
— Use ‘Order by Frame Duration’
— Range select a set of frames around the median point
– Using multiple frames smooths noise in the data
49
Changing a project setting
50
Graphics Jobs
Enable graphics jobs
— On FPS Sample project
Moves CPU graphics work off the main thread
See: https://learn.unity.com/tutorial/optimizing-graphics-in-unity#
51
Graphics Jobs
Player Settings
— Other Settings
52
Graphics Jobs?
Use Comparison view
— Take 2 captures and load them in
– 1st - jobs disabled (blue)
– 2nd - jobs enabled (orange)
53
Graphics Jobs?
Use Frame Summary
54
Graphics Jobs?
Improved frame times
— Faster on CPU overall
Conclusion:
— Graphics jobs setting is faster
Profile on your own projects
55
Thread Utilisation
Review thread activity
— First select threads
56
Thread Utilisation
Review thread activity
— Confirm work distributed to worker
threads
First select all threads, or subset. E.g.
— Worker threads : Job.Worker (All)
— Main thread
— Render thread
57
Thread Utilisation
View the Thread Summary tab
58
Thread Utilisation
View the Thread Summary tab
2nd data set = Graphics jobs enabled
— Worker threads are busier
— Main / Render threads are less busy
59
Are we GPU bound?
60
Are we GPU bound?
Check the duration of Gfx.WaitForPresent
— Non zero, if we are waiting for GPU
61
Are we GPU bound? Yes
Gfx.WaitForPresent
— Is non zero
— So CPU is waiting for the GPU
— Frame is therefore GPU bound
Majority of frames are GPU bound
62
Revisiting graphics jobs
Lets review the Graphics Jobs again
— Select Gfx.WaitForPresent
— Inspect the frame time graphs
63
Gfx.WaitForPresent almost zero
— Initially CPU Bound
Graphics jobs made CPU faster
— Now GPU bound
Next Steps : Focus on GPU optimisations
Revisiting graphics jobs
64
UI Breakdown
65
— Looking at the UI in more detail
Data Set Management
66
— Starting point
– At top of window
Data Set Management
67
1. Open Unity Profiler
2. ‘Pull Data’ from Unity Profiler, or
3. Load previously saved file (any Unity version)
12
3
Data Set Loaded
68
4. Frame time preview is shown for the data set
– Interactive region allowing selection of frame subset
– Right click for advanced options
5. Save to capture (.pdata file)
– Recommend saving Unity Profiler .data (or .raw) and Profile Analyzer .pdata together
5 4
Frame Time Summary
69
— Top right
Frame Time Summary
70
Shows frame times (defaults to ms)
— Highlights min, max, median
frame time (defaults to ms)
— Buttons to jump to specific frames
in Unity Profiler (*)
— Visuals for frame time distribution
Histogram and box and whisker plots
– (Box and whisker description later)
(*) If Profiler has same data set loaded
Marker Table
71
— Bottom left
— What does it show ?
72
2ms 1 2.5ms
5.5ms
Aggregated Marker Data
— Marker data from Unity Profiler
– All stack depths
— Time for each instance
— Calculate aggregated time : 5.5ms
— Record count of instances : 3
Median Marker Values
73
— Marker values over multiple frames
— Calculate min, max, median, etc
— Median value used in table view
5.5ms Min
Median
Max
Marker Table Details
74
Aggregated marker instances
— Displays median, min, max, …
— Visual bar for faster analysis
— Includes call counts and depth
— Table headers allow sorting
— Can select marker to focus on ...
Marker Summary
75
— Bottom right
— Currently selected marker
Marker Summary
76
Information about selected (aggregated) marker
1. Percentage of time in median frame
2. Top times, listed with frame indices
Frames where this marker is slowest
3. Visual display of marker distribution
Histogram and box and whisker plots
4. Median, min, max ms values
1
2
3
4
Marker Summary
77
Information about selected (aggregated) marker
1. Percentage of time in median frame
2. Top times, listed with frame indices
Frames where this marker is slowest
3. Visual display of marker distribution
Histogram and box and whisker plots
4. Median, min, max ms values
5. Min/max of individual marker instances
1
2
3
4
5
Box and Whisker plot
78
Distribution of time values. Tooltip shows exact values
1. Max
2. Upper quartile range
25% of data above this point. Middle value between median and max.
3. Median value
4. Lower quartile range
25% of data below this point. Middle value between min and median
5. Min
Interquartile range is the middle 50% of the values
2
4
1
5
3
Quick visual review
79
Use up/down cursor keys
— Scroll selected marker
Frame Summary
— Review Frame time distribution
— Focus on slowest markers first
– (top of table, sorted by median)
Box and Whisker plot - Examples
Low variance in data (and biased toward low times)
— Suggestion: Review slow outlier frames (>1ms)
80
Large variance in data (wide interquartile range)
— But total min-max range is small (0.01-0.28)
— Suggestion: Ignore (due to small range)
Even data distribution (bell curve)
— Suggestion: Review which other markers align
with slow/fast outliers
Box and Whisker plot - Comparison
81
Comparison between two data sets
— Here the blue data set is slower
Filtering Options
82
— Below frame time graph
— Use to drill down
Filtering Options - Marker Names
83
1. Marker name filtering (case insensitive substring)
– Separated by spaces
– Quote if space in name. E.g. “my marker”
2. Excluding by name (case insensitive substring). E.g. :
– “idle” to exclude idle time in jobs
– “profile” to exclude all profiler functions
1 2
Filtering Options - Marker Selection
84
Can also add to include/exclude list
via marker right click in marker table
1 2
Filtering Options - Threads
85
Thread filtering
Including thread aggregation.
E.g. ‘All worker threads’
3
3.
Filtering Options - Depth
86
4. Marker call stack depth filtering (E.g. callstack depth 3)
4
Filtering Options - Parent
87
5. Limit to markers below a parent
Select parent by right clicking on marker table
5
5. Limit to markers below a parent
Select parent by right clicking on marker table
Filtering Options - Parent
88
5
Filtering Options - Self time
89
6. Show ‘self’ marker time (excluding children)
or ‘total’ time (including children)
Eg.
Self time for Camera.Render is small
as most of time is in child markers
6
Filtering Options
90
7. Select time units to show
8. Select group of marker table columns
9. Indication of marker/thread count for the current filter
8
7
9
8
7
Top 10 markers
91
— Top 10 markers for a quick overview
– on the median frame
Top 10 markers
92
Shows relative ratio of most significant markers
— Uses current filter
— Typically used with
– Main thread
– At specific depth slice (E.g. depth 3)
– Using the ‘total time’ (I.e. including children)
Top 10 markers
93
— Clicking selects the marker
— Tooltips show % and ms time
Comparison Tab
— “Compare” tab
– Compare two data sets
– Or two areas of a single data set
Comparison Tab
— Select left/right data to compare
– Same filters as single data set
– Same visual aids
Comparison Tab
— Side by side comparisons
— Differences shown numerically
— And with visual graphs
– Tooltips on graphs for details
Comparison Table
— Bars show data set with longer time
– Blue if 1st data set has longer time
– Orange if 2nd data set has longer time
Comparison Table
— If marker only present in one scan
– E.g. renamed in new Unity version
— Dash ‘-’ shown for missing markers
– E.g Material.SetPassUncached not in second data set
Comparison top 10 - Normalised
— Both data sets scaled to their own median frame time
– Quickly see if a system has larger impact
Comparison top 10 - Longest
— Data sets are scaled to longest frame time
– Shows absolute differences
Export
— Exporting to csv data
— For custom processing
Export
— Marker table contents
— Frame duration values
– Single
– Comparison
Export
Rich data export
Export
Frame Times Frame Time Comparison
Recap
105
Profile Analyzer
106
— Profile Analyzer is a CPU performance analysis tool
— Shows numerical values and data visualisations
— Numerous filtering options
— Allows comparison of two data sets
— Export for your own analysis
How to get it
107
— Available as a preview package
– 2018.4 +
— Or download directly
– Drop into assets folder
– 5.6 +
Direct download link (also in main documentation)
https://unity.bintray.com/unity/com.unity.performance.profile-analyzer/-/
How to get it
108
Show Preview Packages from the ‘Advanced’ menu
Select Profile Analyzer (Using 0.5.0 in this presentation)
Thank you
109
— Big thank you to all Unity Users who gave valuable feedback
– Please continue to give your feedback. We are listening
– Use Profiler preview area on the forums : https://forum.unity.com/forums/profiler-previews.199/
– Raise Bug reports
Links, Questions?
110
Documentation & Direct Download
https://docs.unity3d.com/Packages/com.unity.performance.profile-analyzer@latest/index.htm
Feedback forum
https://forum.unity.com/forums/profiler-previews.199/
Graphics jobs
https://learn.unity.com/tutorial/optimizing-graphics-in-unity#l
Thank you
111
Useful layout - docked with Profiler
112
Marker Median Value
113
Median value is usually on a different
frame for each marker.
Hover mouse on median to see frame
— WaitForJobGroupID 3.44ms
on frame 55
— Game.Update 0.37ms
on frame 280
Check for markers that
are called a lot
— Sort by count
— GC.Alloc has a high call count
114
Comparing a range of
Representative frames
— Use ‘Order by Frame Time’
— Range select a set of frames, around the median point
— Selection mirrored/paired on both graphs by default
– But can make unique selection on each graph
— All stats will be limited to this selection
115
Markers
— is selection
116
‘Order by Frame Duration’
Shows slower frames align to where GPU bound
Cause of slower frames
117
Delete this slide before presenting
Keep all text within these margins

More Related Content

PPT
How we optimized our Game - Jake & Tess' Finding Monsters Adventure
PDF
【Unite 2018 Tokyo】そろそろ楽がしたい!新アセットバンドルワークフロー&リソースマネージャー詳細解説
PDF
【Unity道場】新しいPrefabワークフロー入門
PPTX
Photon Fusionのはじめの一歩
PPTX
Unity 2018-2019を見据えたDeNAのUnity開発のこれから [DeNA TechCon 2019]
PPTX
Unityで PhotonCloudを使ってリアルタイム・マルチプレイヤーゲームを作っちゃおう【導入編】
PPTX
UE4におけるLoadingとGCのProfilingと最適化手法
PDF
Constexpr 中3女子テクニック
How we optimized our Game - Jake & Tess' Finding Monsters Adventure
【Unite 2018 Tokyo】そろそろ楽がしたい!新アセットバンドルワークフロー&リソースマネージャー詳細解説
【Unity道場】新しいPrefabワークフロー入門
Photon Fusionのはじめの一歩
Unity 2018-2019を見据えたDeNAのUnity開発のこれから [DeNA TechCon 2019]
Unityで PhotonCloudを使ってリアルタイム・マルチプレイヤーゲームを作っちゃおう【導入編】
UE4におけるLoadingとGCのProfilingと最適化手法
Constexpr 中3女子テクニック

What's hot (20)

PDF
【UE4.25 新機能】新しいシリアライゼーション機能「Unversioned Property Serialization」について
PDF
日曜プログラマーが
1週間くらいで通信対戦ゲームを作ってみた
PPTX
Write microservice in golang
PDF
中級グラフィックス入門~シャドウマッピング総まとめ~
PDF
一般的なチートの手法と対策について
PDF
Unreal Open Day 2017 Optimize in Mobile UI
PPTX
Tales from the Optimization Trenches - Unite Copenhagen 2019
PDF
【CEDEC2017】Unityを使ったNintendo Switch™向けのタイトル開発・移植テクニック!!
PDF
知って得するUnity エディタ拡張編
PDF
Unity Internals: Memory and Performance
PDF
バイキング流UE4活用術 ~BPとお別れするまでの18ヶ月~
PPTX
大規模ゲーム開発における build 高速化と安定化
PDF
C++ マルチスレッドプログラミング
PPTX
冬のLock free祭り safe
PPTX
非同期処理の基礎
PPTX
なぜなにリアルタイムレンダリング
PDF
UIElements+UI BuilderでEditor拡張を作ろう
PDF
【Unity道場スペシャル 2017京都】最適化をする前に覚えておきたい技術
PDF
Optimization in Unity: simple tips for developing with "no surprises" / Anton...
PPTX
Apache Flink in the Cloud-Native Era
【UE4.25 新機能】新しいシリアライゼーション機能「Unversioned Property Serialization」について
日曜プログラマーが
1週間くらいで通信対戦ゲームを作ってみた
Write microservice in golang
中級グラフィックス入門~シャドウマッピング総まとめ~
一般的なチートの手法と対策について
Unreal Open Day 2017 Optimize in Mobile UI
Tales from the Optimization Trenches - Unite Copenhagen 2019
【CEDEC2017】Unityを使ったNintendo Switch™向けのタイトル開発・移植テクニック!!
知って得するUnity エディタ拡張編
Unity Internals: Memory and Performance
バイキング流UE4活用術 ~BPとお別れするまでの18ヶ月~
大規模ゲーム開発における build 高速化と安定化
C++ マルチスレッドプログラミング
冬のLock free祭り safe
非同期処理の基礎
なぜなにリアルタイムレンダリング
UIElements+UI BuilderでEditor拡張を作ろう
【Unity道場スペシャル 2017京都】最適化をする前に覚えておきたい技術
Optimization in Unity: simple tips for developing with "no surprises" / Anton...
Apache Flink in the Cloud-Native Era
Ad

Similar to Optimize your game with the Profile Analyzer - Unite Copenhagen 2019 (20)

PDF
Oracle AHF Insights 23c: Deeper Diagnostic Insights for your Oracle Database ...
PDF
Oracle AHF Insights 23c: Deeper Diagnostic Insights for your Oracle Database
PDF
Oracle AHF Insights 23c - Deeper Diagnostic Insights for your Oracle Database...
PDF
Bài tập lớn hệ điều hành HCMUT_HK232.pdf
PDF
Bslsg131en 1
PPTX
Welcome Webinar Slides
PPTX
How to Webinar: Sumo Logic Dashboards
PDF
Python Control library
PDF
CRM EHP3 landscape guide
PDF
Visual Studio Profiler
PDF
Xilinx timing closure
PDF
FIFOPt
PPTX
ISAD 313-3_ TOOLS OF THE SYSTEM ANALYSIS.pptx
PDF
What the Heck Just Happened?
PPTX
Sumo Logic quickStart Webinar June 2016
PDF
Z suzanne van_den_bosch
PDF
Sage tutorial
PDF
Cytoscape Tutorial Session 1 at UT-KBRIN Bioinformatics Summit 2014 (4/11/2014)
PDF
thesis
PDF
Ali.Kamali-MSc.Thesis-SFU
Oracle AHF Insights 23c: Deeper Diagnostic Insights for your Oracle Database ...
Oracle AHF Insights 23c: Deeper Diagnostic Insights for your Oracle Database
Oracle AHF Insights 23c - Deeper Diagnostic Insights for your Oracle Database...
Bài tập lớn hệ điều hành HCMUT_HK232.pdf
Bslsg131en 1
Welcome Webinar Slides
How to Webinar: Sumo Logic Dashboards
Python Control library
CRM EHP3 landscape guide
Visual Studio Profiler
Xilinx timing closure
FIFOPt
ISAD 313-3_ TOOLS OF THE SYSTEM ANALYSIS.pptx
What the Heck Just Happened?
Sumo Logic quickStart Webinar June 2016
Z suzanne van_den_bosch
Sage tutorial
Cytoscape Tutorial Session 1 at UT-KBRIN Bioinformatics Summit 2014 (4/11/2014)
thesis
Ali.Kamali-MSc.Thesis-SFU
Ad

More from Unity Technologies (20)

PDF
Build Immersive Worlds in Virtual Reality
PDF
Augmenting reality: Bring digital objects into the real world
PDF
Let’s get real: An introduction to AR, VR, MR, XR and more
PDF
Using synthetic data for computer vision model training
PDF
The Tipping Point: How Virtual Experiences Are Transforming Global Industries
PDF
Unity Roadmap 2020: Live games
PDF
Unity Roadmap 2020: Core Engine & Creator Tools
PDF
How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...
PPTX
Unity XR platform has a new architecture – Unite Copenhagen 2019
PDF
Turn Revit Models into real-time 3D experiences
PDF
How Daimler uses mobile mixed realities for training and sales - Unite Copenh...
PDF
How Volvo embraced real-time 3D and shook up the auto industry- Unite Copenha...
PDF
QA your code: The new Unity Test Framework – Unite Copenhagen 2019
PDF
Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...
PDF
Supplying scalable VR training applications with Innoactive - Unite Copenhage...
PDF
XR and real-time 3D in automotive digital marketing strategies | Visionaries ...
PDF
Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...
PDF
Creating next-gen VR and MR experiences using Varjo VR-1 and XR-1 - Unite Cop...
PDF
What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019
PDF
How to Improve Visual Rendering Quality in VR - Unite Copenhagen 2019
Build Immersive Worlds in Virtual Reality
Augmenting reality: Bring digital objects into the real world
Let’s get real: An introduction to AR, VR, MR, XR and more
Using synthetic data for computer vision model training
The Tipping Point: How Virtual Experiences Are Transforming Global Industries
Unity Roadmap 2020: Live games
Unity Roadmap 2020: Core Engine & Creator Tools
How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...
Unity XR platform has a new architecture – Unite Copenhagen 2019
Turn Revit Models into real-time 3D experiences
How Daimler uses mobile mixed realities for training and sales - Unite Copenh...
How Volvo embraced real-time 3D and shook up the auto industry- Unite Copenha...
QA your code: The new Unity Test Framework – Unite Copenhagen 2019
Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...
Supplying scalable VR training applications with Innoactive - Unite Copenhage...
XR and real-time 3D in automotive digital marketing strategies | Visionaries ...
Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...
Creating next-gen VR and MR experiences using Varjo VR-1 and XR-1 - Unite Cop...
What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019
How to Improve Visual Rendering Quality in VR - Unite Copenhagen 2019

Recently uploaded (20)

PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Spectroscopy.pptx food analysis technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Approach and Philosophy of On baking technology
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPT
Teaching material agriculture food technology
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Empathic Computing: Creating Shared Understanding
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
sap open course for s4hana steps from ECC to s4
Spectroscopy.pptx food analysis technology
Advanced methodologies resolving dimensionality complications for autism neur...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Encapsulation_ Review paper, used for researhc scholars
Approach and Philosophy of On baking technology
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Digital-Transformation-Roadmap-for-Companies.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Teaching material agriculture food technology
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Network Security Unit 5.pdf for BCA BBA.
MIND Revenue Release Quarter 2 2025 Press Release
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Empathic Computing: Creating Shared Understanding
20250228 LYD VKU AI Blended-Learning.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Unlocking AI with Model Context Protocol (MCP)

Optimize your game with the Profile Analyzer - Unite Copenhagen 2019

  • 2. CPU Performance Analysis with Unity’s Profile Analyzer Lyndon Homewood Platforms Performance Team
  • 3. Contents 3 — Introduction to Performance Analysis — What is the Profile Analyzer? — UI Overview — Examples — UI Breakdown — Recap, links
  • 5. Where to start? 5 — Have you ever wondered where to focus your performance efforts? – Frame time data is so noisy – How can you identify a representative frame
  • 6. Comparing Performance 6 — Have you ever tried to compare performance after a change? – Code change – Asset / Data change – Changing a project setting – Updating to a new Unity version – Switching platform — Or just compare between representative frame and a slow frame
  • 7. Explaining performance 7 — How you ever needed to report on performance changes? – For your Technical Lead, CTO or investor – To help guide optimisation efforts of your team – Provide data in bug reports for Unity
  • 8. A tool would help — The Profile Analyzer was written to solve those problems – Helps identify where to focus – Supports comparison between profile captures – Provides visual representations to aid understanding
  • 9. Profile Analyzer — Complements the Unity Profiler — Multi frame CPU performance analysis – Statistics with visualisations — Comprehensive Filtering support — Allows comparison of two data sets
  • 11. 11
  • 12. Where do I get it from? 12 — Available as a preview package – 2018.4 LTS + — Or download directly – Drop into assets folder – 5.6 +
  • 13. How do I launch it? 13 Launch from Window Menu : — Window / Analysis / Profile Analyzer Older versions : — Window / Profile Analyzer
  • 14. UI Overview 14 — Key areas of the UI — Version 0.5
  • 15. UI Overview 15 1. Frame Time graph 1
  • 16. UI Overview 1. Frame Time graph 2. Filtering options 16 2 1
  • 17. UI Overview 17 1. Frame Time graph 2. Filtering options 3. Top 10 Markers 3 1 2
  • 18. UI Overview 18 1. Frame Time graph 2. Filtering options 3. Top 10 Markers 4. Marker Table 4 3 2 1
  • 19. UI Overview 19 1. Frame Time graph 2. Filtering options 3. Top 10 Markers 4. Marker Table Summary areas 3 2 1 4
  • 20. UI Overview 20 1. Frame Time graph 2. Filtering options 3. Top 10 Markers 4. Marker Table 5. Frame Summary 5 4 3 2 1
  • 21. UI Overview 21 1. Frame Time graph 2. Filtering options 3. Top 10 Markers 4. Marker Table 5. Frame Summary 6. Thread Summary 6 5 4 3 2 1
  • 22. UI Overview 22 1. Frame Time graph 2. Filtering options 3. Top 10 Markers 4. Marker Table 5. Frame Summary 6. Thread Summary 7. Marker Summary 7 6 5 4 3 2 1
  • 24. Profiling tips — Setup repeatable capture – FPS Sample has random spawn point – Hacked in PreviewGameLoop.cs to fixed spawn point var offset = 3;// Random.Range(0, spawnpoints.Length); 24
  • 25. Profiling tips — Close all applications other than the one you’re profiling – Use C# Profile.logFile to write out profile log file (.raw) – so you don’t need to have the editor running – https://docs.unity3d.com/ScriptReference/Profiling.Profiler-logFile.html — Disable CPU performance scaling – E.g. Intel Speed Step or Turbo Boost 25
  • 26. Examples 26 — Check if function called — Finding Representative Frames — Changing a project setting — Are we GPU bound?
  • 27. Check if function called 27
  • 28. First we need to get some data Entry point 28
  • 29. Open the Unity Profiler Unity Profiler 29
  • 30. Open the Unity Profiler Unity Profiler 30
  • 31. Pull data from Unity Profiler Or load previously saved data Acquire Data 31
  • 32. Data 32 Frame Time graph — White for frame durations — Cyan for currently selected marker
  • 33. Search for marker 33 Use Filter area — Type marker name — E.g. FindObjectsOfType
  • 34. Search for marker 34 Marker table shows filtered list
  • 35. Search for marker 35 This marker only appears once
  • 36. Search for marker 36 Marker shown in frame time graph
  • 37. Search for marker 37 Marker shown in frame time graph
  • 38. Search for marker 38 — Select marker — View Summary
  • 39. Search for marker 39 — Top section of Summary
  • 40. Search for marker 40 — Shows first frame marker present on
  • 41. Sync Unity Profiler 41 — Click to jump to frame in Profiler (*) (*) If Profiler has same data set loaded
  • 42. — Highlights selected marker – (first instance) Sync Unity Profiler 42
  • 45. Selecting a Representative Frame 45 — Find the median frame – Here 17.5ms on frame 12
  • 46. Selecting a Representative Frame 46 — Find the median frame – Here 17.5ms on frame 12 — Worst frame (max value) – Here 38.15ms on frame 239
  • 47. Sync Unity Profiler 47 Click button to jump to frame in the Unity Profiler
  • 48. Filter frame selection in Profile Analyzer — Right click on the Frame Time Graph – Select Median Frame — All stats are filtered to the selected frame – Useful, but just one data point ... 48
  • 49. Selecting a range of Representative frames — Use ‘Order by Frame Duration’ — Range select a set of frames around the median point – Using multiple frames smooths noise in the data 49
  • 50. Changing a project setting 50
  • 51. Graphics Jobs Enable graphics jobs — On FPS Sample project Moves CPU graphics work off the main thread See: https://learn.unity.com/tutorial/optimizing-graphics-in-unity# 51
  • 53. Graphics Jobs? Use Comparison view — Take 2 captures and load them in – 1st - jobs disabled (blue) – 2nd - jobs enabled (orange) 53
  • 55. Graphics Jobs? Improved frame times — Faster on CPU overall Conclusion: — Graphics jobs setting is faster Profile on your own projects 55
  • 56. Thread Utilisation Review thread activity — First select threads 56
  • 57. Thread Utilisation Review thread activity — Confirm work distributed to worker threads First select all threads, or subset. E.g. — Worker threads : Job.Worker (All) — Main thread — Render thread 57
  • 58. Thread Utilisation View the Thread Summary tab 58
  • 59. Thread Utilisation View the Thread Summary tab 2nd data set = Graphics jobs enabled — Worker threads are busier — Main / Render threads are less busy 59
  • 60. Are we GPU bound? 60
  • 61. Are we GPU bound? Check the duration of Gfx.WaitForPresent — Non zero, if we are waiting for GPU 61
  • 62. Are we GPU bound? Yes Gfx.WaitForPresent — Is non zero — So CPU is waiting for the GPU — Frame is therefore GPU bound Majority of frames are GPU bound 62
  • 63. Revisiting graphics jobs Lets review the Graphics Jobs again — Select Gfx.WaitForPresent — Inspect the frame time graphs 63
  • 64. Gfx.WaitForPresent almost zero — Initially CPU Bound Graphics jobs made CPU faster — Now GPU bound Next Steps : Focus on GPU optimisations Revisiting graphics jobs 64
  • 65. UI Breakdown 65 — Looking at the UI in more detail
  • 66. Data Set Management 66 — Starting point – At top of window
  • 67. Data Set Management 67 1. Open Unity Profiler 2. ‘Pull Data’ from Unity Profiler, or 3. Load previously saved file (any Unity version) 12 3
  • 68. Data Set Loaded 68 4. Frame time preview is shown for the data set – Interactive region allowing selection of frame subset – Right click for advanced options 5. Save to capture (.pdata file) – Recommend saving Unity Profiler .data (or .raw) and Profile Analyzer .pdata together 5 4
  • 70. Frame Time Summary 70 Shows frame times (defaults to ms) — Highlights min, max, median frame time (defaults to ms) — Buttons to jump to specific frames in Unity Profiler (*) — Visuals for frame time distribution Histogram and box and whisker plots – (Box and whisker description later) (*) If Profiler has same data set loaded
  • 71. Marker Table 71 — Bottom left — What does it show ?
  • 72. 72 2ms 1 2.5ms 5.5ms Aggregated Marker Data — Marker data from Unity Profiler – All stack depths — Time for each instance — Calculate aggregated time : 5.5ms — Record count of instances : 3
  • 73. Median Marker Values 73 — Marker values over multiple frames — Calculate min, max, median, etc — Median value used in table view 5.5ms Min Median Max
  • 74. Marker Table Details 74 Aggregated marker instances — Displays median, min, max, … — Visual bar for faster analysis — Includes call counts and depth — Table headers allow sorting — Can select marker to focus on ...
  • 75. Marker Summary 75 — Bottom right — Currently selected marker
  • 76. Marker Summary 76 Information about selected (aggregated) marker 1. Percentage of time in median frame 2. Top times, listed with frame indices Frames where this marker is slowest 3. Visual display of marker distribution Histogram and box and whisker plots 4. Median, min, max ms values 1 2 3 4
  • 77. Marker Summary 77 Information about selected (aggregated) marker 1. Percentage of time in median frame 2. Top times, listed with frame indices Frames where this marker is slowest 3. Visual display of marker distribution Histogram and box and whisker plots 4. Median, min, max ms values 5. Min/max of individual marker instances 1 2 3 4 5
  • 78. Box and Whisker plot 78 Distribution of time values. Tooltip shows exact values 1. Max 2. Upper quartile range 25% of data above this point. Middle value between median and max. 3. Median value 4. Lower quartile range 25% of data below this point. Middle value between min and median 5. Min Interquartile range is the middle 50% of the values 2 4 1 5 3
  • 79. Quick visual review 79 Use up/down cursor keys — Scroll selected marker Frame Summary — Review Frame time distribution — Focus on slowest markers first – (top of table, sorted by median)
  • 80. Box and Whisker plot - Examples Low variance in data (and biased toward low times) — Suggestion: Review slow outlier frames (>1ms) 80 Large variance in data (wide interquartile range) — But total min-max range is small (0.01-0.28) — Suggestion: Ignore (due to small range) Even data distribution (bell curve) — Suggestion: Review which other markers align with slow/fast outliers
  • 81. Box and Whisker plot - Comparison 81 Comparison between two data sets — Here the blue data set is slower
  • 82. Filtering Options 82 — Below frame time graph — Use to drill down
  • 83. Filtering Options - Marker Names 83 1. Marker name filtering (case insensitive substring) – Separated by spaces – Quote if space in name. E.g. “my marker” 2. Excluding by name (case insensitive substring). E.g. : – “idle” to exclude idle time in jobs – “profile” to exclude all profiler functions 1 2
  • 84. Filtering Options - Marker Selection 84 Can also add to include/exclude list via marker right click in marker table 1 2
  • 85. Filtering Options - Threads 85 Thread filtering Including thread aggregation. E.g. ‘All worker threads’ 3 3.
  • 86. Filtering Options - Depth 86 4. Marker call stack depth filtering (E.g. callstack depth 3) 4
  • 87. Filtering Options - Parent 87 5. Limit to markers below a parent Select parent by right clicking on marker table 5
  • 88. 5. Limit to markers below a parent Select parent by right clicking on marker table Filtering Options - Parent 88 5
  • 89. Filtering Options - Self time 89 6. Show ‘self’ marker time (excluding children) or ‘total’ time (including children) Eg. Self time for Camera.Render is small as most of time is in child markers 6
  • 90. Filtering Options 90 7. Select time units to show 8. Select group of marker table columns 9. Indication of marker/thread count for the current filter 8 7 9 8 7
  • 91. Top 10 markers 91 — Top 10 markers for a quick overview – on the median frame
  • 92. Top 10 markers 92 Shows relative ratio of most significant markers — Uses current filter — Typically used with – Main thread – At specific depth slice (E.g. depth 3) – Using the ‘total time’ (I.e. including children)
  • 93. Top 10 markers 93 — Clicking selects the marker — Tooltips show % and ms time
  • 94. Comparison Tab — “Compare” tab – Compare two data sets – Or two areas of a single data set
  • 95. Comparison Tab — Select left/right data to compare – Same filters as single data set – Same visual aids
  • 96. Comparison Tab — Side by side comparisons — Differences shown numerically — And with visual graphs – Tooltips on graphs for details
  • 97. Comparison Table — Bars show data set with longer time – Blue if 1st data set has longer time – Orange if 2nd data set has longer time
  • 98. Comparison Table — If marker only present in one scan – E.g. renamed in new Unity version — Dash ‘-’ shown for missing markers – E.g Material.SetPassUncached not in second data set
  • 99. Comparison top 10 - Normalised — Both data sets scaled to their own median frame time – Quickly see if a system has larger impact
  • 100. Comparison top 10 - Longest — Data sets are scaled to longest frame time – Shows absolute differences
  • 101. Export — Exporting to csv data — For custom processing
  • 102. Export — Marker table contents — Frame duration values – Single – Comparison
  • 104. Export Frame Times Frame Time Comparison
  • 106. Profile Analyzer 106 — Profile Analyzer is a CPU performance analysis tool — Shows numerical values and data visualisations — Numerous filtering options — Allows comparison of two data sets — Export for your own analysis
  • 107. How to get it 107 — Available as a preview package – 2018.4 + — Or download directly – Drop into assets folder – 5.6 + Direct download link (also in main documentation) https://unity.bintray.com/unity/com.unity.performance.profile-analyzer/-/
  • 108. How to get it 108 Show Preview Packages from the ‘Advanced’ menu Select Profile Analyzer (Using 0.5.0 in this presentation)
  • 109. Thank you 109 — Big thank you to all Unity Users who gave valuable feedback – Please continue to give your feedback. We are listening – Use Profiler preview area on the forums : https://forum.unity.com/forums/profiler-previews.199/ – Raise Bug reports
  • 110. Links, Questions? 110 Documentation & Direct Download https://docs.unity3d.com/Packages/com.unity.performance.profile-analyzer@latest/index.htm Feedback forum https://forum.unity.com/forums/profiler-previews.199/ Graphics jobs https://learn.unity.com/tutorial/optimizing-graphics-in-unity#l
  • 112. Useful layout - docked with Profiler 112
  • 113. Marker Median Value 113 Median value is usually on a different frame for each marker. Hover mouse on median to see frame — WaitForJobGroupID 3.44ms on frame 55 — Game.Update 0.37ms on frame 280
  • 114. Check for markers that are called a lot — Sort by count — GC.Alloc has a high call count 114
  • 115. Comparing a range of Representative frames — Use ‘Order by Frame Time’ — Range select a set of frames, around the median point — Selection mirrored/paired on both graphs by default – But can make unique selection on each graph — All stats will be limited to this selection 115
  • 117. ‘Order by Frame Duration’ Shows slower frames align to where GPU bound Cause of slower frames 117
  • 118. Delete this slide before presenting Keep all text within these margins

Editor's Notes

  • #3: My name is Lyndon Homewood I’m a software engineer on Unitys Platforms Performance Team, Our team are working on optimisations across a range of areas within the Unity runtime and Editor We wrote this tool to help us and made it public so you can all use it on your applications
  • #5: Have you ever wanted to know … Have you ever wondered why two unity versions are slower We did internal so we developed this tool
  • #6: What do you do when the frame time data is so noisy How can you identify a representative frame
  • #7: Performance optimisation might be code or data change Why is the outliner frame slower than the median frame?
  • #9: Performance efforts - Can check if CPU or GPU bound Performance optimisation might be code or data change (ADD ORDER BY FRAME TIME VIEW)
  • #10: Developed with Steve Cavanagh, Unity Profiler Team Lead
  • #24: TAKE TIME ON THIS SLIDE FRAME THE USE CASE
  • #26: Disable Build Option “Script Debugging” (because it inserts hooks for debugging) Disable vsync if necessary (why)
  • #33: Views populate on pull/load
  • #42: Profiler captures are not backwards compatible, but profile analyzer .pdata is
  • #43: … if you have previously made a selection Plans to improve selection highlight when package moves out of preview
  • #49: Select Median Frame
  • #50: Using multiple frames smooths noise in the data Excludes outliers Selection maintained when reverting to order by timestamp
  • #51: TAKE TIME ON THIS SLIDE FRAME THE USE CASE
  • #52: On FPS Sample project Enables rendering to run in parallel on multiple cores We are currently CPU bound
  • #53: On FPS Sample project Enables rendering to run in parallel on multiple cores We are currently CPU bound
  • #55: Note max frame time has gone up. There are some spikes.
  • #56: Test on your own projects using the Profile Analyzer
  • #59: Note: We are using ‘Total time’ here. Self time less useful.
  • #60: Note: We are using ‘Total time’ here. Self time less useful. The increased parallelism of work = faster frame time
  • #62: Select directly or use filter to locate WaitForEndOfFrame is another indicator for GPU Bound
  • #63: Aligned with slower frames
  • #64: Use platform specific GPU profiling tools (or Unity frame debugger)
  • #65: Use platform specific GPU profiling tools (or Unity frame debugger)
  • #67: Let’s look at this area in more detail
  • #68: .data or .raw Can also export data here.
  • #69: .data or .raw Can also export data here.
  • #73: Count is shown in the marker table Only the aggregated marker time is used in the profiler analyzer Markers are aggregated over all depths.
  • #74: Frame number is not the same throughout the table
  • #75: Depth is a range Selected marker highlighted in blue
  • #77: 2. Top three shows frames where marker is slowest
  • #87: Benefit of this filter becomes clearer later In comparison view it will automatically match up the depth in old and new version. Old Unity didn’t have the top level player loop
  • #93: In 2018 a new top level marker went in. PlayerLoop
  • #98: Sortable columns as with single view
  • #110: Thank to all Unity staff who gave feedback on the tool Javier, Vicky, Dale and all the DRE’s Everyone on the profiling and performance teams
  • #111: Thank to all Unity staff who gave feedback on the tool Javier, Vicky, Dale and all the DRE’s Everyone on the profiling and performance teams
  • #112: Time for any questions
  • #118: Use platform specific GPU profiling tools (or Unity frame debugger)