Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancel and re-schedule low-priority task if high-priority task is scheduled #1266

Closed
ahoppen opened this issue May 9, 2024 · 1 comment
Closed

Comments

@ahoppen
Copy link
Collaborator

ahoppen commented May 9, 2024

When TaskScheduler has all execution slots filled up with low priority tasks and a high-priority task is scheduled, we should cancel and reschedule the newest low-priority task (newest because it has probably made the least progress that we would cancel).

rdar://127474310

@ahoppen
Copy link
Collaborator Author

ahoppen commented Jun 7, 2024

Decided not to do this because: Priority elevation of currently executing tasks is done asynchronously by polling in withTaskPriorityChangedHandler. We could thus reasonably get into the following scenario: All execution slots in the AsyncQueue are filled up with low-priority tasks. We now await all of them from a high-priority task (eg. because we want to ensure that the index is up-to-date). At the same time, we schedule a new high-priority task. If we implemented this, then we would cancel and reschedule one of the low-priority tasks only because its priority elevation hasn’t been propagated by priority polling. And that would be sub-optimal because it duplicates work. I think it’s better to just let the low-priority tasks finish.

@ahoppen ahoppen closed this as completed Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant