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

Avoid waiting when only one judge can handle a submission #2002

Merged
merged 1 commit into from
Oct 28, 2022
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
17 changes: 8 additions & 9 deletions judge/bridge/judge_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,19 @@ def judge(self, id, problem, language, source, judge_id, priority):
# idempotent.
return

candidates = [
judge for judge in self.judges if not judge.working and judge.can_judge(problem, language, judge_id)
]
candidates = [judge for judge in self.judges if judge.can_judge(problem, language, judge_id)]
available = [judge for judge in candidates if not judge.working]
if judge_id:
logger.info('Specified judge %s is%savailable', judge_id, ' ' if candidates else ' not ')
logger.info('Specified judge %s is%savailable', judge_id, ' ' if available else ' not ')
else:
logger.info('Free judges: %d', len(candidates))
logger.info('Free judges: %d', len(available))

if len(self.judges) > 1 and len(candidates) == 1 and priority >= REJUDGE_PRIORITY:
candidates = []
if len(candidates) > 1 and len(available) == 1 and priority >= REJUDGE_PRIORITY:
available = []

if candidates:
if available:
# Schedule the submission on the judge reporting least load.
judge = min(candidates, key=lambda judge: (judge.load, random()))
judge = min(available, key=lambda judge: (judge.load, random()))
logger.info('Dispatched submission %d to: %s', id, judge.name)
self.submission_map[id] = judge
try:
Expand Down