[MUD-Dev] Languages

Chris Gray cg at ami-cg.GraySage.Edmonton.AB.CA
Fri May 23 08:25:04 CEST 1997


[Ben G:]

:I'm curious about some things.  What exactly makes c++ slower?  Is it
:more class calls because most ppl make accessing class data a function 
:call?	Perhaps inheritance mapping of some sort?  I head that a c++
:compiler basically just translates the code into c before compile anyway..

The larger number of function calls (at the implementation level) is one
of the biggest slow-downs, I think. Asside from the obvious effect of
executing more instructions, that type of code slows modern CPUs down
even more because it is hard on the instruction cache and on any branch
prediction and look-ahead stuff. I don't know if there any CPUs yet that
can successfully look-ahead through a C++ virtual function call, but I
doubt it. That pretty well shuts off a lot of look-ahead and pipelining
until that call has been resolved. Having lots of small functions (many
of which don't don't actually do anything useful!) results in lots of
instruction cache misses, resulting in execution closer to main memory
speed rather than CPU clock speed.

--
Chris Gray   cg at ami-cg.GraySage.Edmonton.AB.CA



More information about the mud-dev-archive mailing list