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

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

Often in program code there’s multiple ways to do something and the simplest way often isn’t the fastest way. Sometimes the fastest way is just downright ugly and horrible to look at. When you’re working on some giant program that’s still changing and more stuff is being added to it, often it’s better to pick the simplest way even if it’s slower. This is because programmer confusion is a huge source of bugs, where multiple humans are going back into the same program and changing each other’s stuff as more gets added. Anything to cut down on programmer confusion during this phase is a good thing. You need for all your programmers to easily and quickly understand what each other did.

This is one reason to deliberately NOT pick the most fast, optimal way to write the program. Programmer time is way more expensive that CPU time, and making things more complex (as is often needed to pick the fastest solution) increases programmer time.

Another reason to deliberately not pick the most fast, optimal way is because in the early stages nothing is set in stone yet. Writing an optimal fast version of the program is often based on a lot of assumptions like “this scenario cannot happen, that scenario cannot happen, therefore we don’t need a generic solution that handles them…” But if the assumption “this scenario cannot happen” is based on a current design that is likely to change, it’s not safe to write code that depends on it.

Later, toward the end, when all aspects of the design are more set in stone, and you aren’t adding new features as much, it becomes safer to go in and make previously simplistic crude code into much faster but harder to understand code.

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