beyond-all-reason / spring

A powerful free cross-platform RTS game engine
https://beyond-all-reason.github.io/spring/
Other
210 stars 99 forks source link

Updateunitlosstates have high CPU consumption with a lot of FFA players #1357

Open 6AKU66 opened 6 months ago

6AKU66 commented 6 months ago

Beherith found that in 64 FFA match updateunitlosstates is pretty high (Beherith: It was eating 5-6 ms of the 16ms sim frames at 4k units with 64 teams). From myself i propose additional optimization:

  1. Remove LoS for defeated player,
  2. If "/globallos" is active then disable LoS check for units that can't cloak (if i understand correctly for what Updateunitlosstates function is doing).
  3. MT, but there's lua calls UnitEnteredLos, UnitLeftLos, UnitEnteredRadar, UnitLeftRadar according TK.
Beherith commented 6 months ago

Thanks for making a ticket for this. It could be mt'd mirroring the collision detection system's approach

sprunk commented 6 months ago

If "/globallos" is active then disable LoS check for units that can't cloak

This already happens but the other way around https://github.com/beyond-all-reason/spring/blob/f3ba23635e1462ae2084f10bf9ba777467d16090/rts/Sim/Misc/LosHandler.cpp#L182-L185

6AKU66 commented 6 months ago

Thanks for making a ticket for this. It could be mt'd mirroring the collision detection system's approach

I hope you tested without additional zones SetLosStatus, CalcLosStatus, UpdateLosStatus. But just one tracyzone in void CUnitHandler::UpdateUnitLosStates(). Overwise we can be chasing for ghosts here because of high amount of overhead.