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

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

There are lots of different ways of optimising programs. Sometimes it’s possible to use a different algorithm that does exactly the same thing but faster. Sometimes it can be faster to store some results in memory or on disk so that they don’t have to be calculated again, sacrificing some memory/disk space for speed. Sometimes you can avoid doing something that is unnecessary or unimportant, for example, in a game, you might decide that there is no point in displaying details on distant objects since they would barely be visible anyway. Sometimes it’s possible to cut out some checks, for example you might have some code that keeps checking whether a value is zero even though it’s actually impossible for the code that changes this value to set it to zero.

These all sound like they should be obvious, but it can be very tricky to find ways of optimising code in practice. Designing fast algorithms can be very subtle, and sometimes it takes many years of research for someone to realise that there is a much faster way of doing something than anyone thought possible. A typical software package is very complicated and is made up of lots of different components, so it can be hard to understand how they all fit together and where unnecessary work is being done. And the operation of CPUs is pretty subtle – sometimes something that seems like it should be faster ends up being slower because it means the CPU has to move some stuff out of its cache, for example.

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