Optimisations ideas

IronsoulIronsoul Join Date: 2011-03-12 Member: 86048Members
<div class="IPBDescription">Unnofficial, uninformed, under the sea</div>alright, I should first start off that I am a beginner programmer, I don't really know much at all. But hear me out.
What I present is a bunch of possible optimisations that might improve client side performance and/or server performance.

First up, is the fact that when a server tickrate goes down, so does my fps... why is that? Is it because rendering each frame is linked
to the rate the game world updates? I can only assume it is. It's especially obvious when i have high ping, because I'm receiving data at a delayed rate, and my fps gets worse.
How to fix, well, first up, I would think that separating rendering from updating the game world would be a nice start.

My main idea, is a system which puts more strain onto the server(possibly), and hopefully less strain onto the clients.

How this is done:

The server can tell where the players are, but a player on one side of the map, doesn't really need to know exactly what another player on the other side of the map is doing.

In the same way you get hydras to "sleep", you can get a server to detect when people are too far away from other players to matter, then cause the updates of that player to reduce to x,y coordinates only(no health, gunfire, look direction etc), and then slow those upates to once a second. You could probably use the same occlusion culling mechanism to make it work.

Problems with that: audio, you would still want to hear enemies on the other side of a wall, so perhaps you could send audio only as well as x,y coordinates. But even then, keep the updates to once or 5 times a second). That way, you will still get the sense you can tell where the enemies are, at a reasonably smooth rate, but save on not needing to update everything else. This would save hugely on bandwidth.


Another optimisation: reduce updates of a heap of things to 5 times a second. Such as: building's taking damage/being repaird. Power in rooms going down.

Another network optimisation:

if there is no change in resource generation, don't bother updating player's clients if the client already knows how much res is being generated every 8 seconds:
just update the res increment rate every time a resource tower is activated/deactivated, and also when structures are built. Ignore updating whenever resources goes up because of the usual expected increment.

I think one of the major bottlenecks to performance happens during combat. During this time, a lot of lua calls happen forhandling attacks and damage etc. If you reduced the base principals of this down to C code, and only called the actual attack/take damage configuration(for the sound effect settings, models, how to handle death, and also pushback), that might boost overall performance while retaining modability.

That's all of my horrible ideas for now, I put it in general discussion because i heard uwe doesnt bother to check ideas and suggestions.

Comments

  • Heroman117Heroman117 Join Date: 2010-07-28 Member: 73268Members
    edited January 2012
    The additional strain on the client's side when server-performance as well as connection is poor was intentional.

    Before, there were severe rubber banding issues whenever player's collided, due to missing information that the server was incapable of sending to the client in a timely manner. Thus client-prediction for every frame that the server does not provide would fill in the gaps. This had a negative impact on client performance and everyone noticed it, as i recall it was the build 185 patch. For every frame that the client had that the server did not provide information for, had to be predicted, costing processing power. The implementation of client-prediction was necessary however, as it was an issue that needed to be addressed at some point, which it indeed has been alleviated, and for the most part the performance cost that it had brought has largely been regained.

    Frankly, server netcode is something that by all means needs to be addressed specifically so that the <i>server</i> is put under less stress, as the inefficiency of the server is what is causing the drop in client frame rate to begin with, and rather rolling back fixes to collision detection to relieve a little stress on the client, we need to optimize both aspects to give ideal performance. Client performance is, at least from my experience, is less of a glaring issue than server performance is at the moment, as the client can employ various measures through the console to maximize performance. The same cannot be said for the server though, as right now 30 ticks/second is the target performance for servers right now, when in an ideal Counter-Strike server the tickrate can be 100. As of right now even the server seldom performs at maximum capacity, often dipping into the teens, and in the worst case, between 1 and 10, so in reality the server is the last aspect of Ns2 that needs to be put under more stress.

    These issues are largely known by UWE, and its safe to assume whatever can be done to improve server as well as client performance is being investigated and integrated into the game.
  • YuukiYuuki Join Date: 2010-11-20 Member: 75079Members
    <!--quoteo--><div class='quotetop'>QUOTE </div><div class='quotemain'><!--quotec-->The server can tell where the players are, but a player on one side of the map, doesn't really need to know exactly what another player on the other side of the map is doing.<!--QuoteEnd--></div><!--QuoteEEnd-->

    I don't know more than you but it makes sense to me. You could stop predicting them completely I think, if the server provides 30 ticks it should be enough. I wonder if it's not already in game though, for example the power node state update only when you're close it seems.

    But Heroman is right, the server performance is probably the main problem and improving it will probably also improve client performance, because they mostly run the same lua game code (which is the main bottleneck as I understood).
  • ZeikkoZeikko Join Date: 2007-12-16 Member: 63179Members, Squad Five Blue, NS2 Map Tester
    <!--quoteo(post=1893287:date=Jan 10 2012, 02:35 AM:name=Ironsoul)--><div class='quotetop'>QUOTE (Ironsoul @ Jan 10 2012, 02:35 AM) <a href="index.php?act=findpost&pid=1893287"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->The server can tell where the players are, but a player on one side of the map, doesn't really need to know exactly what another player on the other side of the map is doing.<!--QuoteEnd--></div><!--QuoteEEnd-->

    I think it is already on because it is a very crude and basic optimisation and anti cheating mechanism and the fact that other players disappear from your view in when they're far away. This is noticeable in big rooms like crossroads and crevice in Summit. You can try it with your friend by going to the opposite sides of crossroads, moving towards and further away from each other and you will find a distance when you will disappear from each other's view.
  • HughHugh Cameraman San Francisco, CA Join Date: 2010-04-18 Member: 71444NS2 Developer, NS2 Playtester, Reinforced - Silver, Reinforced - Onos, WC 2013 - Shadow, Subnautica Developer, Pistachionauts
    Sounds like a logical thought Ironsoul, well done taking the time write it up!
  • IronsoulIronsoul Join Date: 2011-03-12 Member: 86048Members
    my thought is, get the server to update to clients less... Especially if theyre on the other side of the map from each other. Then the server would be doing less work, it doesn't need to open a connection, send the data, check to see if it's been received etc. it just has to go "if this client is in range of this client then send data". Could be worse in high intensity situations.

    Did I mention the part about offloading some of the really performance hungry parts of the game, such as when combat really picks up, to C code? because that would probably at least make the gameplay more consistent.
  • playerplayer Join Date: 2010-09-12 Member: 73982Members
    Doesn't it already do that though? Send data on a need-to-know basis I mean. I'm pretty sure it also checks against whether networked variables have actually changed or not, before it decides to send them to clients. Moving script into the engine (may) yield performance increases (not always, if there's a lot of cross-engine\script communication going on, you'll lose that advantage outright), but you pay for it in terms of making your game less moddable. A lot of script from the days of the first alpha has already gone into the engine, and I'm thinking any more will become really noticable to modders who want to customize the game.
  • ZaggyZaggy NullPointerException The Netherlands Join Date: 2003-12-10 Member: 24214Forum Moderators, NS2 Playtester, Reinforced - Onos, Subnautica Playtester
    --Removed slowchat and memes--
  • Kouji_SanKouji_San Sr. Hινε Uρкεερεг - EUPT Deputy The Netherlands Join Date: 2003-05-13 Member: 16271Members, NS2 Playtester, Squad Five Blue
    <!--quoteo(post=1893553:date=Jan 11 2012, 02:10 PM:name=Zaggy)--><div class='quotetop'>QUOTE (Zaggy @ Jan 11 2012, 02:10 PM) <a href="index.php?act=findpost&pid=1893553"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->--Removed slowchat and memes--<!--QuoteEnd--></div><!--QuoteEEnd-->
    Did you just moderate yourself, I'm confused :D
  • kingmobkingmob Join Date: 2002-11-01 Member: 3650Members, Constellation
    It was stated in the optimization video that they have tools that can produce a dump during a slowdown.

    I would like to suggest a post-process tool for parsing the dump and building a timeline visualization graph of the event.
    This might include some formatting of the dump statements so they can easily be separated into systems, subsystems, and threads.

    That is just one idea for a visualization based on my limited understanding of how their engine works.
    Other visualizations might be a better investment.

    I have found building a visualization can get an entire group throwing ideas on how to prevent, squash, or hide such problems.
    it makes it easier to present to the group rather than trying to describe the scenario you have analyzed in a log file.
  • w0dk4w0dk4 Join Date: 2008-04-22 Member: 64129Members, Constellation, Reinforced - Shadow
    No offense but I think all ideas expressed here are "beginner" ideas on how to solve performance problems in multiplayer games in general and I am dead sure both Max and Dushan are well aware of these techniques and probably have implemented most of them already.

    From what I've gathered so far, the poor performance in general simply comes from all the aggressive technology choices (LUA gamecode, realtime culling, unlimited lightsources, etc..) rather than from simple fixes like proposed here. So fixing performance is a lot more involved than "disconnecting server tick rate from client fps".
  • DghelneshiDghelneshi Aims to surpass Fana in post edits. Join Date: 2011-11-01 Member: 130634Members, Squad Five Blue, Reinforced - Shadow
    edited January 2012
    <!--quoteo(post=1893582:date=Jan 11 2012, 06:57 PM:name=w0dk4)--><div class='quotetop'>QUOTE (w0dk4 @ Jan 11 2012, 06:57 PM) <a href="index.php?act=findpost&pid=1893582"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->So fixing performance is a lot more involved than "disconnecting server tick rate from client fps".<!--QuoteEnd--></div><!--QuoteEEnd-->
    Especially obvious example, as this idea in particular doesn't even make any sense at all.

    Too many people are being overconfident and think that developing a game like this is as easy as their super mario clone.

    <!--quoteo(post=1893340:date=Jan 10 2012, 11:10 AM:name=Zeikko)--><div class='quotetop'>QUOTE (Zeikko @ Jan 10 2012, 11:10 AM) <a href="index.php?act=findpost&pid=1893340"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->I think it is already on because it is a very crude and basic optimisation and anti cheating mechanism and the fact that other players disappear from your view in when they're far away. This is noticeable in big rooms like crossroads and crevice in Summit.<!--QuoteEnd--></div><!--QuoteEEnd-->
    I never noticed that one... sounds like a quick and dirty hack but will probably get replaced sometime.

    <!--quoteo(post=1893563:date=Jan 11 2012, 04:20 PM:name=Kouji_San)--><div class='quotetop'>QUOTE (Kouji_San @ Jan 11 2012, 04:20 PM) <a href="index.php?act=findpost&pid=1893563"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Did you just moderate yourself, I'm confused :D<!--QuoteEnd--></div><!--QuoteEEnd-->
    He removed some posts without posting anything himself, it's just the notice that something was deleted in case anyone wonders.
  • playerplayer Join Date: 2010-09-12 Member: 73982Members
    <!--quoteo(post=1893586:date=Jan 11 2012, 06:23 PM:name=Dghelneshi)--><div class='quotetop'>QUOTE (Dghelneshi @ Jan 11 2012, 06:23 PM) <a href="index.php?act=findpost&pid=1893586"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec--><!--quoteo(post=0:date=:name=Zeikko)--><div class='quotetop'>QUOTE (Zeikko)</div><div class='quotemain'><!--quotec-->
    I think it is already on because it is a very crude and basic optimisation and anti cheating mechanism and the fact that other players disappear from your view in when they're far away. This is noticeable in big rooms like crossroads and crevice in Summit.<!--QuoteEnd--></div><!--QuoteEEnd-->
    I never noticed that one... sounds like a quick and dirty hack but will probably get replaced sometime.
    <!--QuoteEnd--></div><!--QuoteEEnd-->
    A temp-fix perhaps in the form of a max-distance for when the occlusion-culler wasn't working at all, which could lead to insane load in some areas\maps (ns2_tram in particular, would almost be completely rendered not that many builds ago).
  • IronsoulIronsoul Join Date: 2011-03-12 Member: 86048Members
    well, i did state I don't have much idea. But I am learning lua, and yes, i do understand that programming a very difficult and time consuming task.

    But hey, keep this thread going, maybe we'll get some ideas yet. Probably the main thing to fix performance is to reduce loops as much as possible. Because as we all know, while a loop is running(excluding the game loop), the rest of the program has to wait for it to finish before it can actually continue.
  • scottyscotty Join Date: 2011-07-01 Member: 107400Members
    <!--quoteo(post=1893663:date=Jan 11 2012, 06:48 PM:name=Ironsoul)--><div class='quotetop'>QUOTE (Ironsoul @ Jan 11 2012, 06:48 PM) <a href="index.php?act=findpost&pid=1893663"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Probably the main thing to fix performance is to reduce loops as much as possible. Because as we all know, while a loop is running(excluding the game loop), the rest of the program has to wait for it to finish before it can actually continue.<!--QuoteEnd--></div><!--QuoteEEnd-->

    <a href="http://en.wikipedia.org/wiki/Multithreading" target="_blank">http://en.wikipedia.org/wiki/Multithreading</a>
  • IronsoulIronsoul Join Date: 2011-03-12 Member: 86048Members
    even so, a cpu will run at so many clocks, so if you reduce the required clocks, it will run faster regardless of multi threading.
  • scottyscotty Join Date: 2011-07-01 Member: 107400Members
    Well that's a different argument now isn't it. :)
  • internetexplorerinternetexplorer Join Date: 2011-10-13 Member: 127255Members
    edited January 2012
    Somebody please show me a modern CPU that is starved for clock cycles running ns2.

    As for the thread, it's good that you're trying to start thinking about the issues in this game (albeit from a beginner's perspective). Are you pursuing education or a career in computers/software? Watching the NS2HD videos (especially anything involving Max) is a good source of inspiration for me.

    Chances are the major performance bottlenecks in the game come from things like the rendering engine and physics (as well as things that have been mentioned more recently like the LUA interpreter). Read up on some numerical math and graphics programming if you want to get an idea how that stuff works.

    Either way, they have profiling tools to find sore spots, and they have talented programmers who are devoted to working from a good <i>software architecture </i> - they'll get the game running much smoother given time.
  • IronsoulIronsoul Join Date: 2011-03-12 Member: 86048Members
    yeah, I'm working towards a job in the industry, currently studying c++ and lua.
Sign In or Register to comment.