Natural Selection 2 News Update - Optimizing NS2

FlayraFlayra Game Director, Unknown Worlds EntertainmentSan Francisco Join Date: 2002-01-22 Member: 3Super Administrators, NS2 Developer, Subnautica Developer
Please post comments on the topic Natural Selection 2 News Update - Optimizing NS2 here
«1

Comments

  • konatakonata Join Date: 2011-08-24 Member: 118296Members
    edited January 2012
    I'd imagine part of your optimization problems are due to the engine not being fundamentally finished?
  • RanemanRaneman Join Date: 2010-01-07 Member: 69962Members
    edited January 2012
    People don't get optimization is hard.

    According to some people: this is how optimization goes.

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->#include <iostream>
    #include "game.h"
    using namespace std;

    int main()
    {
        optimize.Game();
            return 0;
    }<!--c2--></div><!--ec2-->
  • playerplayer Join Date: 2010-09-12 Member: 73982Members
    It's also a matter of getting the timing just right. If you optimize too early things are locked in and you end up having to break it open again later on to add some new things, if you optimize too late you might find some feature you've been spending ages on doesn't actually perform within reasonable parameters and needs to be scrapped entirely and redone in a different way. Optimization certainly doesn't always happen at the end as is often posited, I think Lua is a good example of this, its performance needs to be reviewed early on while major changes can still happen (rewriting the VM per example).
  • ZeikkoZeikko Join Date: 2007-12-16 Member: 63179Members, Squad Five Blue, NS2 Map Tester
    <!--quoteo(post=1893434:date=Jan 11 2012, 01:41 AM:name=player)--><div class='quotetop'>QUOTE (player @ Jan 11 2012, 01:41 AM) <a href="index.php?act=findpost&pid=1893434"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->It's also a matter of getting the timing just right. If you optimize too early things are locked in and you end up having to break it open again later on to add some new things, if you optimize too late you might find some feature you've been spending ages on doesn't actually perform within reasonable parameters and needs to be scrapped entirely and redone in a different way. Optimization certainly doesn't always happen at the end as is often posited, I think Lua is a good example of this, its performance needs to be reviewed early on while major changes can still happen (rewriting the VM per example).<!--QuoteEnd--></div><!--QuoteEEnd-->
    +1

    Optimising is an ongoing process where timing is crucial. One needs to monitor and profile all the time and act on the right time.
    Many optimising tasks have not been able to be done earlier because it has not been the correct time. It is just not worth it to spend days optimising stuff that can not be surely incorporated in the final product.
  • exoityexoity Join Date: 2003-03-17 Member: 14620Members, NS1 Playtester, Constellation
    I know that in the video you mentioned using an in game profiler, but do you happen to use any other optimization software such as vtune? Or perhaps even any static code analysis to see potential areas for optimization?

    I did enjoy the video, it is also great to see how you are developing NS2.
  • SampsonSampson Join Date: 2012-01-06 Member: 139769Members
    i'd prefer at least a 190 test video... or 190 released.
  • konatakonata Join Date: 2011-08-24 Member: 118296Members
    <!--quoteo(post=1893444:date=Jan 11 2012, 01:59 AM:name=Sampson)--><div class='quotetop'>QUOTE (Sampson @ Jan 11 2012, 01:59 AM) <a href="index.php?act=findpost&pid=1893444"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->i'd prefer at least a 190 test video... or 190 released.<!--QuoteEnd--></div><!--QuoteEEnd-->

    In fairness it is a <b>developer blog</b> and not a <b>game progress</b> blog.
  • Kouji_SanKouji_San Sr. Hινε Uρкεερεг - EUPT Deputy The Netherlands Join Date: 2003-05-13 Member: 16271Members, NS2 Playtester, Squad Five Blue
    <!--quoteo(post=1893444:date=Jan 10 2012, 11:59 PM:name=Sampson)--><div class='quotetop'>QUOTE (Sampson @ Jan 10 2012, 11:59 PM) <a href="index.php?act=findpost&pid=1893444"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->i'd prefer at least a 190 test video... or 190 released.<!--QuoteEnd--></div><!--QuoteEEnd-->
    <a href="http://upload.wikimedia.org/wikipedia/commons/thumb/9/93/KPatience.png/738px-KPatience.png" target="_blank">patience</a>
  • konatakonata Join Date: 2011-08-24 Member: 118296Members
    Hey, they renamed Solitaire!?
  • playerplayer Join Date: 2010-09-12 Member: 73982Members
    <!--quoteo--><div class='quotetop'>QUOTE </div><div class='quotemain'><!--quotec-->the British use the term Patience to refer to Solitaire with cards<!--QuoteEnd--></div><!--QuoteEEnd-->
    You're a disgrace to England.
  • Who is Mike Jones?Who is Mike Jones? Join Date: 2011-10-29 Member: 130080Members
    I thought NS2HD was as official as it gets.
  • KrizzenKrizzen Join Date: 2011-12-16 Member: 138181Members
    I wonder how the devs feel about choosing LUA at this point? It seems the game spends an awful lot of time processing "game" code rather than rendering the scene. Maybe it was a bit of a bad choice, in hindsight?

    Don't get me wrong though: they seem like they can handle it <b>just fine</b>! However, from my experience, interpreted languages that compile into bytecode always appear fantastic on paper and may perform well in specific test cases, but in practice they just don't perform as well as their pre-compiled, compiler-optimized counterparts. Its a tragedy, really, because I adore interpreted languages.

    Regardless, by the time the game is released, most people will have a CPU powerful enough to just rip through all the game code anyway :P
  • NurEinMenschNurEinMensch Join Date: 2003-02-26 Member: 14056Members, Constellation
    I'm not sure LUA was a good idea or not. But the benefits of it will for the most part come to bear later, whereas the downsides are more obvious right now. Long term it may have been the right choice.
  • kingmobkingmob Join Date: 2002-11-01 Member: 3650Members, Constellation
    LUA was a good idea.
    It is used in other game engines.
    plenty of game engines use some sort of scripting.

    It is easy to change and makes changes faster.
    I seem to remember they built hotloading of scripts into their engine.

    that means someone could write code for a feature.
    test it ...realize what they forgot...add it...test that...and then check it in
    this cuts out compiles and game startups from iterating until a feature (or bug fix) is complete.
    Plus they got some GREAT ideas from the community.

    They may choose to move more code into C/C++ land now that they are nearing feature completion.
    But as an overall investment LUA is still worth it.
  • extolloextollo Ping Blip Join Date: 2010-07-16 Member: 72457Members
    <!--quoteo(post=1893566:date=Jan 11 2012, 11:15 AM:name=kingmob)--><div class='quotetop'>QUOTE (kingmob @ Jan 11 2012, 11:15 AM) <a href="index.php?act=findpost&pid=1893566"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->LUA was a good idea.
    It is used in other game engines.
    plenty of game engines use some sort of scripting.

    It is easy to change and makes changes faster.
    I seem to remember they built hotloading of scripts into their engine.

    that means someone could write code for a feature.
    test it ...realize what they forgot...add it...test that...and then check it in
    this cuts out compiles and game startups from iterating until a feature (or bug fix) is complete.
    Plus they got some GREAT ideas from the community.

    They may choose to move more code into C/C++ land now that they are nearing feature completion.
    But as an overall investment LUA is still worth it.<!--QuoteEnd--></div><!--QuoteEEnd-->

    I think this as well, though it is sad that they can't leverage luajit due to binding optimization. i was wondering why charlie made the comment about discussions of writing a lua interpreter. there will be more optimization in this space for sure.
  • TweadleTweadle Join Date: 2005-02-03 Member: 39686Members, NS2 Map Tester
    Interesting and informative. Thanks!
  • ScardyBobScardyBob ScardyBob Join Date: 2009-11-25 Member: 69528Forum Admins, Forum Moderators, NS2 Playtester, Squad Five Blue, Reinforced - Shadow, WC 2013 - Shadow
    <!--quoteo(post=1893560:date=Jan 11 2012, 06:43 AM:name=NurEinMensch)--><div class='quotetop'>QUOTE (NurEinMensch @ Jan 11 2012, 06:43 AM) <a href="index.php?act=findpost&pid=1893560"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->I'm not sure LUA was a good idea or not. But the benefits of it will for the most part come to bear later, whereas the downsides are more obvious right now. Long term it may have been the right choice.<!--QuoteEnd--></div><!--QuoteEEnd-->
    True, but they are bearing some of the benefits of going with lua <a href="http://www.unknownworlds.com/ns2/forums/index.php?showforum=106" target="_blank">right now</a>.
  • ReeseReese Join Date: 2003-05-08 Member: 16143Members
    Is fixing the luajit integration simply not a possibility? I guess a lot of the decision comes down to how often interpreted lua code is the bottleneck vs. binding code or c++ invoked through lua. Sitting here on the sidelines it seems like there's a good chance you could fix some of the current issues only to find that the lua interpreter is giving you a slightly smaller bottleneck than the bindings.

    That said, great post! It's always fun to watch people try to give accessible explanations of concepts that are difficult to explain to other programmers. From what I can tell you did a good job.
  • tobias3tobias3 Join Date: 2011-12-19 Member: 138543Members
    <!--quoteo(post=1893411:date=Jan 10 2012, 02:04 PM:name=konata)--><div class='quotetop'>QUOTE (konata @ Jan 10 2012, 02:04 PM) <a href="index.php?act=findpost&pid=1893411"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->I'd imagine part of your optimization problems are due to the engine not being fundamentally finished?<!--QuoteEnd--></div><!--QuoteEEnd-->

    And that is due to them trying to build a state of the art engine that first used a state of the art culling method (which did not work) and now uses a Frostbite like approach (which still does not work). I personally do not get that arms race with the big league. I do not care about graphics that much. I just want a playable game! Why not go with something a little more proven? I mean it does not have to look like *insert big studio game here*.
  • Kouji_SanKouji_San Sr. Hινε Uρкεερεг - EUPT Deputy The Netherlands Join Date: 2003-05-13 Member: 16271Members, NS2 Playtester, Squad Five Blue
    <!--quoteo(post=1893935:date=Jan 12 2012, 08:43 PM:name=tobias3)--><div class='quotetop'>QUOTE (tobias3 @ Jan 12 2012, 08:43 PM) <a href="index.php?act=findpost&pid=1893935"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->And that is due to them trying to build a state of the art engine that first used a state of the art culling method (which did not work) and now uses a Frostbite like approach (which still does not work). I personally do not get that arms race with the big league. I do not care about graphics that much. I just want a playable game! Why not go with something a little more proven? I mean it does not have to look like *insert big studio game here*.<!--QuoteEnd--></div><!--QuoteEEnd-->
    The graphics rendering in Spark is very fast actually, it is the game code/lua that is holding back performance right now. But they are getting faster with each patch :)


    Being an indie doesn't mean it has to look crappy... It already looks awesome and when other filters are introduced it will be even more awesome!
  • HarimauHarimau Join Date: 2007-12-24 Member: 63250Members
    @tobias3: Isn't it about making the engine have a decent lifetime, and making it an attractive option for modders (and possibly other companies), and just generally attractive to prospective players? Some of the design decisions are also about making sure they can build the game quickly, with changes appearing on-the-fly.
  • tobias3tobias3 Join Date: 2011-12-19 Member: 138543Members
    <!--quoteo(post=1893980:date=Jan 12 2012, 08:06 PM:name=Harimau)--><div class='quotetop'>QUOTE (Harimau @ Jan 12 2012, 08:06 PM) <a href="index.php?act=findpost&pid=1893980"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->@tobias3: Isn't it about making the engine have a decent lifetime, and making it an attractive option for modders (and possibly other companies), and just generally attractive to prospective players? Some of the design decisions are also about making sure they can build the game quickly, with changes appearing on-the-fly.<!--QuoteEnd--></div><!--QuoteEEnd-->

    So you are saying that engines that need a precomputation (shadow maps, visibility) step like source engine, unreal engine and ID engine do not have a decent lifetime - or that you cannot build a game quickly there?

    Having a sandbox like editor may have its advantages and may be very modern - but the focus should be on delivering something playable and finished. And modders and other companies shouldn't be the focus either.

    Back at the FarCry days I tried to make a mod for the CryTek 1 engine. That engine is similar in that it uses LUA and a sandbox editor. And it was godawful because you could really see that they moved LUA code back into C++ and what was left was an inconsise mess. That does not matter though because they were able to finish the game and deliver.

    Same thing happend here. I think: We need the level designers/game designers to be able to change the game -> Let's do the game part in an easy language that they can learn easily -> level/game designers produce messy, slow lua code -> Programmers have to fix it (costly). Because they like C++ more they move it back there
  • HarimauHarimau Join Date: 2007-12-24 Member: 63250Members
    I am saying nothing of the sort. Don't presume to put words in my mouth.

    Now, with regard to decent lifetime, I was referring to the more "modern" features - an engine that is full of outdated technology when it is released is not attractive to modders, developers, or, more importantly, prospective customers either. A scripting "layer" built on top of the engine was one design decision that creates accessibility for modders, and allows for instant changes in-game. The others you know: dynamic lighting, no pre-compiling, etc. More than being marketed towards modders and developers, the decisions were made so that UWE could import, edit and test lots of assets and features in a very quick period of time, <b>without also requiring a very large team</b>. It was UWE's belief that the benefits outweighed the costs, and they still believe they will get it to work. Honestly, this was all explained by UWE the day they announced the decision to switch from Source to the as-yet-unnamed engine that became Spark (and by Max in one of the recent NS2HD interviews), and I'm just regurgitating it for your benefit. Your frustration is misdirected.
  • tobias3tobias3 Join Date: 2011-12-19 Member: 138543Members
    edited January 2012
    <!--quoteo(post=1894133:date=Jan 13 2012, 09:09 AM:name=Harimau)--><div class='quotetop'>QUOTE (Harimau @ Jan 13 2012, 09:09 AM) <a href="index.php?act=findpost&pid=1894133"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->I am saying nothing of the sort. Don't presume to put words in my mouth.

    Now, with regard to decent lifetime, I was referring to the more "modern" features - an engine that is full of outdated technology when it is released is not attractive to modders, developers, or, more importantly, prospective customers either. A scripting "layer" built on top of the engine was one design decision that creates accessibility for modders, and allows for instant changes in-game. The others you know: dynamic lighting, no pre-compiling, etc. More than being marketed towards modders and developers, the decisions were made so that UWE could import, edit and test lots of assets and features in a very quick period of time, <b>without also requiring a very large team</b>. It was UWE's belief that the benefits outweighed the costs, and they still believe they will get it to work. Honestly, this was all explained by UWE the day they announced the decision to switch from Source to the as-yet-unnamed engine that became Spark (and by Max in one of the recent NS2HD interviews), and I'm just regurgitating it for your benefit. Your frustration is misdirected.<!--QuoteEnd--></div><!--QuoteEEnd-->

    Nobody will want to play a game that is not playable because it is unfinished, unpolished and does not run smoothly, regardless how good it is for modders and developers. And modders and developers are not the customers here. They do not pay the bills. Players do not care if UWE can test or import assets, or change the game while it is running. Of course they care about the visuals, but people play TF2 don't they?
    If I remember correctly they switched to Spark also because Source hat some limitations with regard to dynamic lighting and dynamic infestation. We have yet to see dynamic infestation (as shown in the teaser) and I think some maps are not played because dynamic lighting does not perform well.
    If I read "Fixed a networking bug with acknowledging reliable packets" in the changelog then I'm asking myself: Why are they not using a network libary for that. They are wasting time reinventing the wheel here. This goes for the whole engine.

    Don't get me wrong. I don't think the technology decisions are wrong. They just all cost time getting right now. I think that they should concentrate on finishing the game. They are not Valve. They do not have unlimited time. The first teaser announced it for fall 2009! And frankly I'm afraid they are going to run out of money before the game is finished. And I want to play that game!
    Of course it is too late now to revert some decisions. But why, for example, did they add those atmospheric effects? Nobody requested them. Nobody would have missed them. They caused performance problems. They do not add much value to the game.
    Or constantly twiddling on the balancing while nobody can aim, the hit registration does not work, server tick rate goes down in the late game and so on. Get that to work first. Publishing statistics and analysing them is a joke otherwise.
  • Kouji_SanKouji_San Sr. Hινε Uρкεερεг - EUPT Deputy The Netherlands Join Date: 2003-05-13 Member: 16271Members, NS2 Playtester, Squad Five Blue
    edited January 2012
    From what I heard the atmospherics and AA were very easy and fast to implement and they don't cause performance issues right now, unless you're running it on some kitchen appliance... on my old rig it takes away maybe 1FPS...
  • HarimauHarimau Join Date: 2007-12-24 Member: 63250Members
    <!--quoteo(post=1894219:date=Jan 14 2012, 04:21 AM:name=tobias3)--><div class='quotetop'>QUOTE (tobias3 @ Jan 14 2012, 04:21 AM) <a href="index.php?act=findpost&pid=1894219"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->unfinished<!--QuoteEnd--></div><!--QuoteEEnd-->
    See above.
  • NurEinMenschNurEinMensch Join Date: 2003-02-26 Member: 14056Members, Constellation
    Half-Life single player ran so-so on my comp back then. Multi player (HL DM) was horribly laggy and choppy. Just saying.
  • Visor1Visor1 Join Date: 2012-01-13 Member: 140300Members
    after reading through alot of post i've found the following commands that may help to improve your fps

    r_fog 0
    r_shadow 0
    r_bloom 0
    r_atmospherics 0

    r_instancing 0 *not sure what this suppose to do*

    These commands need to be entered every time you change server and even if you change sides. They may not make a huge difference in your base but in combat I notice a big enough boost. Does anyone know how to turn off the marine hud? I'm getting about 5fps higher as an alien and would like to see if it's causing the problem.

    net_stats will display the server preformance, network and fps very helpful in seeing where the problem is
    r_stats shows your fps and other graphics related info
  • Kouji_SanKouji_San Sr. Hινε Uρкεερεг - EUPT Deputy The Netherlands Join Date: 2003-05-13 Member: 16271Members, NS2 Playtester, Squad Five Blue
    edited February 2012
    r_gui false, but this one turns EVERYTHING off. You could test to see if there is an FPS gain, but I think it could be related to the view model, maybe the marine weapons are higher poly or the Flash elements on the waepons could be a cause.

    The odd thing is though, I don't see any difference in FPS between alien or marine view... Was it because you're in your base mostly so you have to render a lot more onscreen?
  • Visor1Visor1 Join Date: 2012-01-13 Member: 140300Members
    edited February 2012
    <!--quoteo(post=1900748:date=Feb 7 2012, 03:17 PM:name=Kouji_San)--><div class='quotetop'>QUOTE (Kouji_San @ Feb 7 2012, 03:17 PM) <a href="index.php?act=findpost&pid=1900748"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->r_gui false, but this one turns EVERYTHING off. You could test to see if there is an FPS gain, but I think it could be related to the view model, maybe the marine weapons are higher poly or the Flash elements on the waepons could be a cause.

    The odd thing is though, I don't see any difference in FPS between alien or marine view... Was it because you're in your base mostly so you have to render a lot more onscreen?<!--QuoteEnd--></div><!--QuoteEEnd-->

    Na I tested this by joining an empty server had a tick rate of 32 and running around the map. I've never notice a difference before though.

    Just tested with the gui on/off at different points on the map and there is a fps gain by turning it off. I did the test on the new map with the above commands off with net_stats running if anyone else wants to take a look and see if you get the same result.

    I tested removing the gui as an alien and also received a small fps boost. I ran fraps this time with net_stats and noticed a slight fps gain by not having net_stats running (standing still).
Sign In or Register to comment.