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

Worth it for an object to caching its own IMPs?



On Mar 1, 2004, at 7:22 AM, Eric Noyau wrote:

> This has been said before, but I'd like to add another voice to the 
> fray: do not optimize without measuring first. You said first you 
> wanted to optimize because:
>
>> I'm in a situation where an object is calling methods on itself 
>> frequently and latency is important.

It was just one strategy I was entertaining. I never considered it the 
most efficient approach, just something to take the edge off.


> From this I can assure you that ObjectiveC message passing is not 
> likely to be your most important performance hit. The Objective-C 
> runtime is already caching most of the cacheable information anyway. 
> If you touch the disk even just once to read a file message passing is 
> going to be in the order of the insignificant...

I misspoke when I said "parsing." What I really meant was finding an 
object somewhere in an arrary/dict tree. I didn't expect imp caching 
would be a replacement for changing the implementation, just wanted to 
see what it would do.

In most cases, I wouldn't bother with this approach. But this really is 
a special case where a method is being called very frequently inside 
many tight loops.

It might also be that the autoreleased objects I'm getting back from 
KVC could be piling up, but I'm not sure what to do about that. It 
would be nice if there was some way I could use KVC without 
autorelease. I already have manual retain/releases in effect almost 
everywhere it makes sense. I guess I could try more autorelease pools 
too, but I'm not sold on how big of a difference that makes in terms of 
overall performance.


> Write your code, make it work well, and if it is too slow then, and 
> only then, measure the performance.

I'm well past this point.  :)


> The only case where I can remember IMP caching yielding a nice 
> performance boost was in the implementation of KeyValueCoding when it 
> was used only by EOF, not a piece of code you should be writing 
> everyday.

I was just trying something low-risk first. No need to change data 
structures, y'know.  :)


> PS: Any good reason why I can't send a signed message to this list? I 
> got a "The message's content type was not explicitly allowed" from the 
> mail server at omnigroup...

Signatures were disabled for all omni lists. They were just causing too 
many problems, particularly for the digesters.


Thanks,

    - Scott


--
Tree House Ideas
http://treehouseideas.com/