Step 3: Fix the problem

Submitted by epreisz on Sun, 02/11/2007 - 08:11.

Resolving the biggest optimization opportunity is ultimate goal of your optimization efforts. Although I’m not going to go into every way to fix an optimization problem now, I do want to cover some general details about fixing slow code.

We will fix issues at all levels of optimization. In general, we want to optimize in the order of system, application, and micro optimizations. The magnitude of work involved in a system level optimization is usually larger than that of an application or micro. The magnitude of an application optimization is usually larger than that of a micro optimization.

Even if you don’t decided to fix any system level issues, you should at least understand the potential optimizations before moving to the application or micro level. When we fix issues at the system level, we are looking for opportunities to utilize our hardware better.

If you determine that you are only using 50% of your CPU, it usually means that your machine supports optimizations for multiple threads. Adding another thread, if done correctly, may significantly increase performance throughout your entire application.

If you determine that you are only using less than 85% to 90% of your GPU, it may be possible to move processing from your CPU to the GPU. Balancing is the term we use to describe the process by which we move processing from an over-utilized resource to an underutilized resource. Moving particle system processing from the CPU to the GPU is one popular example of balancing.

Choosing the correct algorithm is the key to application level optimizations. By first understanding the details at the system level, we can make better decisions about which algorithm to use. It’s important to know that the computational complexity, described by big “O” notation isn’t the only factor in performance. Algorithms with the same big “O” notation may run at different speeds in you application. This is due to their implementations and the resources they consume.

For example, let’s consider two big “O” algorithms of n log n. One is memory efficient and one is computationally expensive, yet they both have the same big “O” notation and on paper, perform the same. If we are already pushing the limits of our performance due to memory issues, a sort with a big “O” of n log n that consumes or fragments memory will not be as fast as a big “O” n log n that is more memory efficient.

Everyone is always searching for the fastest triangle, but they are missing the big picture. The fastest triangle you can render on a graphics card is the triangle you don’t draw at all. Obviously this doesn’t mean that we shouldn’t draw triangles, but what it does mean is that we should make every effort possible to not draw the triangle if it isn’t visible. For example, if a game object, let’s say a zombie, is behind a wall, then don’t draw it. The processing it takes to disregard the zombie as a currently visible object is probably less than the processing it takes to render it.

The same concept is true of other computer operations. The fastest memory we can use is the memory we don’t need to use. The fastest calculation is the calculation we can omit. The fastest pixel we can draw is the one we omit. If we can omit groups of process intensive calculations with one comparison, the resulting performance gains are even more substantial.

Omitting processing on objects is a very common way to enhance performance. Quad trees, oct trees, BSPs are all designed to quickly return objects located near each other. We can traverse these methods to determine quickly if an object has intersected with the camera frustum or a other geometric entities such as rays. LOD, an acronym meaning Level Of Display, is a term we use to describe a system that reduces the amount of processing without changing the experience of the user. A simple example of a LOD is to reduce the number of polygons on an object as it moves farther away from the user. The reduced poly count will not distract the user since the object takes up fewer and fewer pixels on the screen. It is also possible to LOD AI, physics, and processing of animations if they are far away from the user.

Micro level optimizations will help increase the performance of already existing algorithms. Micro level optimizations are a great way to achieve performance without having to change large sections of code. They can be extremely helpful when deadlines are approaching and the time it takes to perform system or application level optimizations simply doesn’t exist. Again, understanding your available resources may greatly effect how you plan to optimize at the micro level.

Throughout these readings we will cover optimizations for the following sections of a gaming application:

  • CPU
  • Memory
  • Threading issues
  • Bus
  • GPU
  • API usage

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Viagra

ryVCODJL Viagra :-O Cialis =-]

Buy Viagra

jWyLDPSV Buy Viagra jEnnm Buy Cialis Online >:]]

Buy Cialis Online

IHchthBM Buy Cialis Online 5722 Viagra :-O Cheap Phentermine >:-OOO

Buy Cialis Online

mhoEbB Buy Cialis Online xZzHj Cheap viagra 3900 Ambien QcmEF

Cialis

WoYqJXy Cialis 2831 Viagra 6330 Valium obTRRT

Buy Viagra online

BFLxtL Buy Viagra online SqbUR Xanax DNwoMY Buy Cialis 3550

Cialis

tefMKPW Cialis kfkQu Viagra SCxUFy Cheap Phentermine 8105

Cialis

tyGIete Cialis >:-[ Buy Viagra online >:]] Cheap Tramadol QGolx

Valium

iPiHzgSh Valium jlOPM Cheap viagra OyGiqV Ambien 0492 Cialis 8384 Buy Xanax 0626 Phentermine AACyd

Cialis

eAlRcl Cialis EFWyt Buy Viagra 2086 Phentermine online EpUgv

Phentermine

ieYIpU Phentermine 6907 Buy Ambien kkgStg Cialis 4832 Viagra >:]] Cheap Valium hHNlF Xanax bYuNW

Tramadol

DBUdykYT Tramadol WLGvrb Cheap Phentermine puXXz Cheap Xanax GWGLJ

Viagra

EWElEZ Viagra 0262 Cheap Cialis %-[[[

Viagra

pwnSRt Viagra 1283 Cheap Cialis :-O

Tramadol

VIdDXH Tramadol qENXc

Xanax

dBikXUam Xanax azjhYa

Buy Viagra online

Phentermine

Cheap viagra

Viagra

Buy Ambien

Viagra

ywQOlM Viagra Cialis

Buy Viagra

Xanax online

Buy Viagra online

Cheap Valium

Buy Viagra

Buy Valium

Viagra

Xanax

Buy Viagra online

Cheap Xanax

Viagra

EFCSLFvI Viagra Cialis

Phentermine

Viagra

JJwGbRbM Viagra Cheap Cialis

Buy Viagra online

Valium online

Cheap Phentermine

Buy Viagra online

Xanax

Viagra

KLDBrzN Viagra Cialis

Viagra

fAejqDtb Viagra Cheap Cialis

Xanax online

Cheap viagra

Viagra

Phentermine

hVKjhvq Phentermine Xanax

Buy Viagra online

Buy Viagra

YrUykoUO Buy Viagra Cialis

Viagra

ekMwBCvw Viagra Cialis

Cheap Phentermine