• 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: GCD killed my performance
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GCD killed my performance


  • Subject: Re: GCD killed my performance
  • From: Ken Thomases <email@hidden>
  • Date: Thu, 24 Apr 2014 22:42:06 -0500

On Apr 24, 2014, at 10:14 PM, Jens Alfke wrote:

> I’m writing an Objective-C API around a database library, and trying to add some optimizations. There’s a lot of room for parallelizing, since tasks like indexing involve a combination of I/O-bound and CPU-bound operations. As a first step, I made my API thread-safe by creating a dispatch queue and wrapping the C database calls in dispatch_sync blocks.

You may be aware of this, but dispatch_sync() is not necessary or even particularly relevant to thread-safety.  The use of a serial queue or, possibly, a reader/write mechanism using barriers, is what achieves thread safety.

Using a synchronous call is only necessary if your API has synchronous semantics.  For example, if a call provides immediate results to the caller.  Reading from a database would typically have to be synchronous, but writing to it can often be asynchronous.  All you care about is that future reads will always see what was previously written, which the serial queue or barriers will guarantee.

That doesn't necessarily have any bearing on the overhead of GCD vs. the resources of an iPhone, but I thought I'd point it out.

Regards,
Ken


_______________________________________________

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


  • Follow-Ups:
    • Re: GCD killed my performance
      • From: Jens Alfke <email@hidden>
References: 
 >GCD killed my performance (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: GCD killed my performance
  • Next by Date: Re: ARC Retain Cycles
  • Previous by thread: Re: GCD killed my performance
  • Next by thread: Re: GCD killed my performance
  • Index(es):
    • Date
    • Thread