[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Inlined code
From:       Mario Weilguni <mweilguni () sime ! com>
Date:       1999-05-28 18:17:18
[Download RAW message or body]

Am Thu, 27 May 1999 schrieb Waldo Bastian:
>pbrown@redhat.com wrote:
>> 
>> On Thu, 27 May 1999, David Faure wrote:
>> 
>> > > Modified Files:
>> > >     kconfig.h
>> > > Log Message:
>> > > hasKey() returns false if the key's value is null.
>> >
>> > Does it have to be inline ?
>> > This commit forces full kdebase recompilation (I know, it's not the only one those
>> > days !) but that's nonsense as the API isn't changed.
>> > Such a big method being inline is a waste of memory isn't it ?
>> 
>> It gets used a lot.  I don't know, what's the rule of thumb here?  I
>> inlined all the functions that get used a lot when I redid KConfig.  I am
>> sure it increased code size, but I thought it was the right thing to do.
>> Maybe not, I can't be sure.  Opinions?
>
>Some rule of thumbs:
>
>* Use inline for simple setXXXX/getXXXX-like functions only.
>* If code has a performance problem and profiling _shows_ that
>  inlining a function improves the performance significantly, 
>  inline the function.
>* Never assume that something will improve performance without
>  actually measuring it.
>
>Basically you want to reduce the use of inline functions as much
>as possible because:
>
>* it will increase compile-times 
>(everyone including the header-file has to compile the inline-
>functions),
>* you need to recompile a lot if a change is made in the 
>implementation and 
>* it might increase memory usage.
>
>The above rules of thumb try to balance these disadvantages 
>against the advantages (faster execution).

QMap is an excellent (I mean bad) example. Most of it's code is inline,
whenever you use it, it will take ~2 kb of code. If used excessive, it will
slowdown execution too because of cache and pipeline problems (at least this
applies to pentium processors, code which is not in the cache at execution time
will be reloaded into cache, and will be executed only in one of it's two
pipelines (the U pipeline), making it slower than it could be).

Mario

--
Q:  How many heterosexual males does it take to screw in a light bulb
    in San Francisco?
A:  Both of them.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic