Priority of child tasks

SE-0304 discourages from specifying priority for the child tasks:

Generally, it is recommended to not specify priority manually.

I'm trying to understand why. Not a practical problem, just curious.

I see why lowering the priority might lead to priority inversion. Does awaiting on child task with lower priority trigger automatic escalation of the child's priority?

What about raising the priority? From the first glance I don't see any problems with this. Any reasons why raising child priority can cause troubles? Are there any examples when rising priority of the child task is helpful?

Waiting on any task triggers automatic escalation of the blocking task's priority to the blocked task's priority.

Well, it's an inherent priority inversion in an important sense: if low-priority tasks can kick off high-priority tasks, the existence of other high-priority tasks might prevent those high-priority tasks from ever starting. (You can imagine trying to take advantage of this intentionally by e.g. only accepting more work in a low-priority task so that you don't take it when you're overloaded, but that would be a very fragile architecture.)

Setting an explicit priority for a child task is discouraged because, ordinarily, child tasks are compositional in nature, and it's better to just set a priority for an entire task tree wherever you originate the outermost task.


Does this include Will it escalate priority of all pending child tasks?

It's not really clear what TaskGroup should do, escalation-wise, if someone has added child tasks that should run at a lower priority than the parent. Honestly, I'm not thrilled that we added that capability.

@rokhinip, you probably have thoughts about this.