[libdispatch-dev] Clarification on default target_queue for custom serial queues
daniel at acaciatreesoftware.com
Mon Jun 27 13:59:58 PDT 2011
On Jun 25, 2011, at 7:32 PM, Daniel A. Steffen wrote:
> Hi Daniel,
> it is this 'true' here that makes all the difference, the default target queue of a serial queue is the _overcommit_ default-priority global concurrent queue.
> For items/queues submitted to an overcommit global queue, the current Mac OS X kernel workqueue mechanism creates threads more eagerly, e.g. even if an n-wide machine is already fully committed with n cpu-busy threads, submitting another item directly to the overcommit global queue or indirectly to a serial queue with default target queue will cause another thread to be created to handle that item (potentially overcommitting the machine, hence the name).
> If you wish to avoid this, simply set the target queue of your serial queues to the default priority global queue (i.e. non-overcommit).
> The overcommit/non-overcommit distinction is intentionally undocumented and only available in the queue_private.h header because we hope to revise the kernel workqueue mechanism in the future to avoid the need for this distinction.
So custom serial queues default to a different global queue, interesting. But what are the reasons for this default, and what are the downsides of non-overcommiting queues versus overcommitting ones? I mean, non-overcommitting queues still spawn new threads if it blocks.
Would there be a concern if I just retargeted all the queues in my apps to non-overcommiting global queues? Anecdotally, it seems to help UI responsiveness (main thread doesn’t get crowded out?), so that’s a benefit right there.
More information about the libdispatch-dev