原来的 JudgeServer 按核数起 gunicorn worker、每份提交再按核数开进程池,空闲内存跟着核数走
(2 核 52MB、16 核 305MB)。换成 go-judge 后空闲 16MB,同一批提交判题中 80–100MB(原来约 370MB)。
go-judge 只管在沙箱里跑命令,编译、逐点运行、比对输出、定状态码搬到 judge/sandbox.ts,
口径逐条照搬 JudgeServer,出参形状不变。拿生产库真实提交新旧逐点对比:C 2000 份 1989 一致、
C++ 891 份 890 一致、Python 2000 份全一致;不一致的是 system("pause")(现在不再判运行时错误)、
未定义行为、endl 死循环打印(运行时错误变运行超时),见 docker/judge/README.md。
- 判题容器改成 privileged(go-judge 要自己建 cgroup),镜像 oj2-judge-3
- 心跳改由 worker 每 5 秒问判题机 /version 代记,删掉 /api/judge-server/heartbeat
- 前端统一用 stripJudgePath 去掉判题机工作目录(新的 /w/ 和旧的 /judger/run/)
- 提交前编译检查只编译不运行
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
82 lines
2.0 KiB
YAML
82 lines
2.0 KiB
YAML
# go-judge 沙箱里的文件系统:学生程序和编译器只看得到这些。
|
|
# 照 go-judge 自带的 mount.yaml 删减的:只留 gcc / g++ / python3 要的,
|
|
# fpc、mono、ghc、java 那几条(还有 MPI 的 /sys、/dev/shm)都去掉了。
|
|
mount:
|
|
# 编译器、解释器和它们的库
|
|
- type: bind
|
|
source: /bin
|
|
target: /bin
|
|
readonly: true
|
|
- type: bind
|
|
source: /lib
|
|
target: /lib
|
|
readonly: true
|
|
- type: bind
|
|
source: /lib64
|
|
target: /lib64
|
|
readonly: true
|
|
- type: bind
|
|
source: /usr
|
|
target: /usr
|
|
readonly: true
|
|
- type: bind
|
|
source: /etc/ld.so.cache
|
|
target: /etc/ld.so.cache
|
|
readonly: true
|
|
# /usr/bin/gcc → /etc/alternatives/gcc → /usr/bin/gcc-14,少了这条编译器就找不到
|
|
- type: bind
|
|
source: /etc/alternatives
|
|
target: /etc/alternatives
|
|
readonly: true
|
|
- type: bind
|
|
source: /dev/null
|
|
target: /dev/null
|
|
- type: bind
|
|
source: /dev/urandom
|
|
target: /dev/urandom
|
|
- type: bind
|
|
source: /dev/random
|
|
target: /dev/random
|
|
- type: bind
|
|
source: /dev/zero
|
|
target: /dev/zero
|
|
- type: bind
|
|
source: /dev/full
|
|
target: /dev/full
|
|
# 工作目录:源码、编译产物、程序输出都在这里。输出上限 16MB(-output-limit),
|
|
# 加上可执行文件,128MB 绰绰有余
|
|
- type: tmpfs
|
|
target: /w
|
|
data: size=128m,nr_inodes=4k
|
|
# g++ 的中间文件写在 /tmp
|
|
- type: tmpfs
|
|
target: /tmp
|
|
data: size=128m,nr_inodes=4k
|
|
proc: true
|
|
symLink:
|
|
- linkPath: /dev/fd
|
|
target: /proc/self/fd
|
|
- linkPath: /dev/stdin
|
|
target: /proc/self/fd/0
|
|
- linkPath: /dev/stdout
|
|
target: /proc/self/fd/1
|
|
- linkPath: /dev/stderr
|
|
target: /proc/self/fd/2
|
|
maskPath:
|
|
- /sys/firmware
|
|
- /sys/devices/virtual/powercap
|
|
- /proc/acpi
|
|
- /proc/asound
|
|
- /proc/kcore
|
|
- /proc/keys
|
|
- /proc/latency_stats
|
|
- /proc/timer_list
|
|
- /proc/timer_stats
|
|
- /proc/sched_debug
|
|
- /proc/scsi
|
|
workDir: /w
|
|
hostName: go-judge
|
|
domainName: go-judge
|
|
uid: 1536
|
|
gid: 1536
|