How does game “optimization” work? Are people sitting there changing lines of code to more “optimal” ones? What is “optimized”?

1.95K views

The recent The Last of Us for PC made me realize I had no idea what’s meant by “optimizing” a game.

Same with optifine in Minecraft improving performance. How do these things work to just make games use fewer resources?

In: 158

105 Answers

Anonymous 0 Comments

It’s complicated. Even game developers clearly don’t get it right all the time. But a simplified example would be – don’t load textures into RAM before you actually need them. This will reduce the amount of RAM (or video memory – VRAM) required. Because high VRAM usage is a known problem with The Last of Us, this seems like a good solution. But let’s say you didn’t load the textures needed to display a certain building or enemy. Then the player turns a corner, it’s supposed to come into view, but there would be a brief decrease in performance or delay before it could be displayed, because you didn’t load the texture ahead of time and suddenly you need it. So this “good idea” of being conservative with the textures you load ahead of time has become a problem…

Perhaps you could check where the player is to help determine what they are *likely* to see or where they are *likely* to go, now you can load the textures they actually need without missing any or loading excess ones they don’t need. Seems like a good solution right? Problem is, that’s additional work the computer needs to do, and players can be unpredictable in the directions they travel or look, so all that work could just lead to the computer making a wrong prediction about what stuff it should or should not prepare for.

Besides loading textures, there is other work that a game can skip for items that are too far away to see or obscured by other objects. But what if the player comes around a corner and suddenly can see those objects again? It’s a balancing act to get this right and try to predict what work is valuable or wasted.

So it’s a balance of – do stuff that is necessary – don’t do stuff that is unnecessary – don’t mess that up. It’s going to be different for every game and no single solution will give the best possible performance for all players who go through the game differently. So it will never be *perfect* and getting it *good enough* requires a lot of work and testing. If you don’t budget and allow time for it, it’s not going to happen automatically by clicking an “optimize” button right before you release the game.

You are viewing 1 out of 105 answers, click here to view all answers.