mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
judge: fix memory limit
This commit is contained in:
6 files changed
+13
-9
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/hydrojudge",
|
"name": "@hydrooj/hydrojudge",
|
||||||
"bin": "bin/hydrojudge.js",
|
"bin": "bin/hydrojudge.js",
|
||||||
"version": "3.4.1",
|
"version": "3.4.2",
|
||||||
"main": "./src/index.ts",
|
"main": "./src/index.ts",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||||
@@ -9,9 +9,9 @@
|
|||||||
"@hydrooj/utils": "workspace:^",
|
"@hydrooj/utils": "workspace:^",
|
||||||
"adm-zip": "0.5.14",
|
"adm-zip": "0.5.14",
|
||||||
"cac": "^6.7.14",
|
"cac": "^6.7.14",
|
||||||
"p-queue": "^8.0.1",
|
"p-queue": "^8.1.0",
|
||||||
"schemastery": "^3.14.7",
|
"schemastery": "^3.15.0",
|
||||||
"semver": "^7.6.3",
|
"semver": "^7.7.0",
|
||||||
"shell-quote": "^1.8.2",
|
"shell-quote": "^1.8.2",
|
||||||
"superagent": "^10.1.1",
|
"superagent": "^10.1.1",
|
||||||
"ws": "^8.18.0"
|
"ws": "^8.18.0"
|
||||||
@@ -21,6 +21,6 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/adm-zip": "^0.4.34",
|
"@types/adm-zip": "^0.4.34",
|
||||||
"@types/shell-quote": "^1.7.5",
|
"@types/shell-quote": "^1.7.5",
|
||||||
"@types/ws": "^8.5.13"
|
"@types/ws": "^8.5.14"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@ export default async function compile(
|
|||||||
copyOutCached: [target],
|
copyOutCached: [target],
|
||||||
env: { HYDRO_LANG: lang.key },
|
env: { HYDRO_LANG: lang.key },
|
||||||
time: lang.compile_time_limit || 10000,
|
time: lang.compile_time_limit || 10000,
|
||||||
memory: lang.compile_memory_limit || 256 * 1024 * 1024,
|
memory: lang.compile_memory_limit || 256,
|
||||||
},
|
},
|
||||||
`compile[${lang.key}]`,
|
`compile[${lang.key}]`,
|
||||||
3,
|
3,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export async function compilerVersions(langs: Record<string, LangConfig>) {
|
|||||||
const res = await runQueued(version, {
|
const res = await runQueued(version, {
|
||||||
copyIn: {},
|
copyIn: {},
|
||||||
time: 10000,
|
time: 10000,
|
||||||
memory: 256 * 1024 * 1024,
|
memory: 256,
|
||||||
}, 'compilerVersions', 5);
|
}, 'compilerVersions', 5);
|
||||||
result[lang] = `${res.stdout}\n${res.stderr}`.trim();
|
result[lang] = `${res.stdout}\n${res.stderr}`.trim();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export const judge = async (ctx: JudgeTask) => {
|
|||||||
copyIn: execute.copyIn,
|
copyIn: execute.copyIn,
|
||||||
// Allow 2x limits for better debugging
|
// Allow 2x limits for better debugging
|
||||||
time: parseTimeMS(ctx.config.time || '1s') * 2,
|
time: parseTimeMS(ctx.config.time || '1s') * 2,
|
||||||
memory: parseMemoryMB(ctx.config.memory || '128m'),
|
memory: parseMemoryMB(ctx.config.memory || '256m'),
|
||||||
filename: ctx.config.filename,
|
filename: ctx.config.filename,
|
||||||
addressSpaceLimit: address_space_limit,
|
addressSpaceLimit: address_space_limit,
|
||||||
processLimit: process_limit,
|
processLimit: process_limit,
|
||||||
@@ -32,7 +32,7 @@ export const judge = async (ctx: JudgeTask) => {
|
|||||||
const message: string[] = [];
|
const message: string[] = [];
|
||||||
if (time > parseTimeMS(ctx.config.time || '1s')) {
|
if (time > parseTimeMS(ctx.config.time || '1s')) {
|
||||||
status = STATUS.STATUS_TIME_LIMIT_EXCEEDED;
|
status = STATUS.STATUS_TIME_LIMIT_EXCEEDED;
|
||||||
} else if (memory > parseMemoryMB(ctx.config.memory || '128m') * 1024) {
|
} else if (memory > parseMemoryMB(ctx.config.memory || '256m') * 1024) {
|
||||||
status = STATUS.STATUS_MEMORY_LIMIT_EXCEEDED;
|
status = STATUS.STATUS_MEMORY_LIMIT_EXCEEDED;
|
||||||
} else if (code) {
|
} else if (code) {
|
||||||
status = STATUS.STATUS_RUNTIME_ERROR;
|
status = STATUS.STATUS_RUNTIME_ERROR;
|
||||||
|
|||||||
@@ -30,9 +30,11 @@ const statusMap: Map<SandboxStatus, number> = new Map([
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
export interface Parameter {
|
export interface Parameter {
|
||||||
|
/** in ms */
|
||||||
time?: number;
|
time?: number;
|
||||||
stdin?: CopyInFile;
|
stdin?: CopyInFile;
|
||||||
execute?: string;
|
execute?: string;
|
||||||
|
/** in MB */
|
||||||
memory?: number;
|
memory?: number;
|
||||||
processLimit?: number;
|
processLimit?: number;
|
||||||
addressSpaceLimit?: boolean;
|
addressSpaceLimit?: boolean;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ langs:
|
|||||||
- ~ Key marked with a ? means the option is optional
|
- ~ Key marked with a ? means the option is optional
|
||||||
- (name):
|
- (name):
|
||||||
disabled?: whether to disable this language
|
disabled?: whether to disable this language
|
||||||
|
hidden?: won't show in the language selection
|
||||||
compile?: Compile Command
|
compile?: Compile Command
|
||||||
code_file?: Where to write code file when compiling, defaults to `foo.[name]`
|
code_file?: Where to write code file when compiling, defaults to `foo.[name]`
|
||||||
execute: Command to execute the program
|
execute: Command to execute the program
|
||||||
@@ -42,6 +43,7 @@ langs:
|
|||||||
target?: Compiler output file, defaults to `foo`
|
target?: Compiler output file, defaults to `foo`
|
||||||
display: Display name
|
display: Display name
|
||||||
compile_time_limit?: Compile time limit, in milliseconds
|
compile_time_limit?: Compile time limit, in milliseconds
|
||||||
|
compile_memory_limit?: Compile memory limit, in MB
|
||||||
address_space_limit?: Enable address space memory limit as CCF did
|
address_space_limit?: Enable address space memory limit as CCF did
|
||||||
process_limit?: Limit the number of thread
|
process_limit?: Limit the number of thread
|
||||||
bash:
|
bash:
|
||||||
|
|||||||
Reference in new issue
Block a user