discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: objective-c: how slow ?


From: Marko Mikulicic
Subject: Re: objective-c: how slow ?
Date: Sat, 08 Sep 2001 01:08:10 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.3) Gecko/20010801

Erik M. Buck wrote:
>>I admit I don't know in detail the lookup mechanism in the objc runtime
>>but I suppose that rebuilding the sarray after a inheritance change would
>>
> be
>
>>very expensive. Multiple inheritance requres a resoulution when the same
>>
>
> As long as the instance variable layout does not change, dynamically
> changing the super class of an existing class is one pointer operation.
> Each class object has a "superclass" variable.  The message cache tables are
> per-class (At least in my runtime and Apple's runtime) so changing a
> superclass automatically changes the method cache with no extra effort.

But this means that a cached lookup needs to walk through the inheritance graph.
IC-s cache the target where the method is effectively found so no cycles are
lost traversing the inheritance graph.
  I've made some simplified testing and it turns out that for a 10 deep
inheritance there is a 6% difference between calling the root and the child
(the test method returns the incremented argument). In this case IC are ~2.3
times faster than cached lookup.

What is the relationship between lookup speed and the number of methods in that class ?

It should not be an issue, expecially if the framework doesn't have many longer
inheritances. (not uncommon in Self)

I always assumed that selector based cache must flatten inheritance because
walking through it always seemd to me inpractical, but as it turns out it doesn't have a heavy impact in class-based languages. Self heavily use delegation which can considerably lengthen the walk.

A couple of questions:

Why sends to "super" are not directly called, if dynamic inheritance is not used ? (A compiler flag perhaps?)
Is this related to dynamic loading of classes ?
Perhaps super sends are a good place for ICs (you get 99.99% hits)

Do you think that the increase in code size due to PICs, and its presence in the icache, could lead to performance loss comparable to the gain (~2 times) in message sends ? (the performance loss can show up somewhere else, that's my worry)



Marko




reply via email to

[Prev in Thread] Current Thread [Next in Thread]