Lou Montana/Sandbox – User

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Add frameworks, table, and mods advice)
Line 2: Line 2:
== Introduction ==
== Introduction ==


This article will try to be a general guide about improving your '''mission's''' code '''and''' its performance.
This article will try to be a general guide about improving your '''mission's''' code '''and''' its performance.<br>
As usual, moderation is the key so do not expect to have thousands of AI magically running 144 FPS. Everything comes at a cost, the tweaks on this page will simply allow you to calibrate your mission properly.
{{ Informative | This page is about [[Mission Optimisation]]. For ''scripting'' optimisation, see [[Code Optimisation]]. }}
{{ Informative | This page is about [[Mission Optimisation]]. For ''scripting'' optimisation, see [[Code Optimisation]]. }}
{{ Informative | '''See also [[Multiplayer Scripting]]'''. }}
{{ Informative | '''See also [[Multiplayer Scripting]]'''. }}




== Creating your mission ==
== Before anything ==


* Be sure to create your scripts with the latest available commands.
Before optimising anything, make sure you do not have any performance issue running the game itself:
** In {{arma3}} '''DITCH [[BIS_fnc_MP]] FOR GOOD''' and use [[remoteExec]]&nbsp;/&nbsp;[[remoteExecCall]] instead! See [[Arma 3 Remote Execution]].
* Open the editor, place a unit in the area you like and test your computer.
** In {{arma2}} '''ONLY''' use the [[Multiplayer framework]].
** {{arma3}} displays FPS when you go into '''video options'''
* Use the available frameworks
** '''Steam''' allows you to display FPS in a screen corner, in ''Settings &gt; In game &gt; FPS Counter''
** [[Arma 3 Task Framework]]
* Use (unofficial) Performance Guides to get better performances:
<!--
** [https://steamcommunity.com/sharedfiles/filedetails/?id=1731305438      {{arma3}} performance guide]
== Improving without breaking ==
** [https://www.moddb.com/forum/thread/arma-2-ultimate-tweak-thread        {{arma2}} performance guide]
-->
** [https://forums.bohemia.net/forums/topic/50167-pc-optimization-for-arma/ {{arma}}  performance guide]<!--
** [ {{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.
* 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.
{{ Important | Please note that [[viewDistance]] (among other settings) impacts both GPU and CPU! }}


== ''Moar FPS!!1!'' ==


* AI will eat their host's CPU:
== Creating your mission ==
** Use agents whenever possible
** If a client has a low-end machine, they shouldn't 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 Simple Objects|Simple Objects]]
* Less objects = more FPS
** Less mission objects
** Less weapon items / HMD / backpacks = less proxies (item position is calculated)
** Delete dead bodies / wreckages
* [[viewDistance|View distance]]
* Triggers check their condition every 0.5 second (hardcoded value). If you don't need such precision, use a [[while]]-loop script.


{{ Informative | Most if not all of the '''mission''' calculation (objectives, completion distance, etc.) must be done '''server-side'''. Local effects should be calculated '''client-side'''. }}
* Be sure to create your scripts with the latest available commands and functions.
** In {{arma3}} use [[remoteExec]]&nbsp;/&nbsp;[[remoteExecCall]] and '''DITCH [[BIS_fnc_MP]] FOR GOOD!''' See [[Arma 3 Remote Execution]] for more information.
** In {{arma2}} 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:
** [[Arma 3 Respawn]]
** [[Arma 3 Revive]]
** [[Arma 3 Task Framework]]
** [[Arma 3 Animated Briefing]]
** [[Arma 3 Animated Opening]]
** [[Arma 3 Dynamic Groups]]
** [[Arma 3 Key Frame Animation]]
** and most importantly: [[Functions]]


=== Server-side FPS ===
* The server should be considered as a powerful machine from a scripting point of view; .
* If you own more than one average computers, you could consider [[Arma 3 Headless Client|Headless client]] and coding accordingly.


=== Client-side FPS ===
== Performance impact table ==


==== Script optimisation ====
{|class="bikitable"
* Don't [[publicVariable]] at a high rate
! Topic
* Don't spawn many objects
! CPU
* Client [[viewDistance|view distance]] can be set separately from the server's value through scripting. This can make or break performance for the client.
! GPU
 
! Net-<br>work
==== Configuration optimisation ====
! Solution
* If the client has issues playing in singleplayer, it is most likely that his hardware configuration is not up to the game's current settings, and will encounter even more issues in multiplayer.
|-
|
==== AI units quantity ====
| {{colorball|red}}
| {{colorball|green}}
| {{colorball|orange}}
|
* Use [[createAgent|Agents]] whenever possible
* If a client has a low-end machine, they shouldn't 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.
{{ Important | Most if not all of the mission calculation (objectives, completion distance, etc.) must be done '''server-side'''. Local effects should be calculated '''client-side'''. }}
{{ Informative |  If you own more than one average computers, you could consider [[Arma 3 Headless Client|Headless client]] and code accordingly. }}
|-
|
==== Objects quantity ====
| {{colorball|orange}}
| {{colorball|orange}}
| {{colorball|orange}}
| The less objects, the more FPS you will have.
* Lower the mission objects quantity
** AI units, agents
** vehicles, simple objects
** weapon attachments (their proxies are [[attachedTo]])
** headgear, clothing, vests, backpacks
** head-mounted devices (NVGs, etc.)
* Lower [[viewDistance]]
* Lower terrain details
* Lower the [[Arma 3 Dynamic Simulation|Dynamic Simulation]] treshold
* Use [[Arma 3 Simple Objects|Simple Objects]]
* Use '''Garbage Collection''' in order to automatically delete bodies and wreckages:
** {{arma3}}'s Eden-integrated [[Description.ext#Corpse_.26_wreck_management|Garbage Collection]]
** {{arma2}}'s [[Garbage Collector]]
** {{tkoh}}'s [[BIS_fnc_GC]]
{{ Informative | only the ''on-screen'' objects will strongly impact GPU. }}
|-
|
==== High-frequency scripts ====
| {{colorball|red}}
| {{colorball|green}}
| {{colorball|green}}
| A [[while]]-loop checking without a minimum loop-[[sleep]] time is usually a sign of bad conception.<br>
* <code>[[while]] { [[true]] } {{codecomment|// already "bad" if you don't know what you are doing}}</code>
* [[trigger|Triggers]] check their set condition '''every 0.5 second''' (hardcoded value). If a large area is covered or condition code is too complex, this can be an issue. Convert them to scripts then.
* creating [[createUnit|units]]/[[createVehicle|vehicles]] globally implies a network synchronisation.
|-
|
==== High-frequency network messages ====
| {{colorball|orange}}
| {{colorball|green}}
| {{colorball|red}}
|
* Use [[publicVariable]] wisely; for specific cases, consider [[publicVariableServer]]&nbsp;/&nbsp;[[publicVariableClient]]
* Creating [[createUnit|units]]/[[createVehicle|vehicles]] globally implies a network synchronisation, keep them to a minimum / at one-point in the mission.
* keep the '''*global''' version of commands ([[hideObject]]/[[hideObjectGlobal]], etc) to a minimum
* Lower client's [[viewDistance|view distance]] in order to lessen its object position update requests
*  
*  
|}


{{ Informative | [[viewDistance|View distance]] can be separately set for each clients independently from the server's value, through scripting.<br>
This can make or break performance for the client. }}


== Off-the-shelf script ==
<code>_unit [[removePrimaryWeaponItem]] "acc_pointer_IR";
_unit [[removePrimaryWeaponItem]] "acc_flashlight";
[[if]] ([[sunOrMoon]] == 1) { _unit [[unlinkItem]] [[hmd]] _unit; };
</code>


== What else? ==


== What's next? ==
You have applied all these recommendations and yet, your mission still doesn't run well in multiplayer (but does in singleplayer);
an answer to that is that you are using '''mods''', of which some are not well optimised, if at all.


* drop unoptimised mods
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.




Line 66: Line 123:




[[Category:Sandbox]]
[[Category: Sandbox]]

Revision as of 13:14, 29 June 2019

Template:SideTOC

Introduction

This article will try to be a general guide about improving your mission's code and its performance.
As usual, moderation is the key so do not expect to have thousands of AI magically running 144 FPS. Everything comes at a cost, the tweaks on this page will simply allow you to calibrate your mission properly.

This page is about Mission Optimisation. For scripting optimisation, see Code Optimisation.


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.
    • Arma 3 displays FPS when you go into video options
    • Steam allows you to display FPS in a screen corner, in Settings > In game > FPS Counter
  • Use (unofficial) Performance Guides to get better performances:
  • 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.
Please note that viewDistance (among other settings) impacts both GPU and CPU!


Creating your mission


Performance impact table

Topic CPU GPU Net-
work
Solution

AI units quantity

Template:colorball Template:colorball Template:colorball
  • Use Agents whenever possible
  • If a client has a low-end machine, they shouldn't 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.
Most if not all of the mission calculation (objectives, completion distance, etc.) must be done server-side. Local effects should be calculated client-side.
If you own more than one average computers, you could consider Headless client and code accordingly.

Objects quantity

Template:colorball Template:colorball Template:colorball The less objects, the more FPS you will have.
only the on-screen objects will strongly impact GPU.

High-frequency scripts

Template:colorball Template:colorball Template:colorball A while-loop checking without a minimum loop-sleep time is usually a sign of bad conception.
  • while { true } // already "bad" if you don't know what you are doing
  • Triggers check their set condition every 0.5 second (hardcoded value). If a large area is covered or condition code is too complex, this can be an issue. Convert them to scripts then.
  • creating units/vehicles globally implies a network synchronisation.

High-frequency network messages

Template:colorball Template:colorball Template:colorball
View distance can be separately set for each clients independently from the server's value, through scripting.
This can make or break performance for the client.


What else?

You have applied all these recommendations and yet, your mission still doesn't run well in multiplayer (but does in singleplayer); an answer to that is that you are using mods, of which some are not well optimised, if at all.

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.