Re: [exim-dev] RFC: Refactoring expand_string_internal

Etusivu
Poista viesti
Vastaa
Lähettäjä: Philip Hazel
Päiväys:  
Vastaanottaja: Johannes Berg
Kopio: 'exim-dev@exim.org', Sheen, Tony
Aihe: Re: [exim-dev] RFC: Refactoring expand_string_internal
On Tue, 8 Aug 2006, Johannes Berg wrote:

> Sheen, Tony wrote:
> > For maintainability, the worst program I ever worked on had just a single
> > function - main() - but it ran like greased lightning which was the main
> > requirement! Formatting it nicely with 'proper' functions reduced its speed
> > by almost 15%.
> >
> I'm curious on what kind of machine all this has happened. Shouldn't, on
> a modern system/CPU, a small and often-used function be more efficient
> than inlining it everywhere because it'll stick in the CPU cache?


Tony didn't say anything about often-used functions - maybe there
weren't any. I'm no expert in this stuff, but even if there was an
often-used function, does having it in a memory cache balance the loss
incurred by breaking the instruction pipeline to go in and out of a
function? (Not to mention the cost of saving/restoring registers.) I
dunno - one would have to measure these things, and certainly the
hardware architecture could have a significant effect.

Note also that inlining small functions is a common optimising feature
of compilers. There must be a reason for it...


-- 
Philip Hazel            University of Cambridge Computing Service
Get the Exim 4 book:    http://www.uit.co.uk/exim-book