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

2.08K 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

Optimization is multi-faceted and covers a wide range of things.

Typically, when one ‘optimizes’ a game, one is trying to find the biggest overall ‘bang’ for the least possible cost — because it’s almost always a tradeoff, in time, money or resources.

The biggest optimization is how a piece of software uses memory. You can’t just shove everything into RAM and hope that it all works; there’s an efficiency bottleneck for swapping things in and out of RAM.

To optimize RAM usage, a programmer will carefully measure the size of what’s going into the RAM at any given moment. Textures are among the largest memory hogs, so RAM consumption can be lowered by using lower-resolution textures (or fewer overall) whenever possible.

The original Mario Brothers did this *wonderfully –* look at the clouds and the bushes, and you’ll see that they’re exactly the same object, with different colors. That’s a cost savings right there, because only one object needs to be loaded into RAM to display two different things.

The other way to optimize a piece of software is to figure out the most efficient way to use the CPU. Multi-threading allows a programmer to move or divide processor-intensive tasks off of the ‘main thread’ (that is, where the core of the software is expected to run) so that everything has its own space.

Think of this like a toll-booth operator moving garbage trucks and busses (which have to stop frequently) off of the main highway onto a dedicated side-road. Cars no longer get backed up behind busses and garbage trucks, so everything moves much more smoothly.

The third way to optimize a piece of software is often the easiest: simply design the software with memory and processor use in mind from the start.

Case in point: Al Lowe, the creator of *Leisure Suit Larry*, created an entire *maze* in LSL 3 by taking one single four-way ‘pathway’ scene, and using a single image of a bamboo thicket to block the exits he didn’t want the player to take. The entire thing only had to be loaded into memory once, and then it could be almost infinitely reused, for a fraction of the memory that would be required for a more elaborate maze with individual scenes.

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