Faster Virtual Method Dispatch

Sean Kelly sean at f4.ca
Tue Apr 25 11:25:55 PDT 2006


In article <e2lhhq$6qv$1 at digitaldaemon.com>, Craig Black says...
>
>
>"Sean Kelly" <sean at f4.ca> wrote in message 
>news:e2lgsh$5tf$1 at digitaldaemon.com...
>> Craig Black wrote:
>>>
>>> If you think this is doable, then you should write a C++ version of 
>>> wordcount based on this principal.  If you can get comparable performance 
>>> to the D version then you may be on to something.
>>
>> I'd meant to do this and never got around to it.  However, the wordcount 
>> example is meant to compare performance using typical programming 
>> techniques for each language, and writing your own specialized containers 
>> isn't typical :-)
>
>That's not the point.  It demonstrates that the same performance can be 
>achieved without GC, and all the baggage that accompanies it.  So 
>performance-wise it would be like having your cake and eating it too.  If 
>this was possible, perhaps D could be streamlined to take advantage of this 
>somehow.

I merely meant that that's not the point of the wordcount example.  However,
I'll try and find the time to recode it using slices and hashtables in the next
few days.  IIRC that brings performance in line with the D version, so I suppose
that means you can "have your cake and eat it too."  It's worth mentioning,
however, that slicing with explicit memory management doesn't have quite the
utility it does with garbage collection.  It works great for apps where the
entire buffer can be loaded en masse, as with the wordcount example, but in
other cases it's a bit more complicated to manage the lifetime of the referenced
data.  Thus the GC version is still a clear win in terms of ease of use, whether
or not performance can be matched with specialized code elsewhere.


Sean





More information about the Digitalmars-d mailing list