ioi / isolate

Sandbox for securely executing untrusted programs
Other
1.04k stars 154 forks source link

Read memory usage with cgroups v2 #121

Closed magula closed 1 year ago

magula commented 1 year ago

Use memory.peak, which replaces memory.max_usage_in_bytes from v1.

See https://github.com/ioi/isolate/issues/78#issuecomment-1221414436.

It seems that there is still no replacement for memory.memsw.max_usage_in_bytes, so there is no way to read maximum swap usage. This should be acceptable for using isolate as a contest sandbox, where swap is supposed to be disabled for ensuring reproducibility.

So perhaps it would for now be sufficient to leave it like this, and add proper documentation that swap memory is not accounted for. On a related note, I am not sure how obvious it was that with v1 the reported memory usage was the maximum of memory peak and swap memory peak, which I assume could be smaller than the peak of the total memory consumption, so clarifying how or if swap memory consumption is regarded might be good either way.

gollux commented 1 year ago

I applied a slightly different patch. Thanks for your suggestion!