[PATCH] misc size-shrinkage; merges

Rob Landley rob at landley.net
Wed Aug 30 18:47:21 UTC 2006


On Wednesday 30 August 2006 1:37 pm, Rich Felker wrote:
> I don't think it's quite the same as register. A reasonable user would
> expect a compiler never to inline functions unless -Obloat (-O3 or
> whatever) is specified,

Do you have your assumptions chiseled on your forehead every morning, or do 
you just have some kind of assumption megaphone strapped to your face?  You 
have proven repeatedly that you are not a good example of a "reasonable 
user", and your assumptions regularly disagree with reality.

You seem unaware that even -Os inlines small functions, and that there is in 
fact a _reason_ that it does so.  In fact, if there's only one occurrence of 
a function there's almost never a reason _not_ to inline it, it gives the 
optimizer more to work with.  And from a performance perspective, not 
inlining small functions is a big loss for cache reasons.  (Locality of 
reference is more important in modern systems than it has ever been.)

> The reason
> register is stupid is that there's no tradeoff involved; keeping a
> variable in a register is always preferred when possible.

The reason for register was that real world hardware has a finite number of 
registers and some variables are more important to have in registers than 
others.  The x86 architecture is generally referred to as "register starved", 
but even if you dismiss over 80% of the hardware on the planet to focus on 
your ivory tower you still have to pass stuff into recursive calls and across 
compliation boundaries (your entire OS and all applications in it weren't 
built in one invocation of gcc, and the real world uses shared libraries, so 
shut up) and that means you have to figure out what goes into registers for 
how long.  Some programs devote a register to a variable globally, such as 
when C++ tries to devote a register to the "this" pointer even on x86.

The reason "register" stopped being useful is that the compiler's optimizer 
got pretty good at figuring out when that was, and it also got good at 
keeping things in registers part of the time via dynamic loading/flushing 
techniques similar to all sorts of other resource management stuff, 
so "register" doesn't provide the granularity needed.

> But inline 
> may be good or bad and usually the compiler can't make the decision
> correctly.

Do you oversimplify things and then trumpet your child-safe view of the world 
as fact for a living, or is it just a hobby?

http://lwn.net/Articles/82495/
http://lwn.net/Articles/166172/

The compiler doesn't do the world's greatest job on this, but neither do most 
developers.  And the difference is the compiler's getting better.  Thirty 
years ago "register" made sense.  Five years ago "inline" made sense.  Times 
change.

(And now I remember why I put you in my spam filter last time rather than just 
resolving not to read your messages.  It's less aggravating.)

Rob
-- 
Never bet against the cheap plastic solution.



More information about the busybox mailing list