judge: time_rate setting

This commit is contained in:
undefined committed 2021-06-16 15:44:30 +08:00
1 parent 3fe69ca15d
commit 1b96301eef
5 files changed
+12 -5

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "@hydrooj/hydrojudge", "name": "@hydrooj/hydrojudge",
"bin": "bin/hydrojudge.js", "bin": "bin/hydrojudge.js",
"version": "2.8.8", "version": "2.8.9",
"main": "package.json", "main": "package.json",
"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",
+5
View File
@@ -47,6 +47,11 @@ parallelism:
name: parallelism name: parallelism
desc: Runner parallelism desc: Runner parallelism
default: 2 default: 2
rate:
type: number
name: rate
desc: (?)
default: 1
disable: disable:
type: boolean type: boolean
name: disable name: disable
+1
View File
@@ -19,6 +19,7 @@ let config = {
testcases_max: 100, testcases_max: 100,
total_time_limit: 60, total_time_limit: 60,
parallelism: 2, parallelism: 2,
rate: 1,
config: null, config: null,
langs: null, langs: null,
env: `\ env: `\
+5 -3
View File
@@ -34,6 +34,7 @@ function proc({
copyOut = (copyOut as string[]).map((i) => (i.endsWith('?') ? i.substr(0, i.length - 1) : i)); copyOut = (copyOut as string[]).map((i) => (i.endsWith('?') ? i.substr(0, i.length - 1) : i));
} }
const size = parseMemoryMB(getConfig('stdio_size')); const size = parseMemoryMB(getConfig('stdio_size'));
const rate = getConfig('rate');
return { return {
args: cmd(execute.replace(/\$\{dir\}/g, '/w')), args: cmd(execute.replace(/\$\{dir\}/g, '/w')),
env: getConfig('env').split('\n'), env: getConfig('env').split('\n'),
@@ -42,8 +43,8 @@ function proc({
{ name: 'stdout', max: 1024 * 1024 * size }, { name: 'stdout', max: 1024 * 1024 * size },
{ name: 'stderr', max: 1024 * 1024 * size }, { name: 'stderr', max: 1024 * 1024 * size },
], ],
cpuLimit: time * 1000 * 1000, cpuLimit: time * 1000 * 1000 * rate,
realCpuLimit: time * 3000 * 1000, realCpuLimit: time * 3000 * 1000 * rate,
memoryLimit: memory * 1024 * 1024, memoryLimit: memory * 1024 * 1024,
procLimit: process_limit, procLimit: process_limit,
copyIn, copyIn,
@@ -53,10 +54,11 @@ function proc({
} }
async function adaptResult(result, params) { async function adaptResult(result, params) {
const rate = getConfig('rate');
// FIXME: Signalled? // FIXME: Signalled?
const ret: any = { const ret: any = {
status: statusMap[result.status] || STATUS.STATUS_ACCEPTED, status: statusMap[result.status] || STATUS.STATUS_ACCEPTED,
time_usage_ms: result.time / 1000000, time_usage_ms: result.time / 1000000 / rate,
memory_usage_kb: result.memory / 1024, memory_usage_kb: result.memory / 1024,
files: result.files, files: result.files,
code: result.exitStatus, code: result.exitStatus,
-1
View File
@@ -56,7 +56,6 @@ export async function load(call: Entry) {
if (process.env.MINIO_ACCESS_KEY && process.env.MINIO_SECRET_KEY) { if (process.env.MINIO_ACCESS_KEY && process.env.MINIO_SECRET_KEY) {
await modelSystem.set('file.accessKey', process.env.MINIO_ACCESS_KEY); await modelSystem.set('file.accessKey', process.env.MINIO_ACCESS_KEY);
await modelSystem.set('file.secretKey', process.env.MINIO_SECRET_KEY); await modelSystem.set('file.secretKey', process.env.MINIO_SECRET_KEY);
await modelSystem.set('file.endPoint', 'http://localhost:9000/');
} }
const storage = require('../service/storage'); const storage = require('../service/storage');
await storage.start(); await storage.start();