From 1916231f9d6778136f704764f8f7a0f06b08444a Mon Sep 17 00:00:00 2001 From: undefined Date: Sat, 6 Apr 2024 23:33:48 +0800 Subject: [PATCH] judge: terminal: show memory limit --- packages/hydrojudge/src/terminal.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/hydrojudge/src/terminal.ts b/packages/hydrojudge/src/terminal.ts index 14de853d8..03011686f 100644 --- a/packages/hydrojudge/src/terminal.ts +++ b/packages/hydrojudge/src/terminal.ts @@ -1,3 +1,4 @@ +import os from 'os'; import log from './log'; import client from './sandbox/client'; @@ -11,17 +12,19 @@ export = async function terminal() { log.error('interactive terminal requires available tty'); return; } + const memoryLimit = Math.floor(os.totalmem() / 4); process.stdin.setRawMode(true); log.info('Starting /bin/bash, double press Ctrl+C to kill all child processes.'); + log.info(`Current memory limit is ${Math.floor(memoryLimit / 1024 / 1024)}m`); const stream = client.stream({ cmd: [{ args: ['/bin/bash'], env: ['PATH=/usr/local/bin:/usr/bin:/bin', 'HOME=/tmp', `TERM=${process.env['TERM']}`], files: [{ streamIn: true }, { streamOut: true }, { streamOut: true }], - cpuLimit: (20 * 1e9), - clockLimit: (30 * 60 * 1e9), - memoryLimit: (256 << 20), - procLimit: 50, + cpuLimit: (120 * 1e9), + clockLimit: (30 * 120 * 1e9), + memoryLimit, + procLimit: 128, tty: true, }], });