X4: Foundations

X4: Foundations

AI Economy Buff 7.0 Re-mastered
Treybor  [developer] 20 Jun, 2024 @ 7:41am
Performance and what to look for?
Lots of people always talk about performance, so I'm just posting my observations/things I've read in the code or online.

What causes lag? Every trader spinning around looking for trades is actively running a script, a trader going from point A to point B consumes the absolute least amount of CPU. So any major breakdowns in the economy, like every refined metals factory being destroyed would negatively effect every single trader in the chain as trades dry up and they need to continually search for any trade.

Too many stations: Too many trade locations will overload the trade script as it needs to calculate more and more trade entries in it's algorithm, similarly too few can overload a sector graphically or create dry spells in trade.

Mis-matched buy/sell distances: Having a buy at 5 and sell at 1 actually causes the script to run 4 times to grab a trade as opposed to only twice with a matching buy/sell distance order

Economy degradation: as mentioned in my first point, if the economy stalls out and too many traders are stuck in the "searching for trades" script this can have a negative impact of performance as well

Do more sectors increase lag? Not really unless we hit the too many stations threshold, only then would it be an issue, but I have had memory issues over long play sessions when visiting many sectors in a short timespan (this is just something Egosoft would need to look at)

Graphics: Obviously too many ships being loaded at once for your GPU to handle will cause FPS loss, in some cases (such as Second Contact II) the sector is just too small for the amount of traffic it receives, every single turret needs to calculate its fire arc as well and large fleet battles can drop your FPS.

Player assets consume the absolute most CPU, so using AI traders is helpful

Satellites and Resource Probes also consume CPU since they are continually updating new information like vision or resource density.

Also its not always one thing causing degradation, having some traders searching for trades isn't necessarily bad, it's when it becomes widespread from galactic economic collapse or your entire trade fleet doing everything and the AI traders no longer have anything left to do.
Last edited by Treybor; 20 Jun, 2024 @ 9:51am