Jump to content

Discussion: Optimization


Recommended Posts

KSP continues to show sadly lacking performance for the level of graphics and functions the programming has to accomplish, especially on weaker computers.  This game really shouldn't take that powerful of a computer to run at vastly better performance levels than it does now, yet its performance for any given CPU and graphics card setup *is* lackluster relative to what it should be and a sometimes laggy game (especially on weaker computers) is what we have to work with...

I have started this thread as a development discussion thread: to solicit discussion of what the devs could actually do, in concrete terms, to improve the performance of the game (this is NOT a thread for off-the-cuff suggestions by people with no understanding of game programming, I want to see people with actual programming and optimization knowledge make specific educated suggestions here), and to remind the devs at SQUAD that the poor performance and lack of real optimization in KSP is still a major issue they need to work on, one that is still very much holding the game back from reaching its full potential.

 

For that matter, a small tangential bit of commentary and a liberty I am taking as thread author (please do not side-track the discussion by commenting further on this, it is only my opinion)- I do not think the game should ever have been declared "released" in its current state.  In my mind, the game will never truly be an acceptable product for a released game until it has seen a substantial amount of additional effort devoted to improving the game's performance (reducing lag, CPU load, etc.) within the context of its existing features.

 

Go forth and discuss!  And remember to keep the discussion educated, knowledgeable about the subject of programming, and on-topic!

 

- Northstar

Edited by Northstar1989
Link to comment
Share on other sites

  • 3 weeks later...

I'd say your first sentence is wrong.  Do you have any idea what it takes to calculate physics between multiple lego-style parts?  KSP is the first I know of to do it, a few others have been popping up but they don't come close to the scope of this game.  Do you have any idea what it takes to keep track of all the calculations associated with orbits and maneuvers?

You say it shows a lack of performance for the graphics and functions, I say you are taking stock of only the graphics and not the functions.  You want "pretty", I want a space simulator.  I'd like pretty too, but the gameplay comes first.

I think you are discussing based on a faulty premise.  Does that mean it is perfectly optimized? No, in fact if you have been keeping up with DevNotes, you would know they are doing an optimization pass now.  However, I wouldn't expect miracles from that, you might a small improvement and bugs may be easier to chase down on the development end once it is done, but the bulk of performance increase we will get came from Unity 5.

To put it simply, the game is more complex than it looks like from an outside perspective such as your own.  That is a good thing, it means they made the game simple enough for you and I to understand rocket science.

Edited by Alshain
Link to comment
Share on other sites

This is not an easy thing but here is some tips:
-lot of heavy calculations should be precalculated

-ease cpu to calculate phisycs only if the stress (forces) level are higher or lover than X
-if the vechicle seems to destroyed by an upcoming contact (crash) sould not calculate the event - just destroy the craft with a randomized way
-remove all the fancy menu animations (like in the main menu)
-remove all the ui transparency,especcially in VAB and SPH

-do not hide the loading screen while scenery is loading (craft pops early after hit the fly button)

-kill the animated water below the terrain,if still need it then at least dont use the water texture,use some blank really small placeholder texture (maybe need to define the water areas to use the default water text and effect on it)

-a lot of textures already bloated,it a nasty mess of ***** - resize the textures,you dont need 1024x1024 for a small landing gear or a small black seat...

-loading all the stuffs and assets just at the beginning of the game ? say no,its noobish,we programming this way back in the commodore era. (if ksp growing in the same way,we need a "insert game disk 2"

  soon or later :D (because out of memory))

-etc..


 

 

Link to comment
Share on other sites

 

 

9 minutes ago, Red Iron Crown said:

How would the game know what the stresses or forces are without calculating physics in the first place?

currently,i guess from the "noodle" rockets,ksp test forces within parts - for example:the rocket engine really needs to "know" where the landing legs? btw,i dont know,maybe grab the whole craft against the rocket engine until some heavy force come up to tear your craft apart.

Link to comment
Share on other sites

20 hours ago, Alshain said:

I'd say your first sentence is wrong.  Do you have any idea what it takes to calculate physics between multiple lego-style parts?  KSP is the first I know of to do it, a few others have been popping up but they don't come close to the scope of this game.  Do you have any idea what it takes to keep track of all the calculations associated with orbits and maneuvers?

You say it shows a lack of performance for the graphics and functions, I say you are taking stock of only the graphics and not the functions.  You want "pretty", I want a space simulator.  I'd like pretty too, but the gameplay comes first.

I think you are discussing based on a faulty premise.  Does that mean it is perfectly optimized? No, in fact if you have been keeping up with DevNotes, you would know they are doing an optimization pass now.  However, I wouldn't expect miracles from that, you might a small improvement and bugs may be easier to chase down on the development end once it is done, but the bulk of performance increase we will get came from Unity 5.

To put it simply, the game is more complex than it looks like from an outside perspective such as your own.  That is a good thing, it means they made the game simple enough for you and I to understand rocket science.

Then please explain why KSP is the only game I know that doesn't require mods to randomly crash even if I don't do anything special (like building 10000 parts ships), regardless of my specs.

Edited by TheDestroyer111
Link to comment
Share on other sites

1 minute ago, TheDestroyer111 said:

Then please explain why KSP is the only game I know that doesn't require mods to randomly crash even if I don't do anything special (like building 10000 parts ships), regardless of the player's system specs.

10000 part ships are such an edge case that they're barely worth considering. Sure you *can* build them, but there's no in game reason to and I'd imagine the percentage of players that do is vanishingly small.

Link to comment
Share on other sites

3 hours ago, anarkhon said:

-lot of heavy calculations should be precalculated

It's not really possible to "prebake" physics calculations for an unknown object in the same way as the lighting in a scene can be prebaked.

3 hours ago, anarkhon said:

-ease cpu to calculate phisycs only if the stress (forces) level are higher or lover than X

This is already handled via the physics engine. If you're not pushing on the craft, it's not calculating down-stream reaction.

3 hours ago, anarkhon said:

-if the vechicle seems to destroyed by an upcoming contact (crash) sould not calculate the event - just destroy the craft with a randomized way

If the game has already calculated that a collision is taking place, then it's already aware of what is colliding and can blow up the correct part. Also, I think this would lead to gameplay problems. For example, you're trying to dead-stick a plane into a controlled crash landing in rough terrain. The game decides that since the tail of the craft touched the ground, the cockpit should randomly explode.

3 hours ago, anarkhon said:

-remove all the fancy menu animations (like in the main menu)

The main menu scene isn't running or active in any way when the game is "in-flight." So removing the main menu isn't going to improve physics performance.

3 hours ago, anarkhon said:

-remove all the ui transparency,especcially in VAB and SPH

Possibly (and something to consider), but the lighting and animations in the editors are more demanding than the UI transparency (so that's what's being worked on).

 

Link to comment
Share on other sites

7 minutes ago, Red Iron Crown said:

10000 part ships are such an edge case that they're barely worth considering. Sure you *can* build them, but there's no in game reason to and I'd imagine the percentage of players that do is vanishingly small.

I said that ksp crashes WITHOUT building such huge ships, and this is the most unique thing this game has to offer.

Link to comment
Share on other sites

I have another tip:

Remove all foreach and LINQ occurrences in the code because the compiler the latest version of Unity ships with is handling them in a non-optimal fashion.

Anyone?

What?

 

To be serious for a moment: you might get away with a lower altitude switchover from planetary textures to planetary colliders, or whatever the appropriate technical terms are. And (perhaps) a voxel-based aerodynamic system that saves the voxelization and uses it instead of calculating the aerodynamics on a per-part basis might cause a performance boost. You could save several voxelizations based on control inputs (flaps deployed, full/partial roll/pitch/yaw) or calculate the effects of control inputs using solely those parts as deviations from the default voxel-matrix. (This isn't a snide 'look at how great FAR is', but actually a serious suggestion. But it'd need someone to think hard about it to figure out if you'd actually have any runtime savings.)

Link to comment
Share on other sites

1 minute ago, Jovus said:

Remove all foreach and LINQ occurrences in the code because the compiler the latest version of Unity ships with is handling them in a non-optimal fashion.

Specifically:

At the same time Mike and Jim, with the help of Bob (Roverdude) and Nathanael (NathanKell) have been working to update the game to Unity 5.4, a move that will allow us to fix a few long standing issues as well as increase performance in many ways. To help with that Bob, Brian (Arsonide) and Nathanael have been working their way through the project upgrading middleware such as Vectrosity (which we use to render orbit lines), removing old foreach() loops, Singletons and generally de-linqing the game. We recommend that modders to the same in anticipation of the next update to help increase performance for all KSP players. Linq and foreach() loops in particular create a lot of garbage, which is what causes the stutter that some people experience while running the game.

Link to comment
Share on other sites

16 minutes ago, TheDestroyer111 said:

Then please explain why KSP is the only game I know that doesn't require mods to randomly crash even if I don't do anything special (like building 10000 parts ships), regardless of my specs.

I can't explain it to you without amplifying information. I love nothing more than to try to dig around and find out why the game crashes, so that it can be fixed. KSP is a fairly novel game in that you can build ships out of random parts, in random ways, and do unexpected things...which gives rise to all sorts of unplanned code paths and unanticipated outcomes.

4 minutes ago, Jovus said:

Yeah, @Claw, that was the joke.

Ah, I see. Hard to tell in these sorts of threads sometimes. :)

Link to comment
Share on other sites

16 minutes ago, TheDestroyer111 said:

I said that ksp crashes WITHOUT building such huge ships, and this is the most unique thing this game has to offer.

What's your system, memory, video card, etc?  It's plainly worse for you than others.  I haven't had a crash in days.  But if I run it on my laptop, which has poor graphics and only 4 gigs of ram, it's not reliable.

That is the biggest thing that can be done to optimize the game, I think -- reduce memory use.  Some early design decisions, such as 'load every single part at start', no longer make sense.

Edited by Corona688
Link to comment
Share on other sites

7 minutes ago, Claw said:

Ah, I see. Hard to tell in these sorts of threads sometimes. :)

Don't I know it.

The other part, however, was serious. It seems like saving the shape of the craft on build and then treating aerodynamic forces according said shape might actually save cycles. On the other hand, maybe voxel-based calcs are actually more intensive than part-based calcs? I don't know. But I'd be interested to hear someone with more expertise opine on the subject.

Link to comment
Share on other sites

9 minutes ago, Corona688 said:

What's your system, memory, video card, etc?  It's plainly worse for you than others.  I haven't had a crash in days.  But if I run it on my laptop, which has poor graphics and only 4 gigs of ram, it's not reliable.

That is the biggest thing that can be done to optimize the game, I think -- reduce memory use.  Some early design decisions, such as 'load every single part at start', no longer make sense.

You see, the second most unique thing in KSP is that so many technical issues happen only for some people. But random crashing is a problem lots of people with different computers experience, even if you don't.

EDIT: Corona688 below, what's "Snark"?

Edited by TheDestroyer111
Link to comment
Share on other sites

Honestly, I can run KSP on a pretty affordable laptop with quite a few mods. Visual mods are beyond my laptop's capability, and the game textures have to be at half resolution, but the fact that it doesn't take a super-powerful custom-built gaming desktop to run means that personally I'm pretty satisfied.

Link to comment
Share on other sites

There is a lot of focus on part counts, but check how much CPU is being used on a clean stock install before even doing anything. I'm curious what is eating up CPU before anything even happens.

I will speculate again that using animation tools where possible as opposed to physics calculations could help. Planets and their moons could be hooked to a bone that moves along a path, it's current velocity determined by a simple animation curve. If the path is too much get rid of that and add 4 keyframes + animation curves. The bonus of this is that axial tilt would be easy to do by simply rotating the bone the planet is hooked to. Maybe this happens already, and maybe it is a pig resource wise, but in general bone animation takes very little cpu to calculate.

Link to comment
Share on other sites

1 hour ago, TheDestroyer111 said:

Then please explain why KSP is the only game I know that doesn't require mods to randomly crash even if I don't do anything special (like building 10000 parts ships), regardless of my specs.

I find that highly doubtful.  Either it's not true or you don't play many games.

Link to comment
Share on other sites

21 minutes ago, Waxing_Kibbous said:

There is a lot of focus on part counts, but check how much CPU is being used on a clean stock install before even doing anything. I'm curious what is eating up CPU before anything even happens.

I will speculate again that using animation tools where possible as opposed to physics calculations could help. Planets and their moons could be hooked to a bone that moves along a path, it's current velocity determined by a simple animation curve. If the path is too much get rid of that and add 4 keyframes + animation curves. The bonus of this is that axial tilt would be easy to do by simply rotating the bone the planet is hooked to. Maybe this happens already, and maybe it is a pig resource wise, but in general bone animation takes very little cpu to calculate.

Planets are already always "on rails", meaning their current position is a very simple formula that just depends on time, with no physics involved at all. I doubt that it would be a big performance change to replace that by bone animation.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...