On 9/6/2011 3:40 PM, Alain Ketterlin wrote:
> jacob navia<> writes:
>
>> Le 06/09/11 21:13, Lynn McGuire a écrit :
>>> Thanks, I had not thought about the direct calls just
>>> directly binding to the proper method. I'll bet that
>>> there are few direct calls in our code though as we
>>> have many children classes.
>>>
>>> ObjPtr -> DataGroup -> GenGroup
>>>
>>> ObjPtr -> DataGroup -> NodeGroup -> StreamGroup
>>>
>>> are a couple of example lineages.
>>>
>>> Lynn
>>
>> This is completely ridiculous. An indirect call vs a direct call
>> will cost you some pipeline turbulence and the cache may be flushed,
>> really not a big deal.
>
> Depends on the code. With lots of small methods (a la Java, with
> getters/setters all over the place), it may be significant, mainly
> because of the impossibility to inline. Take any program, compile it
> with inlining disabled: the difference may be significant.
>
>> Have you MEASURED the slowdown? Is it significant in relationship
>> to OTHER improvements in your code?
>
> Hard to measure. You need to change tens/hundreds of classes...
>
>> Have you profiled your code to KNOW where it is spending 90% of the
>> time?
>
> In the case I mention above (many small functions), the overhead would
> be spread over a large part of the code. Profiling becomes less useful.
>
>> Before you answer THOSE questions, worrying about direc/indirect
>> calls is WASTED time and effort.
>
> I've just done this on a piece code that was evaluating an expression
> tree on each vertex of a 4D grid, with an insane number of
> floating-point ops. Incredible speedup (~120). Granted, the original was
> over-engineered, and this may be a corner case.
>
> Regarding Lynn's case, I would say you're right: he may be better off
> keeping his current design safe rather than trying to save a few cycles.
>
> -- Alain.
You are more than correct, I was just wondering. In fact, we
saved millions of cycles by porting our code from Smalltalk
to C++. We had to do it anyway, our Smalltalk variant was
Win16 (don't even go there !) without a Win32 port. I would
not be surprised if we got a 100X speedup by converting to
C++ and Win32. Our current design is solid and will not be
changed - we have many other dragons to slay.
Thanks,
Lynn
|