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

When scheduling, also consider task age to sort requested tasks #999

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions dispatcher/backend/src/utils/scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ def get_reqs_doable_by(session: so.Session, worker: dbm.Worker) -> List[Dict[str
"""cursor of RequestedTasks() doable by a worker using all its resources

- sorted by priority
- sorted by duration (longest first)"""
- sorted by duration (longest first)
- sorted by updated_at (task requested long ago first, mandatory for zimit farm)
"""

def get_document(task: dbm.RequestedTask):
return {
Expand Down Expand Up @@ -351,7 +353,7 @@ def get_document(task: dbm.RequestedTask):
return list(
sorted(
map(get_document, session.execute(stmt).scalars()),
key=lambda x: (-x["priority"], -x["duration"]["value"]),
key=lambda x: (-x["priority"], -x["duration"]["value"], x["updated_at"]),
)
)

Expand Down