glib dependancy in KDE3.x

Maks Orlovich mo002j at mail.rochester.edu
Fri Mar 7 18:37:44 GMT 2003


On Friday 07 March 2003 01:27 pm, Guillaume Laurent wrote:
> On Friday 07 March 2003 19:15, Maks Orlovich wrote:
> > Pointless use of virtual functions is of course wasteful.
>
> Last time I actually tried to measure how "wasteful" that was (repeated
> calls to a function doing a sqrt(), virtual or not), I had to raise the
> number of iterations to 1 million before there was any measurable
> difference (about 1 second out of 20 or so). That was on a P-III 600 MHz.
>
> 'virtual' overhead will be drowned in statistic noise as soon as your
> function is doing anything serious, like IO.

Yes, IIRC, someone measured it to be like 1.1 times of a regular function call 
on typical implementation; I really should bookmark that report on C++ 
performance, it's very interesting. I do think that the overhead of not 
making something virtual when it should have been will hurt one so much that 
making everything virtual would be better (i.e. by forcing extra work or code 
dup in place of a neat tiny inheritance integration). Anyway, my point was 
that trying to do it manually is a bad idea, since it assumes one can do it 
better than the compiler. I doubt that, especially for such simple set ups, 
where the compiler is probably using techniques that represent the state of 
the art when its ABI was designed for simple things like this. And of course 
it can incorporate all sorts of platform-specific knowledge in, too.

One place where I do think it matters is trivial inline accessors -- it can be 
non-trivially faster to store something into a base classes member and access 
it inline instead of having a virtual return it. Of course, this only matters 
when the relevant path is incredibly hot, and should only be done based on 
profile feedback.






More information about the kde-core-devel mailing list