• 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: KVO notifications and threads
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KVO notifications and threads


  • Subject: Re: KVO notifications and threads
  • From: Ben Trumbull <email@hidden>
  • Date: Fri, 11 Jul 2008 15:08:23 -0700

At 1:10 PM -0700 7/11/08, email@hidden wrote:
So having mutiple CPUs and cores doesnt buy us much more than bragging rights, at least as far as KVO and UI goes. oh well.
I like Clark Cox's suggestion for wrapping the set methods in a category that forces the actual set to occur on the MainThread


note to Apple developers observing:
   it would be really nice to make the MVC and KVO play nicely with
threads.

KVO + Threads = Fail.

Instead, try enqueuing and coalescing the KVO notifications, and then later pass off a group of them to the main thread's run loop (or similar pull mechanism).

If you don't understand how the proper granularity of tasks and overall division of labor is crucial to scalability, you're not going to get anything out of your multiple cores anyway. Many operations are not worth the overhead of scheduling on another processor.

Extremely fine grained operations induce a vast amount of communication and coordination overhead, while at the same time create some bizarre and non-intuitive semantic results. Very few objects are in a coherent state if individual properties are asynchronously changed, even if the individual changes are atomic.

(1) EOF post discussing cache coherency and transactional integrity problems with fine grained locking: <http://lists.apple.com/archives/webobjects-dev/2004/Dec/msg00255.html>

(2) Performance problems with fine grained locking & KVO <http://lists.apple.com/archives/cocoa-dev/2007/Mar/msg00739.html>



Some books and articles worth your time:

(3) "Java Concurrency in Practice" The first really good book about multi-threading *engineering* instead of theory or APIs

<http://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz/dp/0321349601/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1206565296&sr=8-1>

(4) "Intel Threading Building Blocks". Another book about actually getting things done right by people who consider the granularity of tasks a serious design consideration.

<http://www.amazon.com/Intel-Threading-Building-Blocks-Parallelism/dp/0596514808/ref=sr_1_1?ie=UTF8&s=books&qid=1215811648&sr=1-1>

(5) "Pattern Language for Parallel Programming" Basically, the Gang of 4 design patterns book, done for parallel programming. Not quite as good as "Design Patterns", but then, what is ?

<http://www.amazon.com/Patterns-Parallel-Programming-Software/dp/0321228111/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1206565387&sr=1-1>

(6) a great article by Edward Lee from UC Berkeley. The canonical "why threads suck" and what we could do about it article.
<http://www.computer.org/portal/site/computer/menuitem.5d61c1d591162e4b0ef1bd108bcd45f3/index.jsp?path=computer/homepage/0506&file=cover.xml&xsl=article.xsl>


(7) Article on serious performance optimizations for multicore machines. It discusses several practical techniques like lock striping that ObjC and CF now use:
<http://developers.sun.com/learning/javaoneonline/2006/coolstuff/TS-5354.pdf>



For experienced programmers looking to go further, an excellent grad level book:
(8) "The Art of Multiprocessor Programming"
<http://www.amazon.com/Art-Multiprocessor-Programming-Maurice-Herlihy/dp/0123705916/ref=pd_sim_b_1>


--

-Ben
_______________________________________________

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


  • Prev by Date: Re: any other type of value for the "fromValue" property of CAAnimation?
  • Next by Date: Re: NSSpeechSynthesizer lifetime and garbage collected (GC) applications
  • Previous by thread: Re: KVO notifications and threads
  • Next by thread: Re: KVO notifications and threads
  • Index(es):
    • Date
    • Thread