performance of OO dispatch in inner loops

ToolmakerSteve98 toolmakersteve98 at shawstudio.com
Fri Mar 21 05:32:11 PDT 2008


ToolmakerSteve98" wrote:
>
> "Brendan Eich" wrote:
>> Why do you believe static typing is necessary for performance? Just
>> curious.
>
> I woke up in the middle of night, remembering one detail we hit in 1992.
> Advanced OO programming styles lead to inner loops that contain 
> (potentially
> subclassed) method dispatches. THAT'S the bottleneck, not the speed of
> arithmetic computations. Doesn't JIT well, because each "inner loop" (code
> bottleneck involving repetition) is a cooperative effort between multiple
> objects, any one of which might show up as a different subclass in the 
> next
> loop iteration.
>
> Not awake enough right now to think through whether more modern JITs
> (tracing) successfully unravel this case. If so, then it is a matter of
> careful cache design. If not, then I think this is where static typing (or
> more precisely, constructing an object knowing that it has given 
> interfaces;
> in theory this could be done for dynamically typed objects if you can
> determine at construction that it satisfies the interface) makes possible
> higher performance execution than dynamic typing.

More bad news for dynamic typing as I remember the details more clearly:
turns out the quentessential activity in the complex control logic we were 
seeing for interactive multimedia, is that one object queries another object 
for one or two properties, does a tiny bit of decision making using that 
info and its own properties, modifies its state a bit, then fires a message 
off elsewhere. Performance was dominated by how fast you could get at 
properties on yourself and on the objects you were cooperating with. The 
better you could pin down ahead of time how to get hold of those properties, 
the better your performance.

~TMSteve




More information about the Es4-discuss mailing list