I picked this book up on a bit of a whim, to me it’s quite an odd thought to be worrying about performance that much if you’re writing C# code (coming from the games industry, if you care about performance you’d just write it, or parts of it at-least, in C/C++) but I was curious as to the techniques that people use to write high-performance .NET applications, and I learned some things that may come in useful later.

The book tackles the difficult issue of performance by spending a lot of time teaching you how to properly profile your code, giving detailed breakthroughs of various tools against specialised example code which demonstrates a real-world problem that the author has encountered, and these guides seemed very useful (though I admit I skim-read most of them instead of following along).

The first part of the book focuses on garbage collection, dispelling some of the myths and laying out best practices to avoid a large GC related performance hit. I was really interested to get in-to the guts of how the .NET GC system operates, and feel pretty confident that I could now track-down and solve any GC related performance issues.

The book goes on to discuss the JIT compiler, and outlines some techniques to reduce the amount of time that takes (although the author admits that the JIT is unlikely to be your major issue, baring in a few special cases) and then gives an interesting alternative to reflection that uses generated code to achieve the same thing but in less time.

Generated code isn’t something I’d ever looked at before and it seems very powerful (although not the sort of thing you should be using without good cause) but using it to perform tasks that usually rely on reflection is of particular interest, as I quite often have cause to do that (mostly when writing very-custom serialisation code).

The book spends a fair amount of time looking at threading, how best to manage multiple threads, make use of the threadpool, and which synchronization methods to employ in which scenarios. This topic was very useful to me as on the occasions where I do have to worry about the performance of my code, it’s usually to do with handing many threads at once.

Finally the book wraps up with some tips on how to create a performance minded team, which mostly echoes other team-building texts (find a champion, keep measurements, set concise goals, etc.)

This book is definitely worth reading if you are, like I was, ignorant of the types of things that will slow down your .NET code, and it’s worth keeping around as a reference text to help you accurately measure and solve performance issues.