Performance Profiling: Difference between revisions
mNo edit summary |
(fixed remoteExec examples) |
||
(59 intermediate revisions by 10 users not shown) | |||
Line 1: | Line 1: | ||
{{TOC|side}} | |||
== Versions with performance profiling == | == Versions with performance profiling == | ||
The '''Profiling build''' is provided in semi regular intervals between major game version updates by {{User|Dedmen}} in tandem with {{arma3}} [[Arma_3:_Steam_Branches|Performance build]]. | |||
The download and changelog can be found in the {{Link|https://forums.bistudio.com/forums/topic/160288-arma-3-stable-server-170-performance-binary-feedback/|BI Forums}} as well as in the {{hl|#perf_prof_branch}} channel in the {{Link|https://discordapp.com/invite/arma|official {{arma3}} Discord server}}. | |||
{{Feature|important| | |||
* Through the nature of a Profiling build (due to additional "measuring"/profiling code), they are not as performant as the normal release builds! | |||
* Performance Profiling works also with the [[Arma 3: Diagnostics Exe|Diagnostics Exe]]. | |||
}} | |||
== How to set up == | |||
{{Feature|important| | |||
* To use the profiling build, you must launch the game with the '''arma3profiling_x64.exe''' (arma3serverprofiling_x64.exe for the server). | |||
* One way is to delete the arma3_x64.exe, and rename the profiling exe to it. This way you can continue to use the [[Arma_3:_Launcher|Arma 3 launcher]] to launch the game with your [[Arma_3:_Startup_Parameters|startup parameters]] (or other third party launcher applications). | |||
* The alternative is to use [https://www.windowscentral.com/how-create-and-run-batch-file-windows-10 batch files] (and copy your [[Arma_3:_Startup_Parameters|startup parameters]] from the top of a [[arma.RPT|rpt log file]] from a regular session). | |||
}} | |||
=== Steam branch === | |||
AUTOMATIC (Recommended) - see also [[Arma_3:_Steam_Branches|Steam Branches]]. | |||
# Open Steam | |||
# Right click on '''Arma 3''' in your Steam Library, then '''Properties''' | |||
# Select the tab '''betas''' | |||
# Finally, use the dropdown list to select the branch '''profiling - Performance Profiling Build''' | |||
# Wait for the download to finish | |||
This will automatically download newest performance and profiling exes once they are available. | |||
=== Google Drive === | |||
MANUAL (only when needed) | |||
# Download and install [https://www.7-zip.org/download.html 7z] (usually the 64-bit Windows x64 variant) | |||
# Open {{Link|https://forums.bistudio.com/forums/topic/160288-arma-3-stable-server-170-performance-binary-feedback/|BI forum thread}} | |||
# Got to latest post with a link to google drive | |||
# Browse to the latest game version and profiling build version folder | |||
# Download the desired exe from the google drive folder (usually the arma3client_x64_profiling_XXX.7z) | |||
# Extract the 7z file and copy the exe to your game folder (usually {{hl|C:\Program Files (x86)\Steam\steamapps\common\Arma 3}}) | |||
[[File:Performance_Profiling_01.png|thumb|diag_captureFrame sample output]] | |||
[[File:Performance_Profiling_02.png|thumb|diag_captureFrame sample output]] | |||
[[File:Performance_Profiling_03.png|thumb|diag_captureFrame sample output]] | |||
== FPS basics == | |||
The duration the engine needs to compute all calculations in one cycle is called a frame. The frame-rate, or frames-per-second (fps), in return states how many cycles the engine could compute for a given second. | |||
{{Feature|important| | |||
The shorter a cycle/frame, the higher the fps. | |||
}} | |||
{{Feature|informative| | |||
Note: One second consists of one thousand [https://en.wikipedia.org/wiki/Millisecond milliseconds]. 1 s <nowiki>=</nowiki> 1000 ms | |||
}} | |||
{| class="wikitable" | |||
|+ FPS to frame duration table | |||
|- | |||
! FPS !! seconds !! milliseconds | |||
|- | |||
| 100 || 0.010 || 10 | |||
|- | |||
| 60 || 0.017 || 17 | |||
|- | |||
| 50 || 0.020 || 20 | |||
|- | |||
| 40 || 0.025 || 25 | |||
|- | |||
| 30 || 0.033 || 33 | |||
|- | |||
| 20 || 0.050 || 50 | |||
|- | |||
| 10 || 0.100 || 100 | |||
|- | |||
| 5 || 0.200 || 200 | |||
|- | |||
| 4 || 0.250 || 250 | |||
|- | |||
| 3 || 0.333 || 333 | |||
|- | |||
| 2 || 0.500 || 500 | |||
|- | |||
| 1 || 1.0 || 1000 | |||
|} | |||
== Duration parameter == | |||
* The duration parameter is a time measured in seconds. 0.3 (seconds) is the same as 300 ms / milliseconds. | |||
* It is used to determine what duration of a frame you consider abnormal or that you are interested in for other reasons. | |||
* The first time such frame happens, the frame information will be captured - or put differently: when a situation occurs with a frame lasting longer than said duration. | |||
* 0.3 (<3 fps for the whole frame) is definitely something you should not see in a normal game. | |||
* If you do not capture any frames with 0.3, try lowering it to 0.2 (200 ms / <5 fps) or 0.1 (100 ms / <10 fps). | |||
* If it triggers "too early" before the main slowdown happens that you want to analyze, increase it to a higher value, e.g. 1.0 for long freeze (<1 fps). | |||
== Scope parameter == | |||
* '''total''' is name for the scope of the duration for the whole frame ('''sLoop''' on a dedicated server). | |||
* With the '''total''' scope you capture more or less your frames per second (fps) - if your current frame-rate is essentially stable. In other words if all frames for that second have roughly similar duration. | |||
* In some situations you may encounter single/few frame lasting mini-freezes - aka one/few frames take rather long to complete (ie 100 ms), yet the rest remains in your normal fps range (20 ms for 50 fps for example). | |||
* Whereas a longer freeze means usually a frame last very long, like a second or longer. Thus the game stalls altogether for the given timeframe. | |||
* The scope parameter now allows you to capture subparts of a frame, of different parts of the engine computation - in general terms like networking, world and unit simulation, AI behavior, sound, rendering and visibility checks. | |||
* The '''total''' scope is also from the '''main thread''' and could be called '''main frame''' - all things the engine has to complete in a cycle. In addition there are other threads, where the engine moves other tasks to be computed alongside. Essentially this is what multi-threading is about, allowing the CPU with multiple cores to compute more things at the same time, and thus to reduce the duration of the main frame. | |||
* With the scope parameter you can capture said subparts from the "main frame", yet also from the so called "worker" threads. | |||
* The names for scopes/subscopes you can get from the diag capture dialog or in the frame capture logging files (.log/.trace). | |||
== How to capture == | |||
=== Client === | |||
==== Current Frame ==== | |||
If you want to capture a snapshot of a current moment, there are a few options: | |||
1. Via [[Arma_3:_Cheats|Arma 3 Cheats]] | |||
# Press {{Controls|Shift|num-}} | |||
# Type {{hl|frame}} | |||
# As result the '''diag capture dialog''' opens | |||
{{Feature|important| | |||
* This is a very rough way to capture the game is running while you are typing. | |||
* Outside multiplier, if you open the pause menu, the simulation for the mission is halted. So when you do a capture in that menu, you only get a capture for the menu simulation. | |||
* You can use the ''frame'' cheat at any point - ie in the main menu or submenus, in the editor, in multiplayer, etc. | |||
}} | |||
2. Via [[Arma 3: Debug Console|Debug Console]] | |||
# Open the console ({{Controls|ESC}} key to open pause menu or {{Controls|Shift|D}} in the [[Category:Eden_Editor|Eden editor]]) | |||
# Execute <sqf inline>diag_captureFrame 1;</sqf> | |||
# As result the '''diag capture dialog''' opens | |||
{{Feature|important| | |||
* This is a very rough way to capture the game is running while you are typing. | |||
* Outside multiplier, if you open the pause menu, the simulation for the mission is halted. So when you do a capture in that menu, you only get a capture for the menu simulation. | |||
* To avoid that, you need to delay the execution until the pause menu is closed again. For example by: <sqf inline>(findDisplay 49) closeDisplay 0; diag_captureFrame 3;</sqf> | |||
* To have the console available in a mission (outside the [[Category:Eden_Editor|Eden editor]]), you need to enable it via the [[Description.ext#enableDebugConsole|description.ext enableDebugConsole parameter]]. | |||
* Alternatively you can enable the console in any missions via mods (see below). | |||
}} | |||
Mods to enable console in any mission: | |||
* [https://steamcommunity.com/sharedfiles/filedetails/?id=2000114984 Enable Debug Console = 1 (Access - ADMIN)] by Mr. Uplay | |||
* [https://steamcommunity.com/sharedfiles/filedetails/?id=2000131738 Enable Debug Console = 2 (Access - ALL)] by Mr. Uplay | |||
* [https://steamcommunity.com/sharedfiles/filedetails/?id=1939811222 enableDebugConsole] by Sams | |||
* [https://steamcommunity.com/sharedfiles/filedetails/?id=1231625987 Debug Console] by R3vo | |||
{{Feature|important| | |||
For dedicated server use, you need to allow the given mod by uploading the respective bikey to the server's keys folder - or disable {{hl|verifySignatures <nowiki>=</nowiki> 0;}} via [[Arma_3:_Server_Config_File|server.cfg]]. | |||
}} | |||
'''Strongly recommended''': Use an enhanced debug console like [https://steamcommunity.com/sharedfiles/filedetails/?id=450814997 CBA_A3] or [https://steamcommunity.com/sharedfiles/filedetails/?id=281032552 DevCon] mod | |||
3. Via custom action | |||
You need to execute in the console the following code first to add the action: | |||
<sqf> | |||
if (!(isNil "temp_diag_captureFrame_action")) then | |||
{ | |||
player removeAction temp_diag_captureFrame_action; | |||
temp_diag_captureFrame_action = nil; | |||
}; | |||
temp_diag_captureFrame_action = player addAction ["<t color='#FF0000'>captureFrame</t>", { diag_captureFrame 1; }]; | |||
</sqf> | |||
To remove the action again: | |||
<sqf> | |||
if (!(isNil "temp_diag_captureFrame_action")) then | |||
{ | |||
player removeAction temp_diag_captureFrame_action; | |||
temp_diag_captureFrame_action = nil; | |||
}; | |||
</sqf> | |||
4. Via mission specific code | |||
# [[Function|Functions]] | |||
# [[Eden_Editor:_Trigger#On_Activation|On Activation]] by [[Eden_Editor:_Trigger|Triggers]] | |||
# [[Eden_Editor:_Object#Attributes|Object init field]] | |||
==== Slow Frame ==== | |||
If you want to capture a snapshot of a slow frame, there are a few options: | |||
1. Via [[Arma_3:_Cheats|Arma 3 Cheats]] | |||
# Press {{Controls|Shift|num-}} | |||
# Type {{hl|sframe}} | |||
# Once the game falls below 30 fps (30 ms / 0.030 (s) duration for for '''total''' scope) the diag capture dialog opens | |||
{{Feature|important| | |||
* This is a very basic way to capture slow frames as the limit is not customizable and only works on the '''total''' scope. For customizable scope and duration use the options below. | |||
* Outside multiplier, if you open the pause menu, the simulation for the mission is halted. So when you do a capture in that menu, you only get a capture for the menu simulation. | |||
* You can use the ''sframe'' cheat at any point - ie in the main menu or submenus, in the editor, in multiplayer, etc. | |||
}} | |||
2. Via [[Arma 3: Debug Console|Debug Console]] | |||
# Open the console ({{Controls|ESC}} key to open pause menu or {{Controls|Shift|D}} in the [[Category:Eden_Editor|Eden editor]]) | |||
# Execute <sqf inline>diag_captureSlowFrame ["total", 0.03];// [scope, duration]</sqf> | |||
# As result the '''diag capture dialog''' opens | |||
{{Feature|important| | |||
* There can be only captureSlowFrame active at the same time. If another is set by the different means, the old one becomes inactive. | |||
* Outside multiplier, if you open the pause menu, the simulation for the mission is halted. So when capture triggers while you are still in that menu, you only get a capture for the menu simulation. | |||
* To avoid that, you need to delay the execution until the pause menu is closed again. For example by: <sqf inline>(findDisplay 49) closeDisplay 0; diag_captureSlowFrame ["total", 0.03, 3];</sqf> | |||
* To have the console available in a mission (outside the [[Category:Eden_Editor|Eden editor]]), you need to enable it via the [[Description.ext#enableDebugConsole|description.ext enableDebugConsole parameter]]. | |||
* Alternatively you can enable the console in any missions via mods (see above). | |||
}} | |||
3. Via custom action | |||
You need to execute in the console the following code first to add the action: | |||
<sqf> | |||
if (!(isNil "temp_diag_captureSlowFrame_action")) then | |||
{ | |||
player removeAction temp_diag_captureSlowFrame_action; | |||
temp_diag_captureSlowFrame_action = nil; | |||
}; | |||
temp_diag_captureSlowFrame_action = player addAction ["<t color='#FF0000'>captureSlowFrame</t>", { diag_captureSlowFrame ["total", 0.03]; }]; | |||
</sqf> | |||
Customize the scope and duration as desired. | |||
To remove the action again: | |||
<sqf> | |||
if (!(isNil "temp_diag_captureSlowFrame_action")) then | |||
{ | |||
player removeAction temp_diag_captureSlowFrame_action; | |||
temp_diag_captureSlowFrame_action = nil; | |||
}; | |||
</sqf> | |||
4. Via mission specific code | |||
== Scripting | # [[Function|Functions]] | ||
# [[Eden_Editor:_Trigger#On_Activation|On Activation]] by [[Eden_Editor:_Trigger|Triggers]] | |||
# [[Eden_Editor:_Object#Attributes|Object init field]] | |||
=== Server === | |||
==== Current Server Frame ==== | |||
If you want to capture a snapshot of a current moment on the server, there are a few options: | |||
1. Via [[Multiplayer_Server_Commands#Performance_Profiling|Admin chat commands]] | |||
# Open the chat window '''by pressing the chat key''' (default {{Controls|/}}). | |||
# Type {{hl|#captureFrame}} | |||
# The current frame '''on the server''' is captured and written to a log file in the same directory as the [[Crash_Files|.rpt file]]. | |||
{{Feature|important| | |||
* You must be [[Arma_3:_Server_Config_File#Logged_In_Admin|logged in as admin]]! | |||
* This is a very rough way to capture the current frame on the server. | |||
* See [[diag_captureFrameToFile]] for more info. | |||
}} | |||
2. Via [[Arma 3: Debug Console|Debug Console]] | |||
# Open the console ({{Controls|ESC}} key to open pause menu) | |||
# Execute <sqf inline>[1] remoteExec ["diag_captureFrame", 2];</sqf> | |||
# As result the '''diag capture dialog''' opens | |||
{{Feature|important| | |||
* This is a very rough way to capture the current frame on the server. | |||
* To have the console available in a mission, you need to enable it via the [[Description.ext#enableDebugConsole|description.ext enableDebugConsole parameter]]. | |||
* Alternatively you can enable the console in any missions via mods (see below). | |||
}} | |||
Mods to enable console in any mission: | |||
* [https://steamcommunity.com/sharedfiles/filedetails/?id=2000114984 Enable Debug Console = 1 (Access - ADMIN)] by Mr. Uplay | |||
* [https://steamcommunity.com/sharedfiles/filedetails/?id=2000131738 Enable Debug Console = 2 (Access - ALL)] by Mr. Uplay | |||
* [https://steamcommunity.com/sharedfiles/filedetails/?id=1939811222 enableDebugConsole] by Sams | |||
* [https://steamcommunity.com/sharedfiles/filedetails/?id=1231625987 Debug Console] by R3vo | |||
{{Feature|important| | |||
For dedicated server use, you need to allow the given mod by uploading the respective bikey to the server's keys folder - or disable {{hl|verifySignatures <nowiki>=</nowiki> 0;}} via [[Arma_3:_Server_Config_File|server.cfg]]. | |||
}} | |||
'''Strongly recommended''': Use an enhanced debug console like [https://steamcommunity.com/sharedfiles/filedetails/?id=450814997 CBA_A3] or [https://steamcommunity.com/sharedfiles/filedetails/?id=281032552 DevCon] mod | |||
3. Via custom action | |||
You need to execute in the console the following code first to add the action: | |||
<sqf> | |||
if (!(isNil "temp_diag_captureFrame_server_action")) then | |||
{ | |||
player removeAction temp_diag_captureFrame_server_action; | |||
temp_diag_captureFrame_server_action = nil; | |||
}; | |||
temp_diag_captureFrame_server_action = player addAction ["<t color='#FF0000'>captureFrame (server)</t>", { [1] remoteExec ["diag_captureFrame", 2]; }]; | |||
</sqf> | |||
To remove the action again: | |||
<sqf> | |||
if (!(isNil "temp_diag_captureFrame_server_action")) then | |||
{ | |||
player removeAction temp_diag_captureFrame_server_action; | |||
temp_diag_captureFrame_server_action = nil; | |||
}; | |||
</sqf> | |||
4. Via mission specific code | |||
# [[Function|Functions]] | |||
# [[Eden_Editor:_Trigger#On_Activation|On Activation]] by [[Eden_Editor:_Trigger|Triggers]] | |||
# [[Eden_Editor:_Object#Attributes|Object init field]] | |||
==== Slow Server Frame ==== | |||
If you want to capture a snapshot of a slow frame on the server, there are a few options: | |||
1. Via [[Multiplayer_Server_Commands#Performance_Profiling|Admin chat commands]] | |||
# Open the chat window '''by pressing the chat key''' (default {{Controls|/}}). | |||
# Type {{hl|#captureSlowFrame sLoop 0.03 0 1}} - parameters ''scope, threshold, frameOffset, numberOfSlowFrames to capture'' | |||
# Captures one frame '''on the server''' if it exceeds the set threshold in seconds for the given scope (30 ms / 0.030 (s) duration for for '''sLoop''' scope) | |||
# The frame information get written to a log file in the same directory as the [[Crash_Files|.rpt file]] | |||
{{Feature|important| | |||
* You must be [[Arma_3:_Server_Config_File#Logged_In_Admin|logged in as admin]]! | |||
* Customize the numberOfSlowFrames as you see fit. | |||
* There can be only captureSlowFrame active at the same time. If another is set by the different means, the old one becomes inactive. | |||
* See [[diag_captureSlowFrame]] for more info. | |||
}} | |||
2. Via [[Arma 3: Debug Console|Debug Console]] | |||
# Open the console ({{Controls|ESC}} key to open pause menu) | |||
# Execute <sqf inline>[["sLoop", 0.03]] remoteExec ["diag_captureSlowFrame", 2]; // [scope, duration]</sqf> | |||
# As result the '''diag capture dialog''' opens | |||
{{Feature|important| | |||
* To have the console available in a mission, you need to enable it via the [[Description.ext#enableDebugConsole|description.ext enableDebugConsole parameter]]. | |||
* Alternatively you can enable the console in any missions via mods (see above). | |||
}} | |||
3. Via custom action | |||
You need to execute in the console the following code first to add the action: | |||
<sqf> | |||
if (!(isNil "temp_diag_captureSlowFrame_server_action")) then | |||
{ | |||
player removeAction temp_diag_captureSlowFrame_server_action; | |||
temp_diag_captureSlowFrame_server_action = nil; | |||
}; | |||
temp_diag_captureSlowFrame_server_action = player addAction ["<t color='#FF0000'>captureSlowFrame (server)</t>", { [["sLoop", 0.03]] remoteExec ["diag_captureSlowFrame", 2]; }]; | |||
</sqf> | |||
Customize the scope and duration as desired. | |||
To remove the action again: | |||
<sqf> | |||
if (!(isNil "temp_diag_captureSlowFrame_server_action")) then | |||
{ | |||
player removeAction temp_diag_captureSlowFrame_server_action; | |||
temp_diag_captureSlowFrame_server_action = nil; | |||
}; | |||
</sqf> | |||
4. Via mission specific code | |||
# [[Function|Functions]] | |||
# [[Eden_Editor:_Trigger#On_Activation|On Activation]] by [[Eden_Editor:_Trigger|Triggers]] | |||
# [[Eden_Editor:_Object#Attributes|Object init field]] | |||
== Storing a capture to file == | |||
To export the gathered information of a capture for later analysis/review or to share it with others, you have the following options: | |||
=== Diag capture dialog === | |||
# Press the '''Copy All''' button | |||
# Open an external text editor | |||
# Paste the text into a new text/log file | |||
# Save the file (as .txt or .log) | |||
{{Feature|informative| | |||
Standard naming is: '''captureFrame-DATE_TIME.log''' - like {{hl|captureFrame-17452-2024-11-21_18-12-37.211027.log}} | |||
}} | |||
{{Feature|important| | |||
As alternative if you hold {{Controls|shift}} while pressing the '''Copy All''' button, it will automatically store the capture to both '''.log''' and '''.trace''' format in the [[arma.RPT|rpt log]] folder. | |||
}} | |||
=== diag_captureSlowFrame === | |||
The sqf command <sqf inline>diag_captureSlowFrame</sqf> has the [[boolean]] '''toFile''' as forth parameter. In addition with the [[Number]] '''continuousCounter''' as fifth parameter you can make it log multiple captures in one go. | |||
<syntaxhighlight lang="cpp"> | |||
[section, threshold, frameSkip, toFile, continuousCounter] | |||
</syntaxhighlight> | |||
* Client: <sqf inline>diag_captureSlowFrame ["total", 0.03, 0, true, 1];</sqf> | |||
* Server: <sqf inline>[["total", 0.03, 0, true, 1]] remoteExec ["diag_captureSlowFrame", 2];</sqf> | |||
=== Dedicated server === | |||
The [[Multiplayer_Server_Commands#Performance_Profiling|Admin chat commands]] {{hl|#captureFrame}} / {{hl|#captureSlowFrame sLoop 0}} will automatically create both '''.log''' and '''.trace''' format files on the server in the [[arma.RPT|rpt log]] folder. See above server section for more information. | |||
For customized server side logging use the '''remoteExec approach''' or '''console with remote/target execution'''. | |||
== How to view a capture == | |||
TODO | |||
=== Ingame === | |||
# In the window you will be able to browse a lot of performance-related data, which can be interesting | |||
TODO | |||
=== Externally === | |||
TODO | |||
== Scripting Commands == | |||
* [[diag_captureFrame]] | * [[diag_captureFrame]] | ||
* [[diag_captureSlowFrame]] | * [[diag_captureSlowFrame]] | ||
* [[diag_logSlowFrame]] | * [[diag_logSlowFrame]] - not available in Arma 3. Since {{GVI|arma3|2.20}} [[diag_captureSlowFrame]] with '''toFile''' parameter can log to file as alternative. | ||
* [[diag_captureFrameToFile]] | |||
[[File:Performance_Profiling_04.png|thumb|diag_captureFrame sample output with custom subtree]] | |||
== Creating Your Own Subtree == | |||
When Profiling Per-Frame Eventhandlers (PFH), [[diag_captureFrame]] only shows one blob called siFEH that contains all PFH's so you can't see what part of that is caused by your PFH.<br> | |||
You can create your own subtree inside siFEH by wrapping your function call inside a [[isNil]] CODE statement like this:<br> | |||
Turn your old call which may look like this: | |||
<sqf> | |||
addMissionEventHandler ["EachFrame", { | |||
call myPFHFunction | |||
}]; | |||
</sqf> | |||
Into something like this: | |||
<sqf> | |||
addMissionEventHandler ["EachFrame", { | |||
isNil { call myPFHFunction } // isNil creates the subtree | |||
}]; | |||
</sqf> | |||
Now when you run [[diag_captureFrame]] inside of siPFH you will have a subtree called gsEva and behind that you can see the first line of code inside the isNil statement.<br> | |||
It will only show a part of the first line of that code so you should put something descriptive into the [[isNil]] statement.<br> | |||
You can use the same to create a subtree for any function you like. This will also work inside [[Scheduler#Scheduled_Environment|Scheduled]] ([[spawn]]ed) scripts. <br> | |||
But using this method to "subtree" a function with return values requires a little bit of trickery to get the return value out. | |||
== | == See Also == | ||
* | * [[Code Optimisation]] | ||
* | * [[Mission Optimisation]] | ||
[[Category:Arma Scripting Tutorials]] |
Latest revision as of 14:17, 24 November 2024
Versions with performance profiling
The Profiling build is provided in semi regular intervals between major game version updates by Dedmen in tandem with Arma 3 Performance build.
The download and changelog can be found in the BI Forums as well as in the #perf_prof_branch channel in the official Arma 3 Discord server.
How to set up
Steam branch
AUTOMATIC (Recommended) - see also Steam Branches.
- Open Steam
- Right click on Arma 3 in your Steam Library, then Properties
- Select the tab betas
- Finally, use the dropdown list to select the branch profiling - Performance Profiling Build
- Wait for the download to finish
This will automatically download newest performance and profiling exes once they are available.
Google Drive
MANUAL (only when needed)
- Download and install 7z (usually the 64-bit Windows x64 variant)
- Open BI forum thread
- Got to latest post with a link to google drive
- Browse to the latest game version and profiling build version folder
- Download the desired exe from the google drive folder (usually the arma3client_x64_profiling_XXX.7z)
- Extract the 7z file and copy the exe to your game folder (usually C:
\Program Files (x86) \Steam \steamapps \common \Arma 3)
FPS basics
The duration the engine needs to compute all calculations in one cycle is called a frame. The frame-rate, or frames-per-second (fps), in return states how many cycles the engine could compute for a given second.
FPS | seconds | milliseconds |
---|---|---|
100 | 0.010 | 10 |
60 | 0.017 | 17 |
50 | 0.020 | 20 |
40 | 0.025 | 25 |
30 | 0.033 | 33 |
20 | 0.050 | 50 |
10 | 0.100 | 100 |
5 | 0.200 | 200 |
4 | 0.250 | 250 |
3 | 0.333 | 333 |
2 | 0.500 | 500 |
1 | 1.0 | 1000 |
Duration parameter
- The duration parameter is a time measured in seconds. 0.3 (seconds) is the same as 300 ms / milliseconds.
- It is used to determine what duration of a frame you consider abnormal or that you are interested in for other reasons.
- The first time such frame happens, the frame information will be captured - or put differently: when a situation occurs with a frame lasting longer than said duration.
- 0.3 (<3 fps for the whole frame) is definitely something you should not see in a normal game.
- If you do not capture any frames with 0.3, try lowering it to 0.2 (200 ms / <5 fps) or 0.1 (100 ms / <10 fps).
- If it triggers "too early" before the main slowdown happens that you want to analyze, increase it to a higher value, e.g. 1.0 for long freeze (<1 fps).
Scope parameter
- total is name for the scope of the duration for the whole frame (sLoop on a dedicated server).
- With the total scope you capture more or less your frames per second (fps) - if your current frame-rate is essentially stable. In other words if all frames for that second have roughly similar duration.
- In some situations you may encounter single/few frame lasting mini-freezes - aka one/few frames take rather long to complete (ie 100 ms), yet the rest remains in your normal fps range (20 ms for 50 fps for example).
- Whereas a longer freeze means usually a frame last very long, like a second or longer. Thus the game stalls altogether for the given timeframe.
- The scope parameter now allows you to capture subparts of a frame, of different parts of the engine computation - in general terms like networking, world and unit simulation, AI behavior, sound, rendering and visibility checks.
- The total scope is also from the main thread and could be called main frame - all things the engine has to complete in a cycle. In addition there are other threads, where the engine moves other tasks to be computed alongside. Essentially this is what multi-threading is about, allowing the CPU with multiple cores to compute more things at the same time, and thus to reduce the duration of the main frame.
- With the scope parameter you can capture said subparts from the "main frame", yet also from the so called "worker" threads.
- The names for scopes/subscopes you can get from the diag capture dialog or in the frame capture logging files (.log/.trace).
How to capture
Client
Current Frame
If you want to capture a snapshot of a current moment, there are a few options:
1. Via Arma 3 Cheats
- Press ⇧ Shift + NUM -
- Type frame
- As result the diag capture dialog opens
2. Via Debug Console
- Open the console (ESC key to open pause menu or ⇧ Shift + D in the)
- Execute diag_captureFrame 1;
- As result the diag capture dialog opens
Mods to enable console in any mission:
- Enable Debug Console = 1 (Access - ADMIN) by Mr. Uplay
- Enable Debug Console = 2 (Access - ALL) by Mr. Uplay
- enableDebugConsole by Sams
- Debug Console by R3vo
Strongly recommended: Use an enhanced debug console like CBA_A3 or DevCon mod
3. Via custom action
You need to execute in the console the following code first to add the action:
To remove the action again:
4. Via mission specific code
Slow Frame
If you want to capture a snapshot of a slow frame, there are a few options:
1. Via Arma 3 Cheats
- Press ⇧ Shift + NUM -
- Type sframe
- Once the game falls below 30 fps (30 ms / 0.030 (s) duration for for total scope) the diag capture dialog opens
2. Via Debug Console
- Open the console (ESC key to open pause menu or ⇧ Shift + D in the)
- Execute diag_captureSlowFrame ["total", 0.03];// [scope, duration]
- As result the diag capture dialog opens
3. Via custom action
You need to execute in the console the following code first to add the action:
Customize the scope and duration as desired.
To remove the action again:
4. Via mission specific code
Server
Current Server Frame
If you want to capture a snapshot of a current moment on the server, there are a few options:
1. Via Admin chat commands
- Open the chat window by pressing the chat key (default /).
- Type #captureFrame
- The current frame on the server is captured and written to a log file in the same directory as the .rpt file.
2. Via Debug Console
- Open the console (ESC key to open pause menu)
- Execute [1] remoteExec ["diag_captureFrame", 2];
- As result the diag capture dialog opens
Mods to enable console in any mission:
- Enable Debug Console = 1 (Access - ADMIN) by Mr. Uplay
- Enable Debug Console = 2 (Access - ALL) by Mr. Uplay
- enableDebugConsole by Sams
- Debug Console by R3vo
Strongly recommended: Use an enhanced debug console like CBA_A3 or DevCon mod
3. Via custom action
You need to execute in the console the following code first to add the action:
To remove the action again:
4. Via mission specific code
Slow Server Frame
If you want to capture a snapshot of a slow frame on the server, there are a few options:
1. Via Admin chat commands
- Open the chat window by pressing the chat key (default /).
- Type #captureSlowFrame sLoop 0.03 0 1 - parameters scope, threshold, frameOffset, numberOfSlowFrames to capture
- Captures one frame on the server if it exceeds the set threshold in seconds for the given scope (30 ms / 0.030 (s) duration for for sLoop scope)
- The frame information get written to a log file in the same directory as the .rpt file
2. Via Debug Console
- Open the console (ESC key to open pause menu)
- Execute [["sLoop", 0.03]] remoteExec ["diag_captureSlowFrame", 2]; // [scope, duration]
- As result the diag capture dialog opens
3. Via custom action
You need to execute in the console the following code first to add the action:
Customize the scope and duration as desired.
To remove the action again:
4. Via mission specific code
Storing a capture to file
To export the gathered information of a capture for later analysis/review or to share it with others, you have the following options:
Diag capture dialog
- Press the Copy All button
- Open an external text editor
- Paste the text into a new text/log file
- Save the file (as .txt or .log)
diag_captureSlowFrame
The sqf command diag_captureSlowFrame has the boolean toFile as forth parameter. In addition with the Number continuousCounter as fifth parameter you can make it log multiple captures in one go.
[section, threshold, frameSkip, toFile, continuousCounter]
- Client: diag_captureSlowFrame ["total", 0.03, 0, true, 1];
- Server: [["total", 0.03, 0, true, 1]] remoteExec ["diag_captureSlowFrame", 2];
Dedicated server
The Admin chat commands #captureFrame / #captureSlowFrame sLoop 0 will automatically create both .log and .trace format files on the server in the rpt log folder. See above server section for more information.
For customized server side logging use the remoteExec approach or console with remote/target execution.
How to view a capture
TODO
Ingame
- In the window you will be able to browse a lot of performance-related data, which can be interesting
TODO
Externally
TODO
Scripting Commands
- diag_captureFrame
- diag_captureSlowFrame
- diag_logSlowFrame - not available in Arma 3. Since 2.20 diag_captureSlowFrame with toFile parameter can log to file as alternative.
- diag_captureFrameToFile
Creating Your Own Subtree
When Profiling Per-Frame Eventhandlers (PFH), diag_captureFrame only shows one blob called siFEH that contains all PFH's so you can't see what part of that is caused by your PFH.
You can create your own subtree inside siFEH by wrapping your function call inside a isNil CODE statement like this:
Turn your old call which may look like this:
Into something like this:
Now when you run diag_captureFrame inside of siPFH you will have a subtree called gsEva and behind that you can see the first line of code inside the isNil statement.
It will only show a part of the first line of that code so you should put something descriptive into the isNil statement.
You can use the same to create a subtree for any function you like. This will also work inside Scheduled (spawned) scripts.
But using this method to "subtree" a function with return values requires a little bit of trickery to get the return value out.