What is “optimization” in video games and why does it affect performance

304 views

also is improving it just a matter of time? like a process of refinement?

In: 1

4 Answers

Anonymous 0 Comments

Optimization means locating the program’s bottlenecks – parts of your code that take up the most resources (usually time, but sometimes memory) – and making them take up less of those resources. This could be done in many ways, such as optimizing the actual algorithms, storing parts of the calculation in memory (to avoid calculating things over and over again) or even simplifying the program (getting less accurate but faster results).

Anonymous 0 Comments

>also is improving it just a matter of time? like a process of refinement?

You refine code by making sure it does exactly what you want with only the resources it needs. This becomes harder and harder the more complex your programs become.

For example: In order to have a program calculate stuff you need to store values in things called “variables”, placeholders that get juggled around by code functions and can get filled with different numbers. Before the program does that it needs to reserve memory space for that variable in RAM. Now if your variable is a “long” it can store all the whole numbers between -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. That takes 8 bytes of memory that the program needs to reserve. But what if the values stored in that variable never become **that** large or small? What if the variable is only used to store… the day of the month? That’s never going to become bigger than “31”! You could use a different variable type in this case, a “*byte*” for example. That only can store numbers from -128 to 127 but also only reserves **1 byte of memory**. You now optimized the program to only use 1/8 of the original RAM requirements without affecting its function!

Anonymous 0 Comments

I think most programmers would agree that when making a large program like a game, the standard would be something like: make it readable, make it work, make it good, make it fast, in that order. Making a program that is easy to understand by everyone on the team is a priority over doing all those little CPU tricks that make programs run faster. But let’s be honest, those things are going to have to get done eventually. So let’s imagine a simplified version of making a video game. I’m imagining a working title of “Batman: Arkham Shopping Mall”

Pass 1 of the game has a working prototype…. It might not switch to low-polygon versions of graphics at long range, might follow the rules of lighting at all times, draw the whole world on the graphics card even if parts are invisible to the player (eg: behind them), all the loot in the world might just be in one giant list to be consulted, etc. This results in a game that runs and looks really good, but only gets like 15 FPS. Technically working, but not something you could sell. How do we improve this?

Pass 2 of the game is improved to not draw what’s behind the player, distant objects follow a simplified lighting rule instead and use low polygon versions of graphics except for NPCs, and the loot list is sorted geographically but only on the X coordinate making searches faster on average. Framerate is now 25 FPS, but distant objects tend to very obviously pop in and out of their low polygon versions. More work is needed.

In pass 3 the map now has internal grid lines and each grid square indicates which other grid squares are possibly visible, allowing only visible terrain to be drawn. There are low polygon versions of NPCs now and even medium polygon versions for mid range. The list of loot is also part of the grid square system and so is always a short list of important things, changing as the player crosses those grid lines. FPS shoots up to 45 and the GPU is no longer at 100% all the time on the test machines.

In pass 4 an advanced analysis tool was let loose on the game while it ran through the test scenarios. The enemy AI code was using 40% of the CPU usage – much higher than expected – and so that had to be investigated because the test case had the player never within sight of the enemy. It was discovered that the enemy AI was aggressively searching for the player but not taking advantage of the grid system or their own field of view (in front of vs behind the enemy) to determine whether there was even a chance of being seen, causing all enemies all over the map to do extensive geometry math.

I’ll let you imagine what passes 5 through 20 look like. Hopefully this gives you an idea of what “optimization” is.

Anonymous 0 Comments

Optimization is a really broad term that encompasses a lot of different things, but essentially it’s making the game perform better, or take up less CPU/GPU time and memory space than it currently is. For example, when a level is first made, it might only run at 30 fps, but the developers have decided they want their game to run at 60 fps, so now the developers need to go through all the art and systems that make up the level and figure out how to make it run more efficiently. So for example, the artists could go through the level art and find unnecessary details that they can take out. The programmers will go through the code and figure out which parts are taking the longest to run, and how they can make those parts run faster. They’ll set certain parts of the levels to be unloaded, and only loaded in when they’re needed, so time isn’t wasted on things that aren’t being used, for example if you go inside a building, a lot of the outside world will be unloaded since you’re not going to be able to see it anyway. There’ll also be systems to replace far away objects with much lower detailed versions of the object, the player won’t notice the extra detail at that distance so why waste CPU time on it.