Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why we should not use default QoS directly?

I have read some GDC posts or even Apple saying that developer should not use the .default QoS directly, but why? legibility?

I think that assign .default QoS to a task is the same to not assign a QoS explicitly.

enter image description here

Link from the screenshot belongs: https://developer.apple.com/library/archive/documentation/Performance/Conceptual/EnergyGuide-iOS/PrioritizeWorkWithQoS.html

like image 941
Andoni Da Silva Avatar asked Sep 07 '25 06:09

Andoni Da Silva


2 Answers

.default is there for backwards compatibility reasons since GCD can't guess what priority you want to assign your tasks.

There's two reasons to use the other 4 recommended values:

  • It gives the system more context over what hierarchy of execution your tasks should follow. For example, a user initiated task might be scheduled in a higher priority queue versus a background task. This enables the system to perform optimizations of when to run your tasks as well as energy spending. See Session 706 of WWDC 2017.
  • Apple silicon (iPhone, iPad, Apple TV, Apple Watch and M1 Macs) has high performance and efficiency cores and the system decides which cores to use depending on the QoS developers set. Imagine that a user interactive task will run on an high performance core, while a background task might run on the efficiency one. For more information see Tuning Your Code’s Performance for Apple Silicon.
like image 105
fbernardo Avatar answered Sep 10 '25 13:09

fbernardo


"I think that assign .default QoS to a task is the same to not assign a QoS explicitly." You're right.

In my opinion, Apple suggests us using other 4 types in general for specific purposes. If you are not sure about this, it will pick .default for your task.

like image 22
Phuc Avatar answered Sep 10 '25 13:09

Phuc