Re: nonatomic vs atomic assign/retain
Re: nonatomic vs atomic assign/retain
- Subject: Re: nonatomic vs atomic assign/retain
- From: Jens Alfke <email@hidden>
- Date: Tue, 06 Sep 2011 10:20:39 -0700
On Sep 6, 2011, at 10:09 AM, Preston Sumner wrote:
> Based on discussion on the dev forums, atomic properties are the recommended default except for things like performance-critical code or frameworks that assume they're running on a single thread.
Yes, that was the eventual decision. But it wasn’t unanimous.
> Making the "safe" version the default is a sensible decision, in my humble opinion.
It depends. I think you have to make individual decisions on safety/performance trade-offs (otherwise we’d all be using Ruby or Python).
One of the things that worries me about atomic accessors is that they could lead to a form of “death by a thousand cuts” — your code gets slower but no hot spots show up in profiles because the overhead is spread out among hundreds of accessor methods, no single one of which stands out. (Yes, some of the extra time will show up inside the implementations of -retain, -autorelease and -drain, but a significant amount is just the extra overhead in the accessor of making the calls.)
But it’s true, as you point out, that ARC introduces optimizations that lessen this overhead. I haven’t dived into ARC yet (I work on open-source code so I can’t until it’s available on all platforms) but hope to soon.
—Jens_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden