Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Draft Proposal for Namespaces in Objective-C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Draft Proposal for Namespaces in Objective-C



Am 15.04.2012 um 17:07 schrieb Michael Ash:

> What prevents the current caching mechanism from continuing to work as it does now? To a first order approximation, the performance of the general (SEL, Class) -> IMP mapping algorithm doesn't matter at all. As long as there is one answer to mapping (SEL, Class) -> IMP at any given time (and as far as I can tell, there is with Kyle's proposal and would be with any other reasonable proposal to namespace selectors), objc_msgSend will perform just like it does to day. Once you cache the IMP, the method used to look it up in the first place simply doesn't matter.
>
> Am I missing something? Either way, I would *really* like this discussion of performance to proceed on an informed basis rather than generalized fearmongering. If you think it's going to add a 2x performance hit, please explain how.

I already explained it before, but as it seems nobody bothers to read the whole thread, I'll explain again:

The problem is the nil namespace, which all existing binaries will have. If you add the namespace to the selector UID, you will have two different selectors for the same method! The nil-namespaced selector and the selector with the correct namespace, in this case, default.

Now, if you have two different selectors you need to look up, the amount of lookups you need doubles. Thus the 2x performance hit.

But I like Greg's workaround, where instead of doubling the lookup time you double the memory required by duplicating all methods in the dtable.

So, it's either a 2x performance hit or 2x memory hit, so we're at the usual tradeoff here that you have with almost all algorithms. I agree though that Greg's way is the better way, as memory is most likely the less limitating factor here. But, as he already explains, this brings a lot of other problems.

For example:

A method can be called with two different values for _cmd. For a forwarding handler, this could mean serious breakage if the code is not namespace-aware. A selector in the nil namespace and the default namespace will be effectively two different selectors now, so the forwarding handler needs to be able to handle boht.


--
Jonathan


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Draft Proposal for Namespaces in Objective-C (From: Kyle Sluder <email@hidden>)
 >Re: Draft Proposal for Namespaces in Objective-C (From: Kyle Sluder <email@hidden>)
 >Re: Draft Proposal for Namespaces in Objective-C (From: Kyle Sluder <email@hidden>)
 >Re: Draft Proposal for Namespaces in Objective-C (From: Jonathan Schleifer <email@hidden>)
 >Re: Draft Proposal for Namespaces in Objective-C (From: Kyle Sluder <email@hidden>)
 >Re: Draft Proposal for Namespaces in Objective-C (From: Jens Ayton <email@hidden>)
 >Re: Draft Proposal for Namespaces in Objective-C (From: Uli Kusterer <email@hidden>)
 >Re: Draft Proposal for Namespaces in Objective-C (From: Ian Joyner <email@hidden>)
 >Re: Draft Proposal for Namespaces in Objective-C (From: Michael Ash <email@hidden>)
 >Re: Draft Proposal for Namespaces in Objective-C (From: Ian Joyner <email@hidden>)
 >Re: Draft Proposal for Namespaces in Objective-C (From: Kyle Sluder <email@hidden>)
 >Re: Draft Proposal for Namespaces in Objective-C (From: Remy Demarest <email@hidden>)
 >Re: Draft Proposal for Namespaces in Objective-C (From: Ken Case <email@hidden>)
 >Re: Draft Proposal for Namespaces in Objective-C (From: Ken Case <email@hidden>)
 >Re: Draft Proposal for Namespaces in Objective-C (From: Jayson Adams <email@hidden>)
 >Re: Draft Proposal for Namespaces in Objective-C (From: Jonathan Schleifer <email@hidden>)
 >Re: Draft Proposal for Namespaces in Objective-C (From: Michael Ash <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.