• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Recuperating after NS_HANDLER
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Recuperating after NS_HANDLER


  • Subject: Re: Recuperating after NS_HANDLER
  • From: Shaun Wexler <email@hidden>
  • Date: Sun, 16 May 2004 17:56:08 -0700

On May 16, 2004, at 5:45 PM, Ondra Cada wrote:

Aha, thanks. Truth is, being an old NeXTie I am used to NS_HANDLER et al, and although I have noticed the docs and release notes, I know next to nothing of those new directives.

Incidentally...

I was referring to ObjC @try/@catch/@finally rather than NS_HANDLER macros

... are the differences between those two explained anywhere? So far I have found no detailed explanation of potential (dis)advantages of @try... vs. NS_HANDLER family, potential catches when mixing them, et cetera. Just as well, is there a similar explanation/comparation of NS...Lock vs. @synchronized?

NSLock will have more overhead than @synchronized(), which uses a hash of the object's address as an index to a small shared pool of pthread_mutex locks, and will be faster than NSLock in most cases. When I wrote my own fine-grained locking functions, I compiled a fairly accurately profile (pthread_mutex_lock does not include any @synchronized macro overhead):


2 threads competing for the same lock:

Dual-1.42 1.42 GHz G4, one CPU disabled, SKWAtomicLock compiled for G4-UP

SKWLock() - 38 ns per iteration
pthread_mutex_lock() - 312 ns per iteration
[NSLock lock] - 721 ns per iteration

SKWTryLock() - 40 ns per iteration - 1% miss percent
pthread_mutex_trylock() - 262 ns per iteration - 1% miss percent
[NSLock tryLock] - 510 ns per iteration - 1% miss percent

Dual-1.42 GHz G4, both CPU's enabled, SKWAtomicLock compiled for G4-MP

SKWLock() - 99 ns per iteration
pthread_mutex_lock() - 6202 ns per iteration
[NSLock lock] - 7205 ns per iteration

SKWTryLock() - 112 ns per iteration - 8% miss percent
pthread_mutex_trylock() - 727 ns per iteration - 1% miss percent
[NSLock tryLock] - 651 ns per iteration - 26% miss percent


4 threads competing for the same lock:

Dual-1.42 1.42 GHz G4, one CPU disabled, SKWAtomicLock compiled for G4-UP

SKWLock() - 32 ns per iteration
pthread_mutex_lock() - 772 ns per iteration
[NSLock lock] - 1460 ns per iteration

SKWTryLock() - 34 ns per iteration - 1% miss percent
pthread_mutex_trylock() - 275 ns per iteration - 1% miss percent
[NSLock tryLock] - 503 ns per iteration - 1% miss percent

Dual-1.42 GHz G4, both CPU's enabled, SKWAtomicLock compiled for G4-MP

SKWLock() - 92 ns per iteration
pthread_mutex_lock() - 8914 ns per iteration
[NSLock lock] - 9887 ns per iteration

SKWTryLock() - 92 ns per iteration - 3% miss percent
pthread_mutex_trylock() - 739 ns per iteration - 1% miss percent
[NSLock tryLock] - 500 ns per iteration - 14% miss percent


YMMV. ;)
--
Shaun Wexler
MacFOH
http://www.macfoh.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Recuperating after NS_HANDLER
      • From: Nicko van Someren <email@hidden>
References: 
 >Recuperating after NS_HANDLER (From: Francisco Tolmasky <email@hidden>)
 >Re: Recuperating after NS_HANDLER (From: Shaun Wexler <email@hidden>)
 >Re: Recuperating after NS_HANDLER (From: j o a r <email@hidden>)
 >Re: Recuperating after NS_HANDLER (From: Shaun Wexler <email@hidden>)
 >Re: Recuperating after NS_HANDLER (From: Ondra Cada <email@hidden>)
 >Re: Recuperating after NS_HANDLER (From: Shaun Wexler <email@hidden>)
 >Re: Recuperating after NS_HANDLER (From: Ondra Cada <email@hidden>)

  • Prev by Date: Re: newbie - int and unsigned int
  • Next by Date: Re: newbie - int and unsigned int
  • Previous by thread: Re: Recuperating after NS_HANDLER
  • Next by thread: Re: Recuperating after NS_HANDLER
  • Index(es):
    • Date
    • Thread