the real bottleneck

the real bottleneck

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

the real bottleneck

Post by Tobi »

Following up on the other thread here, where a non bottleneck was optimized, I typed a blog post about part of result of Spring profiling done by BrainDamage.

I might even make more posts, some of which may even be useful as documentation :-P

clicky
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: the real bottleneck

Post by jK »

would be nice to know the used miplevels for the losmaps

PS: it would be nice too to know what lua he had run (it ate ~40% of his cpu)
User avatar
Decimator
Posts: 1118
Joined: 24 Jul 2005, 04:15

Re: the real bottleneck

Post by Decimator »

So what would happen if we had a separate type of los that ignores terrain?
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: the real bottleneck

Post by lurker »

12.70% LOS
12.83% sqrt

By the way, before I saw this post I was wondering about trying to speed up the vector los squares get shoved into. Looks like capacity may or may not be 0 after clear() is called. If it is, then we should probably reserve() a size in the hundreds range. It seems that gcc tends to not touch capacity, but it never hurts to be explicit about such things.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: the real bottleneck

Post by jK »

hmmm seems to be an old build too, Camera::InView() spends >4% in sqrt, but I already optimized that stuff with square functions.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: the real bottleneck

Post by lurker »

What was used to make this?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: the real bottleneck

Post by Argh »

So what would happen if we had a separate type of los that ignores terrain?
Gee, I've only asked for that maybe 4-5 times now ;)

Seriously... I think that issue no. 1 is:

1. LOS handler needs to update only if Unit exits the current LOS square (i.e., the larger the squares, the less frequently it bothers, no matter how fast things move).

2. Aircraft shouldn't bother checking terrain, because they move so fast that no. 1 still won't result in a large enough cost savings.

Just my opinion, of course, but I don't see a lot of benefit, in terms of gameplay, for the way things currently work.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: the real bottleneck

Post by lurker »

In no particular order:
It already waits for units to move.
Aircraft tend to not be that high, compared to cliffs. And they can also land.
Circular LOS would be pretty simple to code to have as a lobby option, we already even have the same code for ALOS. It just takes someone to get around to it.
el_matarife
Posts: 933
Joined: 27 Feb 2006, 02:04

Re: the real bottleneck

Post by el_matarife »

lurker wrote:Aircraft tend to not be that high, compared to cliffs. And they can also land.
I think we should just assume aircraft fly high enough to ignore terrain checks unless landed or told otherwise through some sort of unit tag. (I know NOTA has some low flying units they may want terrain LOS checks on, plus who knows what else.)
User avatar
quantum
Posts: 590
Joined: 19 Sep 2006, 22:48

Re: the real bottleneck

Post by quantum »

Reducing LOS miplevels has had a huge effect on chicken mode in CA and no visible drawback. It's possibly an easy solution to this problem.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: the real bottleneck

Post by lurker »

No assuming imo. Go with a tag and use terrain if that tag isn't there.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: the real bottleneck

Post by Tobi »

As far as I know BrainDamage used Spring 0.77b5 for his testing, so indeed an old build :-)

I think he used XTA 9.53. He had IceUI and other heavy LUA stuff running. I'll update the post later today, I have the replays at my home PC.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: the real bottleneck

Post by lurker »

It seems XTA uses default. Maybe we should bump the default to 2 for LOS.
el_matarife
Posts: 933
Joined: 27 Feb 2006, 02:04

Re: the real bottleneck

Post by el_matarife »

lurker wrote:What was used to make this?
Yeah, can you document how to do this performance profiling? It'd be an interesting way to test possible performance improvements.
User avatar
koshi
Lobby Developer
Posts: 1059
Joined: 14 Aug 2007, 16:15

Re: the real bottleneck

Post by koshi »

el_matarife
Posts: 933
Joined: 27 Feb 2006, 02:04

Re: the real bottleneck

Post by el_matarife »

quantum wrote:Reducing LOS miplevels has had a huge effect on chicken mode in CA and no visible drawback. It's possibly an easy solution to this problem.
FatController just tested this in BA by changing the AirLOSMipMap to 4 from the current 2 and LOSMipMap to 2 from 1 and had 15% lower CPU usage with 1200 patrolling Vampire stealth fighters after switching teams so they didn't render. I'm assuming that's an extreme edge case, but even a 5% to 10% bump would be pretty nice for no appreciable sacrifice in quality.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: the real bottleneck

Post by FLOZi »

S44 also had significant gains when we changed the los settings. I'm afraid I've forgotten the numbers though..
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: the real bottleneck

Post by imbaczek »

Most interesting post. Good visualizations there.

What's the complexity of LOS today in big-O notation? Is it O(units*map_squares)? There is an algorithm for square LOS which works in O(map_squares); I'm not sure if it can be repurposed for circular LOS though, also it ignores height differences. For view-blocking stuff, there's recursive shadowcasting available in several roguelike(!) libs.
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: the real bottleneck

Post by Kloot »

It's Omega(n * m), where n is the number of units that moved from their last SlowUpdate position and m the total number of squares covered (not counting overlap). Since each unit sees an amount of squares that grows quadratically as a function of its LOS radius (which all need explicit updating) the bottleneck very quickly becomes visible, patrolling fighter swarms are the worst offenders of course. ;)
Argh wrote: Aircraft shouldn't bother checking terrain
... And that would mean _all_ squares within a plane's LOS would _always_ need to be visited with the current tabular representation, thus making the problem even more acute.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: the real bottleneck

Post by Tobi »

imbaczek wrote:Most interesting post. Good visualizations there.

What's the complexity of LOS today in big-O notation? Is it O(units*map_squares)? There is an algorithm for square LOS which works in O(map_squares); I'm not sure if it can be repurposed for circular LOS though, also it ignores height differences. For view-blocking stuff, there's recursive shadowcasting available in several roguelike(!) libs.
Thanks. Have a link to this algorithm for square LOS that works in O(map_squares)?
Post Reply

Return to “Engine”