Developer Page

Martijn Klingens kde-optimize@mail.kde.org
Sat, 11 Jan 2003 17:47:08 +0100


On Friday 10 January 2003 02:10, Benjamin Meyer wrote:
> I didn't get any C++ optimization book recomendations from anyone.  Does
> anyone even have one?

Well, the basics of optimizations don't lie in the language or tools used 
anyway, but in the algorithm itself. Whereas algorithmic optimizations are 
generally measured in the _factor_ of performance improvements, the gain when 
shuffling around code to do a += 1 or ++a instead of a++ is generally only a 
percentage. Also, such optimizations tend to be _HIGHLY_ compiler and 
platform (both hard- and software) dependent, so they don't always pay off 
well, whereas algorithmic changes tend to do.

In the case where we don't have a lot of control over the code it might pay 
off, like using static over an anonymous namespace because it speeds up 
dynamic loaders and gcc/ld don't optimize out dynamic namespaces well, but 
again, you're basically optimizing towards a single or a few platforms, so 
it's only really worth the effort in extremely hot code paths.

The books that learnt me most about optimizing in general were the books 
written by Michael Abrash. I once borrowed Zen of Graphics Programming and 
Zen of Code optimization 
http://www.amazon.com/exec/obidos/tg/detail/-/1883577039/qid=1042302164/sr=1-5/ref=sr_1_5/002-8483024-2856842?v=glance&s=books
which seems to be poorly available these days. It's a bit older now too, 
though an awful lot of the general stuff is still _VERY_ applicable. The 
parts about hardcore asm-optimization are obviously highly outdated today.

There's also the Graphics Programming Black Book, which I bought when I 
returned the above books to their owner. This is essentially the above two 
books bundled in one, together with a few additional chapters and on cdrom 
his older book Zen of Assembly Language.

http://www.amazon.com/exec/obidos/tg/detail/-/1576101746/qid=1042302164/sr=1-2/ref=sr_1_2/002-8483024-2856842?v=glance&s=books

This one too is poorly availble though :( (and a lot more expensive than the 
~75 Euros that I paid for it).

-- 
Martijn