tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Functions locality and instruction fetch



On Sun, Jan 27, 2013 at 05:14:24PM +0000, Sad Clouds wrote:
> 
> The question that was bugging me is this: if in the source file I write
> functions in linear order:
> 
> f1()
> f2()
> f3()
> ...
> f10()
> 
> will GCC generate their binary code in the same linear order,
> clustering them together in memory addresses?
> 
> I ran 'nm' on binary files and it seems the above holds true, at least
> for GCC, but I would be wrong...

I've seen object code where that isn't true.
I've sure some versions of gcc re-order stuff - especially for static
functions.

Why do you want functions adjacent?
- to reduce the number of active TLB ?
- NUMA systems copying physical pages into local memory
- avoid some long instruction sequences for long jumps (don't they have
  to be generated anyway - unless they are linker generated trampolines)?

Sun might have had NUMA systems.

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index