mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
judge: change sandbox memoryMax logic
This commit is contained in:
1 parent
915c01f703
commit
4710476678
3 files changed
+5
-5
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@hydrooj/hydrojudge",
|
||||
"bin": "bin/hydrojudge.js",
|
||||
"version": "2.5.7",
|
||||
"version": "2.5.8",
|
||||
"main": "package.json",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
import yaml from 'js-yaml';
|
||||
import { sum } from 'lodash';
|
||||
import { max, maxBy, sum } from 'lodash';
|
||||
import readYamlCases, { convertIniConfig } from '@hydrooj/utils/lib/cases';
|
||||
import { changeErrorType } from '@hydrooj/utils/lib/utils';
|
||||
import { FormatError, SystemError } from './error';
|
||||
@@ -187,6 +187,8 @@ function isValidConfig(config) {
|
||||
if (total_time > (getConfig('total_time_limit') || 60) * 1000) {
|
||||
throw new FormatError('Total time limit longer than {0}s. Cancelled.', [+getConfig('total_time_limit') || 60]);
|
||||
}
|
||||
const memMax = max(config.subtasks.map((subtask) => subtask.memory));
|
||||
if (memMax > parseMemoryMB(getConfig('memoryMax'))) throw new FormatError('Memory limit larger than memory_max');
|
||||
}
|
||||
|
||||
export default async function readCases(folder: string, cfg: Record<string, any> = {}, args) {
|
||||
|
||||
@@ -26,13 +26,11 @@ const statusMap = {
|
||||
function proc({
|
||||
execute = '',
|
||||
time = 16000,
|
||||
memory = 1024,
|
||||
memory = parseMemoryMB(getConfig('memoryMax')),
|
||||
process_limit = 32,
|
||||
stdin = '', copyIn = {}, copyOut = [], copyOutCached = [],
|
||||
} = {}) {
|
||||
const size = parseMemoryMB(getConfig('stdio_size'));
|
||||
const memoryMax = parseMemoryMB(getConfig('memoryMax'));
|
||||
if (memory > memoryMax) throw new FormatError('Memory limit larger than memory_max');
|
||||
return {
|
||||
args: cmd(execute.replace(/\$\{dir\}/g, '/w')),
|
||||
env,
|
||||
|
||||
Reference in new issue
Block a user