Skip to content

Commit 652bb06

Browse files
committed
Add option to specify an additional overshoot time when kicking off a rejudging.
Fixes #2700.
1 parent 5a6b3b5 commit 652bb06

File tree

8 files changed

+28
-12
lines changed

8 files changed

+28
-12
lines changed

judge/judgedaemon.main.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,8 +1380,9 @@ function judge(array $judgeTask): bool
13801380
}
13811381
}
13821382

1383-
$hardtimelimit = $run_config['time_limit'] +
1384-
overshoot_time($run_config['time_limit'], $overshoot);
1383+
$hardtimelimit = $run_config['time_limit']
1384+
+ overshoot_time($run_config['time_limit'], $overshoot)
1385+
+ $run_config['overshoot'];
13851386
if ($combined_run_compare) {
13861387
// This accounts for wall time spent in the validator. We may likely
13871388
// want to make this configurable in the future. The current factor is

webapp/src/Controller/API/JudgehostController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ private function maybeUpdateActiveJudging(Judging $judging): void
11591159
->getResult();
11601160
// TODO: Pick up priority from previous judgings?
11611161
$this->rejudgingService->createRejudging($rejudging->getReason(), JudgeTask::PRIORITY_DEFAULT, $judgings,
1162-
false, $rejudging->getRepeat(), $rejudging->getRepeatedRejudging(), $skipped);
1162+
false, $rejudging->getRepeat(), 0, $rejudging->getRepeatedRejudging(), $skipped);
11631163
}
11641164
}
11651165
}

webapp/src/Controller/Jury/InternalErrorController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ public function handleAction(Request $request, ?Profiler $profiler, int $errorId
187187
$affectedJudgings->getValues(),
188188
false,
189189
0,
190+
0,
190191
null,
191192
$skipped,
192193
$progressReporter);

webapp/src/Controller/Jury/RejudgingController.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ public function addAction(Request $request, FormFactoryInterface $formFactory):
526526
'before' => $formData['before'],
527527
'after' => $formData['after'],
528528
'referer' => $request->headers->get('referer'),
529+
'overshoot' => $formData['overshoot'],
529530
];
530531
return $this->render('jury/rejudging_add.html.twig', [
531532
'data' => http_build_query($data),
@@ -639,7 +640,7 @@ public function addAction(Request $request, FormFactoryInterface $formFactory):
639640

640641
$skipped = [];
641642
$res = $this->rejudgingService->createRejudging(
642-
$reason, (int)$data['priority'], $judgings, false, (int)($data['repeat'] ?? 1), null, $skipped, $progressReporter);
643+
$reason, (int)$data['priority'], $judgings, false, (int)($data['repeat'] ?? 1), (int) ($data['overshoot'] ?? 0), null, $skipped, $progressReporter);
643644
$this->generateFlashMessagesForSkippedJudgings($skipped);
644645

645646
if ($res === null) {
@@ -670,6 +671,7 @@ public function createAction(Request $request): Response
670671
$autoApply = (bool)$request->request->get('auto_apply');
671672
$repeat = (int)$request->request->get('repeat');
672673
$priority = $request->request->get('priority') ?: 'default';
674+
$overshoot = (int)$request->request->get('overshoot') ?: 0;
673675

674676
if (empty($table) || empty($id)) {
675677
throw new BadRequestHttpException('No table or id passed for selection in rejudging');
@@ -723,7 +725,7 @@ public function createAction(Request $request): Response
723725
flush();
724726
};
725727

726-
return $this->streamResponse($this->requestStack, function () use ($priority, $progressReporter, $repeat, $reason, $request, $autoApply, $includeAll, $id, $table, $tablemap) {
728+
return $this->streamResponse($this->requestStack, function () use ($priority, $progressReporter, $repeat, $reason, $overshoot, $request, $autoApply, $includeAll, $id, $table, $tablemap) {
727729
// Only rejudge submissions in active contests.
728730
$contests = $this->dj->getCurrentContests();
729731

@@ -773,7 +775,7 @@ public function createAction(Request $request): Response
773775
}
774776

775777
$skipped = [];
776-
$res = $this->rejudgingService->createRejudging($reason, JudgeTask::parsePriority($priority), $judgings, $autoApply, $repeat, null, $skipped, $progressReporter);
778+
$res = $this->rejudgingService->createRejudging($reason, JudgeTask::parsePriority($priority), $judgings, $autoApply, $repeat, $overshoot, null, $skipped, $progressReporter);
777779

778780
if ($res === null) {
779781
$prefix = sprintf('%s%s', $request->getSchemeAndHttpHost(), $request->getBasePath());

webapp/src/Form/Type/RejudgingType.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
132132
'constraints' => $relativeTimeConstraints,
133133
'help' => 'in form ±[HHH]H:MM[:SS[.uuuuuu]], contest relative time',
134134
]);
135+
$builder->add('overshoot', IntegerType::class, [
136+
'label' => 'Additional grace time',
137+
'required' => false,
138+
'attr' => ['min' => 0, 'max' => 999],
139+
'help' => 'in seconds',
140+
]);
135141

136142
$builder->add('save', SubmitType::class);
137143

webapp/src/Service/DOMJudgeService.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ public function unblockJudgeTasks(): void
11681168
}
11691169
}
11701170

1171-
public function maybeCreateJudgeTasks(Judging $judging, int $priority = JudgeTask::PRIORITY_DEFAULT, bool $manualRequest = false): void
1171+
public function maybeCreateJudgeTasks(Judging $judging, int $priority = JudgeTask::PRIORITY_DEFAULT, bool $manualRequest = false, int $overshoot = 0): void
11721172
{
11731173
$submission = $judging->getSubmission();
11741174
$problem = $submission->getContestProblem();
@@ -1181,7 +1181,7 @@ public function maybeCreateJudgeTasks(Judging $judging, int $priority = JudgeTas
11811181
return;
11821182
}
11831183

1184-
$this->actuallyCreateJudgetasks($priority, $judging);
1184+
$this->actuallyCreateJudgetasks($priority, $judging, $overshoot);
11851185

11861186
$team = $submission->getTeam();
11871187
$result = $this->em->createQueryBuilder()
@@ -1423,7 +1423,7 @@ public function parseMetadata(string $raw_metadata): array
14231423
return $res;
14241424
}
14251425

1426-
public function getRunConfig(ContestProblem $problem, Submission $submission): string
1426+
public function getRunConfig(ContestProblem $problem, Submission $submission, int $overshoot = 0): string
14271427
{
14281428
$memoryLimit = $problem->getProblem()->getMemlimit();
14291429
$outputLimit = $problem->getProblem()->getOutputlimit();
@@ -1444,6 +1444,7 @@ public function getRunConfig(ContestProblem $problem, Submission $submission): s
14441444
'entry_point' => $submission->getEntryPoint(),
14451445
'pass_limit' => $problem->getProblem()->getMultipassLimit(),
14461446
'hash' => $runExecutable->getHash(),
1447+
'overshoot' => $overshoot,
14471448
]
14481449
);
14491450
}
@@ -1587,7 +1588,7 @@ private function allowJudge(ContestProblem $problem, Submission $submission, Lan
15871588
return !$evalOnDemand;
15881589
}
15891590

1590-
private function actuallyCreateJudgetasks(int $priority, Judging $judging): void
1591+
private function actuallyCreateJudgetasks(int $priority, Judging $judging, int $overshoot = 0): void
15911592
{
15921593
$submission = $judging->getSubmission();
15931594
$problem = $submission->getContestProblem();
@@ -1606,7 +1607,7 @@ private function actuallyCreateJudgetasks(int $priority, Judging $judging): void
16061607
':compare_script_id' => $this->getImmutableCompareExecutable($problem)->getImmutableExecId(),
16071608
':run_script_id' => $this->getImmutableRunExecutable($problem)->getImmutableExecId(),
16081609
':compile_config' => $this->getCompileConfig($submission),
1609-
':run_config' => $this->getRunConfig($problem, $submission),
1610+
':run_config' => $this->getRunConfig($problem, $submission, $overshoot),
16101611
':compare_config' => $this->getCompareConfig($problem),
16111612
];
16121613

webapp/src/Service/RejudgingService.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public function createRejudging(
5353
array $judgings,
5454
bool $autoApply,
5555
?int $repeat,
56+
?int $overshoot,
5657
?Rejudging $repeatedRejudging,
5758
array &$skipped,
5859
?callable $progressReporter = null
@@ -153,7 +154,7 @@ public function createRejudging(
153154
->getQuery()
154155
->getSingleResult();
155156

156-
$this->dj->maybeCreateJudgeTasks($newJudging, $priority);
157+
$this->dj->maybeCreateJudgeTasks($newJudging, $priority, false, $overshoot);
157158

158159
$this->em->getConnection()->commit();
159160

webapp/templates/jury/partials/rejudge_form.html.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@
9292
<option value="high">high</option>
9393
</select>
9494
</div>
95+
<div id="rejudge-overshoot" class="mb-3">
96+
<label for="overshoot">Additional grace time (in s)</label>
97+
<input type="number" class="form-control" name="overshoot" id="overshoot" value="0" min="0" max="999" step="1">
98+
</div>
9599
{% endif %}
96100
</div>
97101
<div class="modal-footer">

0 commit comments

Comments
 (0)