“Video Game Optimization” – a good book

I had the chance to spend some quality time with Preisz & Garney’s recent book “Video Game Optimization” a few weeks back, as I was trapped in a 14 hour plane flight. I hardly spent all that time with it, though I probably should have spent more. Instead, “Shutter Island” and “It’s Complicated” (with bad audio) are four hours out of my life I’ll never get back.

This book goes from soup to nuts on the topic: types of optimization, how to set and achieve goals, discussion of specific tools (VTune, PIX, PerfHUD, etc.), where bottlenecks can occur and how to test for them, and in-depth coverage of CPU and GPU issues. Graphics and engine performance are the focus, including multicore and networking optimization, plus a chapter on consoles and another on managed languages. Some of the information is in the “obvious if you’ve done it before” category, but critical knowledge if you haven’t, e.g., the first thing to do when optimizing is to create some good benchmark tests and lay down the baselines.

There are many specific tips, such as turning on the DirectX Debug runtime and seeing if any bugs are found. Even if your application appears to run fine with problems flagged, the fact that they’re being flagged is a sign of lost performance (the API has to recover from your problem) or possible bugs. I hadn’t really considered that aspect (“code works even with the warnings, why fix it?”), so plan to go back to work with renewed vigor in eliminating these when seen.

I also liked reading about how various optimizing compilers work nowadays. The main takeaway for me was to not worry about little syntactic tricks any more, most modern optimizers are good enough to make the code quite fast.

There’s very little in this book with which I can find fault. I tested a few terms against the index. About the only lack I found was for the “small batch problem“,  where it pays to merge small static meshes into a single large mesh when possible. This topic does turn out to be covered (Chapter 8), but the index has nothing under “batch”, “batching”, “small batch”, etc. There is also no index entry for “mesh”. So the index, while present (and 12 pages long), does have at least one hole I could detect. There are other little index mismatches, like “NVIDIA PerfHUD Tool” and “NvPerfHud Tool” being separate entries, with different pages listed. Typo-wise, I found one small error on page 123, first line should say “stack” instead of “heap”, I believe.

Executive summary: it’s a worthwhile book for just about anyone interested in optimization. These guys are veteran experts in this field, and the book gives specific advice and practical tips in many areas. A huge range of topics are covered, the authors like to run various experiments and show where problems can occur (sometimes the cases are a bit pathological, but still interesting), and there are lots of bits of information to mull over. Long and short, recommended if you want to know about this subject.

To learn more: first, look inside the book on Amazon. We mentioned here before Eric Preisz’s worthwhile article on videogame optimization on Gamasutra. A very early outline of the book appears on vertexbuffer.com. For me, it’s great to see that this is a passion for the first author – that comes through loud and clear in this book. I’ve added it to our recommended books section.

One little update: Carmack’s inverse sqrt trick, mentioned in the book on page 155, is dated for the PC. According to Ian Ameline, “It has been obsolete since the Pentium 3 came out with SSE. The rsqrtss/rsqrtps instructions are faster still and have better and more predictable accuracy. Rsqrtss + one iteration of Newton/Raphson gives 22 (of 23) bits of accuracy, guaranteed.”

Tags: , ,


  1. EricPreisz’s avatar

    Thanks for the review and the notes. We are glad you found it a useful read!

  2. Wussie’s avatar

    I have read this book as well and have to say that I agree with pretty much everything said here.
    It’s a definite recommendation, even if you’re not specifically interested in actively squeezing every last bit of performance out of your game, it provides a very valuable insight into the techniques you’ll want to master and issues that might arise when you eventually run into performance problems.

  3. bengarney’s avatar

    Awesome, thanks for the review! This is one of my go-to blogs for graphics programming so it’s a huge thrill to be mentioned. 🙂

    Echoing Eric’s comments – it’s great to hear the book is useful even for experienced developers!

  4. morgan3d’s avatar

    Regarding the rsqt instruction, a year ago I profiled various “fast” rsqrt methods (in C) on Intel Core2 under MSVC9 and found the following, for processing a single float32:

    Lomont’s sqrt -> 0.48 ns
    sqrtf(x) -> 3.77 ns

    powf(x, -0.5f) -> 45.54 ns
    Walsh’s* rsqrt -> 5.45 ns
    Lomont’s rsqrt -> 5.44 ns
    1.0 / sqrtf(x) -> 3.49 ns

    All had vanishingly small error for 10^8 randomly selected values on [0, 3], except for Lomont’s sqrt approximation, which had a huge RMS error of 0.34. So I confirm that this is a case where the compiler “just does the right thing”, except that it doesn’t recognize that powf(x, -0.5) is rsqrt.

    * this is the thing often attributed to Carmack

  5. wrice127’s avatar

    The book didn’t consider console games, xbox360 and ps3; although it had one chapter “console” it wasn’t detail enough.

Comments are now closed.