From 88158a8f8abb48403f3fbb42de2ab18d2f6753ab Mon Sep 17 00:00:00 2001 From: undefined Date: Thu, 5 Jan 2023 16:57:51 +0800 Subject: [PATCH] judge: set larger limit for compile --- packages/hydrojudge/src/sandbox.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/hydrojudge/src/sandbox.ts b/packages/hydrojudge/src/sandbox.ts index b0998da1f..8d7efc564 100644 --- a/packages/hydrojudge/src/sandbox.ts +++ b/packages/hydrojudge/src/sandbox.ts @@ -74,14 +74,15 @@ function proc(params: Parameter): Cmd { const copyOut = supportOptional ? params.copyOut : (params.copyOut || []).map((i) => (i.endsWith('?') ? i.substring(0, i.length - 1) : i)); - const size = params.stdioLimit || params.cacheStdoutAndStderr ? parseMemoryMB(getConfig('stdio_size')) : 4; - const rate = getConfig('rate'); + const stdioLimit = parseMemoryMB(getConfig('stdio_size')); + const stdioSize = params.stdioLimit || params.cacheStdoutAndStderr ? stdioLimit : 4; const copyOutCached = [...(params.copyOutCached || [])]; if (params.cacheStdoutAndStderr) copyOutCached.push(params.filename ? `${params.filename}.out?` : 'stdout', 'stderr'); const copyIn = { ...(params.copyIn || {}) }; const stdin = params.stdin || { content: '' }; if (params.filename) copyIn[`${params.filename}.in`] = stdin; const time = params.time || 16000; + const cpuLimit = Math.floor(time * 1000 * 1000 * getConfig('rate')); const memory = params.memory || parseMemoryMB(getConfig('memoryMax')); return { args: parseArgs(params.execute || ''), @@ -91,16 +92,16 @@ function proc(params: Parameter): Cmd { ], files: [ params.filename ? { content: '' } : stdin, - { name: 'stdout', max: Math.floor(1024 * 1024 * size) }, - { name: 'stderr', max: Math.floor(1024 * 1024 * size) }, + { name: 'stdout', max: Math.floor(1024 * 1024 * stdioSize) }, + { name: 'stderr', max: Math.floor(1024 * 1024 * stdioSize) }, ], - cpuLimit: Math.floor(time * 1000 * 1000 * rate), - clockLimit: Math.floor(time * 3000 * 1000 * rate), + cpuLimit, + clockLimit: 3 * cpuLimit, memoryLimit: Math.floor(memory * 1024 * 1024), strictMemoryLimit: getConfig('strict_memory'), // stackLimit: memory * 1024 * 1024, procLimit: params.processLimit || getConfig('processLimit'), - copyOutMax: Math.floor(1024 * 1024 * size * 3), + copyOutMax: Math.floor(1024 * 1024 * stdioLimit * 3), copyIn, copyOut, copyOutCached,