On Thu, Jul 24, 2008 at 7:57 AM, André Pang <[EMAIL PROTECTED]> wrote: > On 24/07/2008, at 11:47 PM, Ken Foskey wrote: > >> Rule 2. If performance is not enough profile. >> >> Questions about inlining are largely redundant in a modern computer >> program. Most of the time is spent waiting for harddisk access. > > Inlining is a useful optimisation in itself, but it is most important > because it enables a number of other optimisations (e.g. loop hoisting, > constant folding, dead code elimination) that can speed up some code > significantly.
Of course, blindly inlining can really screw with performance too. If the function you are inlining is called from many places, even if it is small, it an make much more to have one copy of it which you jump to and reduce overall code size, rather than inlining it. Of course, if the function is smaller than code required to actually perform a call you should always inline. > And while I agree that the usual limiting factor in a modern desktop system > is I/O, I think that people tend to pass off performance too easily these > days. CPUs have certainly gotten a lot faster, but we're also manipulating > so much more data these days that performance still matters, and all those > micro-optimisations really do add up a lot. (I believe that compiling the > WebKit HTML framework with -fstrict-aliasing gave them about a 6% speedup -- > not bad for a single compiler switch. Combine that with a bunch of other > optimisations that speed things up by 5%, and suddenly things are running > 20-30% faster than before...) You can definitely make significant, order of magnitude improvements to code performance by optimising certain code paths. Of course, you want to make sure you have the 'big picture' architecture/algorithm right first. If a function is called millions of time during execution, my first inclination is to see if we can reduce the number of times it is called, rather than seeing what optimisation can be done to the function. Benno _______________________________________________ coders mailing list coders@slug.org.au http://lists.slug.org.au/listinfo/coders