New issue
Advanced search Search tips

Issue 839122 link

Starred by 3 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Feature

Blocking:
issue 623683
issue 793069
issue 839099



Sign in to add a comment

[Feature] Consider adding TaskPriority::IDLE

Project Member Reported by gab@chromium.org, May 2 2018

Issue description

We currently have TaskPriority::BACKGROUND for tasks that should be as little disruptive as possible and can take "an arbitrarily long time to complete".

The next priority after that is TaskPriority::USER_VISIBLE.

TaskPriority::IDLE would signify a priority that is lowest to schedule but must still run on a foreground thread when it is scheduled.

In issue 793069 we want to funnel multiple traits on a single sequence. To do so we can't mix BACKGROUND/USER_VISIBLE as when we only have BACKGROUND work, we don't want to move a to a background physical thread as that would cause a priority inversion if USER_VISIBLE/USER_BLOCKING work came in (the thread may be descheduled by the OS while we're blocked on it coming live).

In  issue 839099  we want to allow manually toggling the priority of a single sequence. Again, it could be reasonable to want not incur a priority inversion when doing this.

In the promises world (WIP) this would also be required. Ideally all services are initialized with IDLE priority and only promoted to USER_BLOCKING when actually needed before being loaded.

For all those cases, BACKGROUND->USER_BLOCKING promotion incurs a priority inversion if it's already running a background thread. Hence we need TaskPriority::IDLE

(I've also seen ad-hoc one off tasks that couldn't execute at BACKGROUND but were also disruptive at USER_VISIBLE priority)
 

Comment 1 by gab@chromium.org, May 9 2018

Blocking: 623683
Owner: chrisha@chromium.org
Status: Assigned (was: Available)
To do this I think we should switch to a mode with one queue per priority instead of a single priority queue. I think this is a better model anyways than continually sorting many sequences between effectively 2 or 3 possible values as we do today.

I'm not convinced we need to implement an anti-starving algorithm (e.g. yield to a task of lower priority every N'th task in a row at a given priority) because IDLE should really mean "do this when idle" and not mind starving when non-idle.

In any case, this is definitely a precursor to issue 623683 if we ever go there.

@chrisha : a good first bug to dip your toes in TaskScheduler land as a precursor to  issue 839099 ?

Sign in to add a comment