Skip to content

Commit 6e6eb1a

Browse files
committed
Pass separate CPU/wall time limits through testcase_run.sh
The script doesn't do anything with these, so this way, we have more flexibility in setting them separately and we can increase only the wall clock hard time limit for interactive problems.
1 parent 518f541 commit 6e6eb1a

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

judge/judgedaemon.main.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,12 +1421,16 @@ function judge(array $judgeTask): bool
14211421
$hardtimelimit = $run_config['time_limit']
14221422
+ overshoot_time($run_config['time_limit'], $overshoot)
14231423
+ $run_config['overshoot'];
1424+
$timelimit = [
1425+
'cpu' => [ $run_config['time_limit'], $hardtimelimit ],
1426+
'wall' => [ $run_config['time_limit'], $hardtimelimit ],
1427+
];
14241428
if ($combined_run_compare) {
14251429
// This accounts for wall time spent in the validator. We may likely
14261430
// want to make this configurable in the future. The current factor is
14271431
// under the assumption that the validator has to do approximately the
14281432
// same amount of work wall-time wise as the submission.
1429-
$hardtimelimit *= 2;
1433+
$timelimit['wall'][1] *= 2;
14301434
}
14311435

14321436
// While we already set those above to likely the same values from the
@@ -1462,11 +1466,12 @@ function judge(array $judgeTask): bool
14621466
}
14631467
}
14641468

1469+
$timelimit_str = implode(':', $timelimit['cpu']) . ',' . implode(':', $timelimit['wall']);
14651470
$test_run_cmd = LIBJUDGEDIR . "/testcase_run.sh $cpuset_opt " .
14661471
implode(' ', array_map('dj_escapeshellarg', [
14671472
$input,
14681473
$output,
1469-
"$run_config[time_limit]:$hardtimelimit",
1474+
$timelimit_str,
14701475
$passdir,
14711476
$run_runpath,
14721477
$compare_runpath,

judge/testcase_run.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#
88
# <testdata.in> File containing test-input with absolute pathname.
99
# <testdata.out> File containing test-output with absolute pathname.
10-
# <timelimit> Timelimit in seconds, optionally followed by ':' and
11-
# the hard limit to kill still running submissions.
10+
# <timelimit> Timelimit in seconds in the format
11+
# "<cpu_soft>:<cpu_hard>,<wall_soft>:<wall_hard>".
1212
# <workdir> Directory where to execute submission in a chroot-ed
1313
# environment. For best security leave it as empty as possible.
1414
# Certainly do not place output-files there!
@@ -202,13 +202,15 @@ fi
202202
exitcode=0
203203
# To suppress false positive of FILELIMIT misspelling of TIMELIMIT:
204204
# shellcheck disable=SC2153
205+
TIMELIMIT_CPU="${TIMELIMIT%%,*}"
206+
TIMELIMIT_WALL="${TIMELIMIT#*,}"
205207
runcheck "$RUN_SCRIPT" $RUNARGS \
206208
$GAINROOT "$RUNGUARD" ${DEBUG:+-v -V "DEBUG=$DEBUG"} ${TMPDIR:+ -V "TMPDIR=$TMPDIR"} $CPUSET_OPT \
207209
-r "$PWD/../.." \
208210
--nproc=$PROCLIMIT \
209211
--no-core --streamsize=$FILELIMIT \
210212
--user="$RUNUSER" --group="$RUNGROUP" \
211-
--walltime=$TIMELIMIT --cputime=$TIMELIMIT \
213+
--walltime="$TIMELIMIT_WALL" --cputime="$TIMELIMIT_CPU" \
212214
--memsize=$MEMLIMIT --filesize=$FILELIMIT \
213215
--stderr=program.err --outmeta=program.meta -- \
214216
"$PREFIX/$PROGRAM" 2>runguard.err

0 commit comments

Comments
 (0)