Mission Optimisation: Difference between revisions
Lou Montana (talk | contribs) (Add "General script mistakes" category) |
Lou Montana (talk | contribs) m (Add more diag_* commands) |
||
Line 11: | Line 11: | ||
Before optimising anything, make sure you do not have any performance issue running the game itself: | Before optimising anything, make sure you do not have any performance issue running the game itself: | ||
* Open the editor, place a unit in the area you like and test your computer. | * Open the editor, place a unit in the area you like and test your computer. | ||
** {{arma3}} | ** You can get current FPS in {{arma3}} by going into '''video options''' or using [[diag_fps]] | ||
** '''Steam''' allows you to display FPS in a screen corner, in ''Settings > In game > FPS Counter'' | ** '''Steam''' allows you to display FPS in a screen corner, in ''Settings > In game > FPS Counter'' | ||
* Use (unofficial) Performance Guides to get better performances: | * Use (unofficial) Performance Guides to get better performances: | ||
Line 97: | Line 97: | ||
| {{colorball|green}} | | {{colorball|green}} | ||
| Having too many scripts running is a cause for severe performance issues and execution delays in singleplayer as well as multiplayer. | | Having too many scripts running is a cause for severe performance issues and execution delays in singleplayer as well as multiplayer. | ||
* You can track the number of running scripts using [[diag_activeScripts]]; you can also use: | |||
** [[diag activeSQFScripts]] | |||
** [[diag activeSQSScripts]] | |||
** [[diag activeMissionFSMs]] | |||
* A common bad practice is to [[spawn]] a function for each units that need it; the good practice would be to have a single script working with an array of units, array that is edited (unit added/removed) whenever needed:<!-- | * A common bad practice is to [[spawn]] a function for each units that need it; the good practice would be to have a single script working with an array of units, array that is edited (unit added/removed) whenever needed:<!-- | ||
--><code>{ [[_x]] [[spawn]] _myCode; } [[forEach]] _units; {{codecomment|// bad}}<br><!-- | --><code>{ [[_x]] [[spawn]] _myCode; } [[forEach]] _units; {{codecomment|// bad}}<br><!-- | ||
-->_units [[spawn]] _myCode; {{codecomment|// good}}</code><!-- | -->_units [[spawn]] _myCode; {{codecomment|// good}}</code><!-- | ||
-->You can use [[ | -->You can use [[diag_activeSQFScripts]] to ensure you are not clogging your CPU with multiple instances of the same script. | ||
* ''Not compiling:''' running multiple times the same script with [[execVM]] will make the game read the file every single time; This is an issue, especially if you execute it frequently.<br><!-- | * '''Not compiling your scripts:''' running multiple times the same script with [[execVM]] will make the game read the file every single time; This is an issue, especially if you execute it frequently.<br><!-- | ||
--><code>[[while]] { [[sleep]] 5; [[alive]] [[player]] } [[do]] { [[player]] [[execVM]] "myScript.sqf"; }; {{codecomment|// bad}}<br><br><!-- | --><code>[[while]] { [[sleep]] 5; [[alive]] [[player]] } [[do]] { [[player]] [[execVM]] "myScript.sqf"; }; {{codecomment|// bad}}<br><br><!-- | ||
-->[[private]] _myScript = [[compile]] [[preprocessFileLineNumbers]] "myScript.sqf";<br><!-- | -->[[private]] _myScript = [[compile]] [[preprocessFileLineNumbers]] "myScript.sqf";<br><!-- |
Revision as of 14:13, 30 June 2019
Introduction
This article will try to be a general guide about improving your mission's performance.
As usual, moderation is the key; do not expect to find a magical solution that makes it possible to run thousands of AI at 144 FPS on this page. Everything comes at a cost, the tweaks on this page will simply allow you to calibrate your mission properly.
Before anything
Before optimising anything, make sure you do not have any performance issue running the game itself:
- Open the editor, place a unit in the area you like and test your computer.
- You can get current FPS in Arma 3 by going into video options or using diag_fps
- Steam allows you to display FPS in a screen corner, in Settings > In game > FPS Counter
- Use (unofficial) Performance Guides to get better performances:
- Play your mission in singleplayer. If your mission runs fine, its network messages might very well be the issue. See Multiplayer Scripting for good practice tips.
- Usual bottlenecks:
- Lower your graphical settings (resolution, textures). If you get way better performances, at least your GPU limits you.
- If the game keeps having low FPS when running @ 1024×768/low textures then your CPU is most likely the issue. Mission scripts may be performance-hogging too.
Creating your mission
- Be sure to create your scripts with the latest available commands and functions.
- In Arma 3 use remoteExec / remoteExecCall and DITCH BIS_fnc_MP FOR GOOD! See Arma 3 Remote Execution for more information.
- In Arma 2 network communication is done using the Multiplayer framework.
- Use the available frameworks and functions for each topic, unless you replace them by third-party ones:
Performance impact table
Topic | CPU | GPU | Net- work |
Solution |
---|---|---|---|---|
AI unit quantity |
Template:colorball | Template:colorball | Template:colorball |
|
Object quantity |
Template:colorball | Template:colorball | Template:colorball | The less objects, the more FPS you will have.
|
General script mistakes |
Template:colorball | Template:colorball | Template:colorball | Having too many scripts running is a cause for severe performance issues and execution delays in singleplayer as well as multiplayer.
|
High-frequency scripts |
Template:colorball | Template:colorball | Template:colorball | Checking a condition too often is usually a source of poor performance. Does your code execution need to be frame-perfect, or can you afford a delay of a few seconds?
|
High-frequency network messages |
Template:colorball | Template:colorball | Template:colorball |
|
What else?
If you have applied all these recommendations and your mission still doesn't run well in multiplayer (but does in singleplayer), it might be caused by mods that you are running which could be badly, or not at all, optimised.
If you want to be sure, run the same mission with and without mods. If you have a big difference in performance, look no further.