Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCD vs custom queue

I was wondering what is the difference in performance between these two.

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{

    // perform complex operation

    // dispatch back to main thread to update UI

});



dispatch_async(_myCustomConcurrentQueue, ^{

    // perform complex operation

    // dispatch back to main thread to update UI

});

My assumption is the GCD is used across the os and other applications, and it will need to perform very quick background tasks, and be finished quick. And custom queues that are created are separate from GCD and they can run a different task, and will be added back to the pool once they are released. And so my assumption is that my customQueue performs better than GCD for a complex operation.

What are your thoughts? Which performs better? Are they the same?

like image 635
Legolas Avatar asked Jun 27 '26 21:06

Legolas


1 Answers

While the high-priority global queue might theoretically be faster (since you don't have to create the queue, slightly different thread priority), the difference between that and your own custom concurrent queue is unlikely to be observable. There are two reasons, though, that you might want to use your own custom queues:

  1. Certain features, notably dispatch barriers, are unavailable in global queues, so if you need those features, you'll want to use custom queue.

  2. Debugging your app, it can also be useful to use your own queues with meaningful names, so that you can more easily identify the individual threads in the debugger.

But there are no material performance reasons to choose high priority global concurrent queue vs a custom concurrent queue.

like image 74
Rob Avatar answered Jun 29 '26 12:06

Rob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!