Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

接口参数是否有问题? #125

Open
kylincodelab opened this issue Dec 12, 2024 · 4 comments
Open

接口参数是否有问题? #125

kylincodelab opened this issue Dec 12, 2024 · 4 comments

Comments

@kylincodelab
Copy link

curl -X POST http://localhost:5050/run -H "Content-Type: application/json;charset=UTF-8" -d '{"cmd":[{"args":["/bin/cat","a.hs"],"env":["PATH=/usr/bin:/bin"],"files":[{"content":""},{"name":"stdout","max":10240},{"name":"stderr","max":10240}],"cpuLimit":10000000000,"memoryLimit":104857600,"procLimit":50,"copyIn":{"a.hs":{"content":"main = putStrLn \"Hello, World!\""},"b":{"content":"TEST"}}}]}'
[{"status":"Accepted","exitStatus":0,"time":914000,"memory":6823936,"runTime":2004088,"files":{"stderr":"","stdout":"main = putStrLn \"Hello, World!\""}}]

一个简单的程序 运行内存竟然占用6M多?之前都是很低,更新新版的judge就很大

@criyle
Copy link
Owner

criyle commented Dec 12, 2024

通常是因为没有启用 cgroup 内存计量而转而采用的 max_rss,最低值为 go-judge 的当前内存占用
curl http://localhost:5050/config 获取 runnerConfigcgroupType,如果为 0,则证明没有启用 cgroup

@kylincodelab
Copy link
Author

curl http://localhost:5050/config
{"addressSpaceLimit":true,"copyOutOptional":true,"fileStorePath":"/dev/shm/go-judge3472785913","pipeProxy":true,"runnerConfig":{"cgroupType":2,"domainName":"executor_server","gid":1000,"hostName":"executor_server","maskedPaths":["/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","/usr/lib/wsl/drivers","/usr/lib/wsl/lib"],"mount":[{"Source":"/bin","Target":"bin","FsType":"","Data":"","Flags":282627},{"Source":"/lib","Target":"lib","FsType":"","Data":"","Flags":282627},{"Source":"/lib64","Target":"lib64","FsType":"","Data":"","Flags":282627},{"Source":"/usr","Target":"usr","FsType":"","Data":"","Flags":282627},{"Source":"/etc/ld.so.cache","Target":"etc/ld.so.cache","FsType":"","Data":"","Flags":282627},{"Source":"proc","Target":"proc","FsType":"proc","Data":"","Flags":15},{"Source":"/etc/alternatives","Target":"etc/alternatives","FsType":"","Data":"","Flags":282627},{"Source":"/etc/mono","Target":"etc/mono","FsType":"","Data":"","Flags":282627},{"Source":"/dev/null","Target":"dev/null","FsType":"","Data":"","Flags":282626},{"Source":"/dev/urandom","Target":"dev/urandom","FsType":"","Data":"","Flags":282626},{"Source":"/dev/random","Target":"dev/random","FsType":"","Data":"","Flags":282626},{"Source":"/dev/zero","Target":"dev/zero","FsType":"","Data":"","Flags":282626},{"Source":"/dev/full","Target":"dev/full","FsType":"","Data":"","Flags":282626},{"Source":"tmpfs","Target":"w","FsType":"tmpfs","Data":"size=128m,nr_inodes=4k","Flags":1030},{"Source":"tmpfs","Target":"tmp","FsType":"tmpfs","Data":"size=128m,nr_inodes=4k","Flags":1030}],"symbolicLink":[{"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"}],"uid":1000,"workDir":"/w"},"stream":true,"symlink":true}

奇怪 "cgroupType": 2, 貌似是有启用

@criyle
Copy link
Owner

criyle commented Dec 12, 2024

cgroup v2 需要内核5.19 以上才有内存高水位计量

@kylincodelab
Copy link
Author

升级内核后,正常了,感谢,

root@eaf616056768:/judge/server# curl -X POST http://localhost:5050/run -H "Content-Type: application/json;charset=UTF-8" -d '{"cmd":[{"args":["/bin/cat","a.hs"],"env":["PATH=/usr/bin:/bin"],"files":[{"content":""},{"name":"stdout","max":10240},{"name":"stderr","max":10240}],"cpuLimit":10000000000,"memoryLimit":104857600,"procLimit":50,"copyIn":{"a.hs":{"content":"main = putStrLn \"Hello, World!\""},"b":{"content":"TEST"}}}]}'
[{"status":"Accepted","exitStatus":0,"time":1463000,"memory":380928,"runTime":2602742,"files":{"stderr":"","stdout":"main = putStrLn \"Hello, World!\""}}]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants