fighters on "patrol" = performance hit

fighters on "patrol" = performance hit

Various things about Spring that do not fit in any of the other forums listed below, including forum rules.

Moderator: Moderators

[pokemon]
Posts: 1
Joined: 12 Sep 2009, 18:33

fighters on "patrol" = performance hit

Post by [pokemon] »

I just noticed a strange thing while having about 1500 fighters patrolling my base. While they were on patrol command the game lagged horribly, it was roughly 5 fps. but once i canceled the patrol and set on queued move or attack the fps jumped back to 50 fps. The question arises, is something wrong with the patrol command? Maybe it could be redone to improve performance.
User avatar
Caydr
Omnidouche
Posts: 7179
Joined: 16 Oct 2004, 19:40

Re: fighters on "patrol" = performance hit

Post by Caydr »

Pathfinding uses a lot of resources, we've known that a while. What mod were you playing? Some mods make aircraft able to fly through each other, reducing the performance penalty significantly.

Also, why the hell are you here complaining about a scenario that will never come up in a game? 1500 fighters? No developer would be stupid enough to make that necessary under normal gameplay. Play a real game and you'll not have things like this to complain about. It's like complaining that iTunes would fill your hard drive if you were to download every song ever made.
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: fighters on "patrol" = performance hit

Post by aegis »

/me goes and plays a 64-player game... wait, might these 1500 fighters have a valid reason for existing?

also, the point of his post: patrol seems to have performance issues.
User avatar
BrainDamage
Lobby Developer
Posts: 1164
Joined: 25 Sep 2006, 13:56

Re: fighters on "patrol" = performance hit

Post by BrainDamage »

Caydr wrote:Pathfinding uses a lot of resources, we've known that a while.
airplanes don't pathfind
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: fighters on "patrol" = performance hit

Post by bobthedinosaur »

they shouldn't
User avatar
momfreeek
Posts: 625
Joined: 29 Apr 2008, 16:50

Re: fighters on "patrol" = performance hit

Post by momfreeek »

los calculations

1500 airplanes, all moving, all recalculating los constantly
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: fighters on "patrol" = performance hit

Post by KDR_11k »

On patrol they look for targets to chase. On move they don't.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: fighters on "patrol" = performance hit

Post by Beherith »

Would there be a big difference in their behavior or performance if they were just stuck on repeat on move or repeat on fight?
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: fighters on "patrol" = performance hit

Post by KDR_11k »

On move they don't look for targets, fight shouldn't make a difference from patrol.
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: fighters on "patrol" = performance hit

Post by aegis »

units don't look for targets when they automatically attack things in range while moving?
User avatar
Caydr
Omnidouche
Posts: 7179
Joined: 16 Oct 2004, 19:40

Re: fighters on "patrol" = performance hit

Post by Caydr »

I meant pathing and LoS... I'm used to spouting this off to people that /give 5000 armflash and suddenly their game slows down even though the units are low-detail.

In any event it'll never get seen in a real game. There are all kinds of hypothetical situations that might cause problems but that doesn't mean devs need to start wasting their time on eliminating them.
zerver
Spring Developer
Posts: 1358
Joined: 16 Dec 2006, 20:59

Re: fighters on "patrol" = performance hit

Post by zerver »

I guess the performance hit could be reduced a lot by implementing some kind of caching of nearby enemies, but there is a risk it will make the fighters react more slowly to incoming bombers. Anyway, I will look into it.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: fighters on "patrol" = performance hit

Post by Tobi »

KDR_11k wrote:On patrol they look for targets to chase. On move they don't.
This. (Confirmed in my own test, patrol of 1500 BA armhawks reduces FPS by 50% compared to repeat-move with roam.)


On fight/patrol, CGameHelper::GetClosestEnemyUnit is called for each unit every SlowUpdate (every 16 frames).

GetClosestEnemyUnit iterates through all units in all quads within maximum range of the units weapons.

If the common case is that less enemies are nearby then friendlies (I bet it is), it may be advantageous to iterate over CQuadField::Quad::teamUnits for all enemy teams instead of CQuadField::Quad::units.

zerver wrote:Anyway, I will look into it.
Will leave it to you to confirm it is this and implement the change then ;-)

EDIT: I don't think caching will really be feasible, at least not without making the algorithm an approximation only. (ie. GetNearbyEnemyUnit)
HectorMeyer
Posts: 181
Joined: 13 Jan 2009, 11:20

Re: fighters on "patrol" = performance hit

Post by HectorMeyer »

zerver wrote:I guess the performance hit could be reduced a lot by implementing some kind of caching of nearby enemies, but there is a risk it will make the fighters react more slowly to incoming bombers. Anyway, I will look into it.
Or maybe the engine can detect when a certain number of planes are on a patrol path, and then stop calculating LOS for each plane and instead give permanent LOS for the patrol area.
User avatar
Dragon45
Posts: 2883
Joined: 16 Aug 2004, 04:36

Re: fighters on "patrol" = performance hit

Post by Dragon45 »

HectorMeyer wrote:
zerver wrote:I guess the performance hit could be reduced a lot by implementing some kind of caching of nearby enemies, but there is a risk it will make the fighters react more slowly to incoming bombers. Anyway, I will look into it.
Or maybe the engine can detect when a certain number of planes are on a patrol path, and then stop calculating LOS for each plane and instead give permanent LOS for the patrol area.
Some optimization is needed, but this seems like a bad idea. The degenerate case of 1-2 fighters patrolling a large area in front of your base, for example.

LOS might need to be optimized...
Auswaschbar
Spring Developer
Posts: 1254
Joined: 24 Jun 2007, 08:34

Re: fighters on "patrol" = performance hit

Post by Auswaschbar »

HectorMeyer wrote:
zerver wrote:I guess the performance hit could be reduced a lot by implementing some kind of caching of nearby enemies, but there is a risk it will make the fighters react more slowly to incoming bombers. Anyway, I will look into it.
Or maybe the engine can detect when a certain number of planes are on a patrol path, and then stop calculating LOS for each plane and instead give permanent LOS for the patrol area.
[ ] you have read the thread
[X] you just give unhelpfull advice
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: fighters on "patrol" = performance hit

Post by lurker »

So how does acquiring targets in move+fireatwill mode work?
HectorMeyer
Posts: 181
Joined: 13 Jan 2009, 11:20

Re: fighters on "patrol" = performance hit

Post by HectorMeyer »

I know Tobi and zerver were talking about something different. The LOS thing was just an idea.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: fighters on "patrol" = performance hit

Post by Tobi »

lurker wrote:So how does acquiring targets in move+fireatwill mode work?
It doesn't chase units as in patrol in this case.

Just the weapon's SlowUpdate checks for enemies, and this uses CGameHelper::GenerateTargets, which apparently uses exactly the speedup I suggested for CGameHelper::GetClosestEnemyUnit. I don't know why the code isn't reused between those two, haven't investigated much tho.

Only if the unit is idle (no orders in queue) it also seems to call CGameHelper::GetClosestEnemyUnit, but I guess the slowdown caused by this isn't really noticeable because other slowdowns from moving aren't present (like LOS) and/or because when e.g. planes are idle they often land, and when landed they all do take a free spot of ground. In other words, when idle there are possibly less other units nearby then when patrolling in a single blob of 1500 planes.
User avatar
JohannesH
Posts: 1793
Joined: 07 Apr 2009, 12:43

Re: fighters on "patrol" = performance hit

Post by JohannesH »

how does having the units on "roam" affect it?
Post Reply

Return to “General Discussion”