5% performance boost in Alien Swarm and possibly more...

Grab your favourite IDE and tinker with the innards of game engines

5% performance boost in Alien Swarm and possibly more...

Postby IBeMad on Tue Jan 01, 2013 6:51 am

This was an email sent from me to Jonathan Sutton, who was the project lead for Alien Swarm. I'm not sure how many SDKs this affects, but I know for sure it affects Alien Swarm's stock SDK and I just thought I'd share it. I sent this to him on 11/10/12:

Hey Jonathan,

This might be old news to everyone there at Valve, and I kinda hope it is and just hasn't been fixed in the SDK yet :/

First off: let me state that I've only reproduced this bug with a local (map <mapname>) server and haven't tested it with any other setups (client connecting to dedi server, etc).

About 5 minutes with the profiler in my new copy of VS2012 and I was pretty sure there was something wrong with the animation system. Visual Studio was reporting that about 5% of total game time for both the server and the client was being spent on VerifySequenceIndex() in animation.cpp. I didn't look too far into how the system works, but I assumed that the animation system generates two CUtlVectors with the purpose of creating an "optimized" comparison method for finding animations, aka avoiding having to do strcmp everywhere and instead just using integers for activity names.

It seems like the value "activitylistversion" in studiohdr_t(\public\studio.h) is networked between the client and server? The problem arises when VerifySequenceIndex() is called in animation.cpp. What should happen is the CStudioHDR's GetActivityListVersion() function should return the same value as g_nActivityListVersion, except for the very first time, when it needs to be initialized. What actually happens is the client's g_nActivityListVersion equals 1, and the server's g_nActivityListVersion equals 2.

This happens because on the server in CWorld::CWorld(), (\game\server\world.cpp) the function ActivityList_Init() is called, then in CWorld::Precache() the function ActivityList_Free() is called, which increments g_nActivityListVersion (which is initialized to 1, and after being incremented is now 2). On the client however (in cdll_client_int.cpp, InitGameSystems()) only ActivityList_Init() is called, so on the client g_nActivityListVersion remains at 1.

Because of these differences, every frame the server will call VerifySequenceIndex(), find that the CStudioHDR's GetActivityListVersion() equals 1, and will rebuild the optimized activity list, then set the CStudioHDR's activitylistversion to 2. The client will then call VerifySequenceIndex(), find that the CStudioHDR's GetActivityListVersion() equals 2, and will rebuild the optimized activity list, then sent the CStudioHDR's activitylistversion to 1.

This will keep going indefinitely, thus resulting in a 5% overall performance loss according to Visual Studio. Whatever the true reason for why these variables are synced between the client and server, changing

ActivityList_Init();
ActivityList_RegisterSharedActivities();

EventList_Init();
EventList_RegisterSharedEvents();

in InitGameSystems() in cdll_client_int.cpp to

ActivityList_Init();
ActivityList_Free();
ActivityList_RegisterSharedActivities();
EventList_Init();
EventList_Free();
EventList_RegisterSharedEvents();

fixed the problem. Hopefully this has already been fixed and the SDK hasn't been updated with the fix, or if not, there's 5% more performance :)


This was the response I received back from him a few days later:

Wow, good find Matt! I’ll look into it here. Thanks.


With typical Valve style I never received anything back after that, but whatever.
Last edited by IBeMad on Tue Jan 01, 2013 7:16 am, edited 1 time in total.
IBeMad
Member
Member
 
Joined: Sun Jan 22, 2012 5:18 pm

Re: 5% performance boost in Alien Swarm and possibly more...

Postby Jangalomph on Tue Jan 01, 2013 7:05 am

only a couple months late on reply. But hey! I'd be surprised to see an updated sdk show up on my screen within the next few days.
http://www.nomoreroominhell.com
I don’t know whether I was right or wrong, I guess I’ll never know… But I made it. And I guess I should be thankful for that. - Strelok
Has anyone really been far even as decided to use even go want to do look more like?
User avatar
Jangalomph
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Wed Jun 25, 2008 3:19 pm
Location: Sumter, SC

Re: 5% performance boost in Alien Swarm and possibly more...

Postby IBeMad on Tue Jan 01, 2013 7:18 am

Well Jonathan Sutton did push out a fair number of community-requested SDK updates... among which were Alien Swarm's shader sources, ttf font support, marine and alien model sources, and a matchmaking dll that supports more than 4 players. :)
IBeMad
Member
Member
 
Joined: Sun Jan 22, 2012 5:18 pm

Re: 5% performance boost in Alien Swarm and possibly more...

Postby Jangalomph on Tue Jan 01, 2013 10:36 pm

Now we just need him to push out linux server support for alienswarm/asw games/mods.
http://www.nomoreroominhell.com
I don’t know whether I was right or wrong, I guess I’ll never know… But I made it. And I guess I should be thankful for that. - Strelok
Has anyone really been far even as decided to use even go want to do look more like?
User avatar
Jangalomph
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Wed Jun 25, 2008 3:19 pm
Location: Sumter, SC

Re: 5% performance boost in Alien Swarm and possibly more...

Postby twlomega on Tue Jan 01, 2013 11:44 pm

I had fixed this in the 2007 SDK;

you would just have to change:
if( pstudiohdr->GetActivityListVersion( ) != g_nActivityListVersion )
to:
if( g_nActivityListVersion > pstudiohdr->GetActivityListVersion( ) )

inside VerifySequenceIndex()

Otherwise, you'll still run into the same problem when going between listen / dedicated.

-Tony
twlomega
Dumpling
Dumpling
 
Joined: Tue Jan 01, 2013 11:41 pm

Re: 5% performance boost in Alien Swarm and possibly more...

Postby Jangalomph on Wed Jan 02, 2013 7:52 am

Tony "sergi"? Sorry if spelled wrong, been a long time since i saw the name.

Edit: and it may just be a coincidence that your name is tony
http://www.nomoreroominhell.com
I don’t know whether I was right or wrong, I guess I’ll never know… But I made it. And I guess I should be thankful for that. - Strelok
Has anyone really been far even as decided to use even go want to do look more like?
User avatar
Jangalomph
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Wed Jun 25, 2008 3:19 pm
Location: Sumter, SC

Re: 5% performance boost in Alien Swarm and possibly more...

Postby Kosire on Wed Jan 02, 2013 11:11 am

jangalomph wrote:Now we just need him to push out linux server support for alienswarm/asw games/mods.

good luck

jangalomph wrote:Tony "sergi"? Sorry if spelled wrong, been a long time since i saw the name.

Edit: and it may just be a coincidence that your name is tony

It's him. :smt023
User avatar
Kosire
1337 p0st3r
1337 p0st3r
 
Joined: Sat Mar 07, 2009 7:25 pm
Location: Denmark

Re: 5% performance boost in Alien Swarm and possibly more...

Postby Jangalomph on Wed Jan 02, 2013 2:03 pm

Yeah the odds of linux servers coming out are... slim to none.

And nice to see tony here. :-D
http://www.nomoreroominhell.com
I don’t know whether I was right or wrong, I guess I’ll never know… But I made it. And I guess I should be thankful for that. - Strelok
Has anyone really been far even as decided to use even go want to do look more like?
User avatar
Jangalomph
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Wed Jun 25, 2008 3:19 pm
Location: Sumter, SC

Re: 5% performance boost in Alien Swarm and possibly more...

Postby twlomega on Thu Jan 03, 2013 12:59 pm

jangalomph wrote:Tony "sergi"? Sorry if spelled wrong, been a long time since i saw the name.

Edit: and it may just be a coincidence that your name is tony


Yeah, Sergi.
'Tis me.
twlomega
Dumpling
Dumpling
 
Joined: Tue Jan 01, 2013 11:41 pm

Return to Programming

Who is online

Users browsing this forum: No registered users