2 ms·
If you're interested, the main part of the container implementation is here: https://github.com/maelstrom-software/maelstrom/blob/main/crates/maelstrom-worker/s
by nfachan 2y ago
If you're interested, the main part of the container implementation is here: https://github.com/maelstrom-software/maelstrom/blob/main/crates/maelstrom-worker/src/executor.rs https://github.com/maelstrom-software/maelstrom/blob/main/cr...
For each test we run, we clone the worker process, then make a bunch of Linux syscalls to set everything up for the container, then exec the test. We use the trick of having the child process share the virtual memory of the parent until the test is exec'ed.
We also use a technique where we build up a "program" of simple operations (each operation more or less maps to a syscall) in the parent before cloning, then evaluate the program in the child. This gives us the same performance benefits of using posix_spawn or vfork, but lets us configure all of the namespace stuff while we're spawning.
The code that's run in the child can be found here: https://github.com/maelstrom-software/maelstrom/blob/main/crates/maelstrom-worker-child/src/lib.rs https://github.com/maelstrom-software/maelstrom/blob/main/cr...