Mission Optimisation: Difference between revisions
Lou Montana (talk | contribs) m (Some wiki formatting) |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 18: | Line 18: | ||
** {{Link|https://www.moddb.com/forum/thread/arma-2-ultimate-tweak-thread|{{arma2}} performance guide}} | ** {{Link|https://www.moddb.com/forum/thread/arma-2-ultimate-tweak-thread|{{arma2}} performance guide}} | ||
** {{Link|https://forums.bohemia.net/forums/topic/50167-pc-optimization-for-arma/|{{arma1}} performance guide}}<!-- | ** {{Link|https://forums.bohemia.net/forums/topic/50167-pc-optimization-for-arma/|{{arma1}} performance guide}}<!-- | ||
** | ** {{Link|{{ofp}} performance guide}} | ||
--> | --> | ||
* 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. | * 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. | ||
Line 28: | Line 28: | ||
== | == Mission Creation == | ||
* Be sure to create your scripts with the latest available commands and functions. | * Be sure to create your scripts with the latest available commands and functions. | ||
Line 37: | Line 37: | ||
** [[Arma 3: Revive]] | ** [[Arma 3: Revive]] | ||
** [[Arma 3: Task Framework]] | ** [[Arma 3: Task Framework]] | ||
** [[Arma 3 Animated Briefing]] | ** [[Arma 3: Animated Briefing]] | ||
** [[Arma 3 Animated Opening]] | ** [[Arma 3: Animated Opening]] | ||
** [[Arma 3: Dynamic Groups]] | ** [[Arma 3: Dynamic Groups]] | ||
** [[Arma 3 Key Frame Animation]] | ** [[Arma 3: Key Frame Animation]] | ||
** and most importantly: [[Functions]] | ** and most importantly: [[Functions]] | ||
Line 46: | Line 46: | ||
== Performance Impact Table == | == Performance Impact Table == | ||
{{Feature| | {{Feature|informative| | ||
: {{Colorball|red|1.125}} means a heavy impact on performance<br> | : {{Colorball|red|1.125}} means a heavy impact on performance<br> | ||
: {{Colorball|orange|1.125}} means an average impact<br> | : {{Colorball|orange|1.125}} means an average impact<br> | ||
Line 67: | Line 67: | ||
* Use [[createAgent|Agents]] whenever possible | * Use [[createAgent|Agents]] whenever possible | ||
* The more units there are, the more network updates there will be - hence the impact on both CPU and network. | * The more units there are, the more network updates there will be - hence the impact on both CPU and network. | ||
* If a client has a low-end machine, they | * If a client has a low-end machine, they should not lead a group of many AIs as these would then be locally computed. | ||
* [[Arma 3: Dynamic Simulation]] allows you to freeze AI that are distant from players. Many distance settings should be set according to the mission. | * [[Arma 3: Dynamic Simulation]] allows you to freeze AI that are distant from players. Many distance settings should be set according to the mission. | ||
{{ Feature | | {{Feature|informative|If you own more than one average computer, you could consider [[Arma 3: Headless Client|Headless client]] to offload AI from the server.}} | ||
|- | |- | ||
| | | | ||
Line 83: | Line 83: | ||
** headgear, clothing, vests, backpacks | ** headgear, clothing, vests, backpacks | ||
** head-mounted devices (NVGs, etc.) | ** head-mounted devices (NVGs, etc.) | ||
* Lower [[viewDistance]] | * Lower [[viewDistance|view distance]] | ||
* Lower [[setTerrainGrid| terrain details]] | * Lower [[setTerrainGrid|terrain details]] | ||
* Lower the [[Arma 3 Dynamic Simulation|Dynamic Simulation]] | * Lower the [[Arma 3: Dynamic Simulation|Dynamic Simulation]] threshold | ||
* Use [[Arma 3 Simple Objects|Simple Objects]] | * Use [[Arma 3: Simple Objects|Simple Objects]] | ||
* Use '''Garbage Collection''' in order to automatically delete bodies and wreckages: | * Use '''Garbage Collection''' in order to automatically delete bodies and wreckages: | ||
** {{arma3}}'s Eden-integrated [[Description.ext# | ** {{arma3}}'s Eden-integrated [[Description.ext#Corpse .26 wreck management|Garbage Collection]] | ||
** {{arma2}}'s [[Garbage Collector]] | ** {{arma2}}'s [[Garbage Collector]] | ||
** {{tkoh}}'s [[BIS_fnc_GC]] | ** {{tkoh}}'s [[BIS_fnc_GC]] | ||
{{ Feature | | {{Feature|informative|Only the ''on-screen'' objects will strongly impact the GPU.}} | ||
|- | |- | ||
| | | | ||
Line 100: | Line 100: | ||
| 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: | * 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:<!-- | ||
--><sqf> | --><sqf> | ||
Line 114: | Line 114: | ||
private _myScript = compile preprocessFileLineNumbers "myScript.sqf"; | private _myScript = compile preprocessFileLineNumbers "myScript.sqf"; | ||
while { sleep 5; alive player } do { player spawn _myScript; }; // | while { sleep 5; alive player } do { player spawn _myScript; }; // better | ||
while { sleep 5; alive player } do { player spawn TAG_fnc_myScript; }; // perfect! see [[Arma 3: Functions Library|Functions]] | |||
</sqf> | </sqf> | ||
|- | |- | ||
Line 125: | Line 127: | ||
* A [[while]]-loop checking without a minimum loop-[[sleep]] time is usually a sign of bad conception.<!-- | * A [[while]]-loop checking without a minimum loop-[[sleep]] time is usually a sign of bad conception.<!-- | ||
--><sqf> | --><sqf> | ||
while { true } // bad if you | while { true } // bad if you do not know what you are doing | ||
while { alive player } // better | while { alive player } // better | ||
while { sleep 1 ; alive player } // perfect | while { sleep 1 ; alive player } // perfect | ||
</sqf> | </sqf> | ||
* By default, [[Trigger]]s check their set condition '''every 0.5 second'''. If a large area is covered or condition code is too complex, this can become an issue; the triggers should then be converted to scripts if possible. Since {{GVI|arma3|2.00}} it is possible to change trigger intervals, either via [[ | * By default, [[Trigger]]s check their set condition '''every 0.5 second'''. If a large area is covered or condition code is too complex, this can become an issue; the triggers should then be converted to scripts if possible. Since {{GVI|arma3|2.00}} it is possible to change trigger intervals, either via [[Eden Editor: Entity Attributes|trigger attributes]] in [[:Category:Eden Editor|3DEN]], or via the scripting command [[setTriggerInterval]]. | ||
* [[Trigger]]s can be made '''Server-Side only''' to save clients' resources. | * [[Trigger]]s can be made '''Server-Side only''' to save clients' resources. | ||
{{Feature | important | All of the mission-related calculation (objectives, completion distance, etc.) must be done '''server-side'''. Local effects should be calculated '''client-side'''.}} | {{Feature | important | All of the mission-related calculation (objectives, completion distance, etc.) must be done '''server-side'''. Local effects should be calculated '''client-side'''.}} | ||
Line 151: | Line 153: | ||
| {{Colorball|green}} | | {{Colorball|green}} | ||
| {{Colorball|green}} | | {{Colorball|green}} | ||
| [[Scheduler# | | [[Scheduler#Unscheduled Environment|Unscheduled code]] can have a high impact on the framerate, as such code is not subject to the [[Scheduler|scheduler]]'s management (as its name suggests) and will run without limitation. Cyclic unscheduled low-performance code can make the game unplayable, up to freezing it. | ||
* As only time-critical scripts should run unscheduled, [[spawn]] any other code from unscheduled environment once you have the required results:<!-- | * As only time-critical scripts should run unscheduled, [[spawn]] any other code from unscheduled environment once you have the required results:<!-- | ||
--><sqf> | --><sqf> | ||
Line 158: | Line 160: | ||
/* ... */ // other unscheduled code | /* ... */ // other unscheduled code | ||
</sqf> | </sqf> | ||
{{ Feature | | {{Feature|informative|See also {{Link|Scheduler#Where code starts unscheduled}}.}} | ||
|} | |} | ||
== What | == What Else? == | ||
If you have applied all these recommendations and your mission still | If you have applied all these recommendations and your mission still does not 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. | it might be caused by '''mods''' that you are running which could be badly, or not at all, optimised. | ||
Line 170: | Line 172: | ||
== Performance Diagnostic | == Performance Diagnostic Tools == | ||
=== Server Commands === | === Server Commands === | ||
Line 179: | Line 181: | ||
** Shows performance information in the dedicated server console. Interval 0 means to stop monitoring. (since {{arma3}} v1.64) | ** Shows performance information in the dedicated server console. Interval 0 means to stop monitoring. (since {{arma3}} v1.64) | ||
=== Diagnostic | === Diagnostic Commands === | ||
* [[:Category: | |||
* [[:Category: | * [[:Category:Arma 3: Scripting Commands: Diagnostic Branch|Diag. commands only available in Diagnostic Branch]] | ||
* [[:Category:Command Group: Diagnostic|Diag. command available in all builds]] | |||
Line 190: | Line 193: | ||
* [[Code Best Practices]] | * [[Code Best Practices]] | ||
* [[Performance Profiling]] | * [[Performance Profiling]] | ||
* [[User:Dedmen|Dedmen]]'s [[ArmaScriptProfiler]] ({{Link| | * [[User:Dedmen|Dedmen]]'s [[ArmaScriptProfiler]] ({{Link|https://forums.bohemia.net/forums/topic/211626-arma-script-profiler/|forum post}}) | ||
[[Category:Arma Scripting Tutorials]] | [[Category:Arma Scripting Tutorials]] |
Latest revision as of 23:33, 20 May 2025
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 on this page a magical solution that makes it possible to run thousands of AI at 240 FPS.
Everything comes at a cost, the tweaks here will simply allow you to locate issues and calibrate your mission properly.
Before Anything
Before optimising anything, make sure you do not have any performance issue running the game itself:
- Read Arma 3: Performance Optimisation
- 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.
Mission Creation
- 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 Arma 2: 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 |
| |||
Object quantity |
The less objects, the more FPS you will have.
| |||
General script mistakes |
Having too many scripts running is a cause for severe performance issues and execution delays in singleplayer as well as multiplayer.
| |||
High-frequency scripts |
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 |
| |||
Unscheduled code |
Unscheduled code can have a high impact on the framerate, as such code is not subject to the scheduler's management (as its name suggests) and will run without limitation. Cyclic unscheduled low-performance code can make the game unplayable, up to freezing it. |
What Else?
If you have applied all these recommendations and your mission still does not 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.
Performance Diagnostic Tools
Server Commands
- #monitor 5
- Shows performance information of the server. Interval 0 means to stop monitoring.
- #monitords 5
- Shows performance information in the dedicated server console. Interval 0 means to stop monitoring. (since Arma 3 v1.64)
Diagnostic Commands