-
Notifications
You must be signed in to change notification settings - Fork 601
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
greedy task resource accounting instead of blocking on tasks ahead in the queue #3822
Merged
singholt
merged 1 commit into
aws:feature/greedy-task-resource-accounting
from
singholt:feature/greedy-task-resource-accounting
Jul 21, 2023
Merged
greedy task resource accounting instead of blocking on tasks ahead in the queue #3822
singholt
merged 1 commit into
aws:feature/greedy-task-resource-accounting
from
singholt:feature/greedy-task-resource-accounting
Jul 21, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
singholt
changed the title
switch to greedy task resource accounting instead of blocking on tasks ahead in the queue
greedy task resource accounting instead of blocking on tasks ahead in the queue
Jul 20, 2023
singholt
force-pushed
the
feature/greedy-task-resource-accounting
branch
from
July 21, 2023 00:23
5812b5d
to
ffc7974
Compare
mye956
reviewed
Jul 21, 2023
singholt
force-pushed
the
feature/greedy-task-resource-accounting
branch
from
July 21, 2023 18:10
ffc7974
to
56fac99
Compare
singholt
force-pushed
the
feature/greedy-task-resource-accounting
branch
from
July 21, 2023 18:25
56fac99
to
3997ebd
Compare
ubhattacharjya
previously approved these changes
Jul 21, 2023
mye956
previously approved these changes
Jul 21, 2023
chienhanlin
reviewed
Jul 21, 2023
singholt
force-pushed
the
feature/greedy-task-resource-accounting
branch
from
July 21, 2023 18:33
3997ebd
to
187e9bb
Compare
singholt
force-pushed
the
feature/greedy-task-resource-accounting
branch
from
July 21, 2023 18:52
187e9bb
to
3ea8de0
Compare
singholt
force-pushed
the
feature/greedy-task-resource-accounting
branch
from
July 21, 2023 19:29
3ea8de0
to
9c322f7
Compare
prateekchaudhry
approved these changes
Jul 21, 2023
chienhanlin
approved these changes
Jul 21, 2023
singholt
merged commit Jul 21, 2023
3b6c4f1
into
aws:feature/greedy-task-resource-accounting
34 of 35 checks passed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Traditionally, the ECS agent wouldn't start new tasks until all stopping tasks have stopped on a container instance.
With the task resource accounting project, we replaced this serialization with a resource accounting strategy that uses a FIFO queue to serve incoming tasks: #3819. If there are no resources available on the host, we queue tasks up until resources are available.
As soon as resources become available, the first task in the queue gets priority. The other waiting tasks continue to wait, until the first task gets served. There are corner cases when the first task in the queue is large enough to block all other tasks from being served (forever).
This PR changes the above behavior. With this change, although we give preference to tasks in a FIFO fashion, we will try to run as many tasks from the queue as possible, instead of blocking on tasks ahead in the queue that cannot start.
Example:
Consider a container instance with memory 1024 MiB. 3 tasks land on the instance: task T1 with memory 512 MiB, task T2 with memory 1024 MiB, and task T3 with memory 256 MiB.
T1 will run, since the requested memory is available. T2 needs more memory (1024 MiB) than whats available (512 MiB), hence it will be placed in the wait queue. T3 will also run because the requested memory is available. Prior to this change, the T3 would not run until T2 has been served first (and the only way T2 would run is if T1 stops).
Note:
Implementation details
dequeueTask()
to dequeue at the given index, instead of dequeuing first task always.topTask()
togetTaskByIndex()
to return a task at the given index, instead of returning the first task always.monitorQueuedTasks()
to try dequeuing as many tasks as possible, instead of stopping if unable to dequeue the first task in the queue.Testing
New tests cover the changes: yes
Description for the changelog
enhancement: switch to greedy task resource accounting instead of blocking on tasks ahead in the queue.
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.