On inlining in C++

Robert Dewar dewar@gnat.com
Mon Aug 4 17:35:00 GMT 2003


> People are looking at this problem from two different angles:
> 
> a.  What will, on average, give the best performance?
> b.  What will, on average, cause the least trouble?
> 
> Andrew.

Right, those two angles always have to be considered. Note that the decision
in gcc to default to -O0 clearly is more concerned with consideration b than
a. This is probably reasonable, although it often costs gcc in benchmarks
against other compilers where optimization is the default (we have seen
behcnmarking protocols which require the default switches to be used, yes
that's silly, but it happens!)

> 
> "I do not believe that would be a surprise to anyone who thought about
> it for a minute."

You are assuming a model of someone who understands the possible effects
of inlining and knows what an instruction cache is and how it works. The
readership and writership of this list is hardly a representative cross-
section of "in the trenches" C++ programmers, who in my experience have
very little awarness of what is going on at the machine level.



More information about the Gcc mailing list