On 15/01/2007, at 2:03 AM, Mars Saxman wrote:
The second thing you're talking about is a specific performance
optimization known as "call devirtualization". This is where the
compiler observes that a specific call target could not have been
overridden and uses that knowledge to generate a simpler call
sequence.
For the non-C++ people amongst us I'll expand on this.
1) C++ allows you to have "stack objects" within a function, which
are declared locally and have a lifespan only within that scope. The
compiler knows the exact type of the stack object, there's no chance
of it being a subclass, and therefore can devirtualize all calls to
methods of that object.
2) Ironically, C++ has a principle of "separate compilation" which
means most compilers do not consider classes from different files
together and so RB is in a better place to do whole-program
optimisation. There are some C++ environments I believe now starting
to do whole-program optimisation but it is far from mainstream.
You can achieve the equivalent of C++ choosing if methods are virtual
or not by using 'extends' methods currently in RB but I don't think
that is guaranteed forever - I don't think RS have ruled out making
'extends' methods virtual in future.
Inlining of small methods, which would require devirtualisation or an
explicit programmer declaration they were non-virtual, is the kind of
optimisation that makes a huge difference depending on your
programming style. I will admit that in RB I tend to write fewer
accessor methods. Having just moved to RB2007 from RB5, I will
experiment with the performance of Property methods to see how much
overhead they add. If the Get and Set methods are non-virtual, they
would be a good candidate for inlining.
The range of programming styles, application needs and algorithms
applied is so broad across a community like RB, it's probably
impossible for Mars to point to any one optimisation that will make a
big difference to people in general.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>