Documentation
¶
Overview ¶
Package dmtcp checkpoints and restarts an engine's process tree with DMTCP, entirely in user space: the backend for containers that cannot run CRIU (no CAP_SYS_ADMIN or CAP_CHECKPOINT_RESTORE, a read-only /proc/sys, unshare refused by seccomp), such as RunPod pods.
DMTCP must start the engine (dmtcp_launch preloads its wrappers), so the whole life of a snapshotted engine runs under one coordinator. The fdkeep plugin repairs what DMTCP loses of the CUDA driver's helper fds, thread names, listening sockets and epoll watches (docs/dmtcp.md).
Inside the tree DMTCP keeps virtual PIDs (40000 and up); outside, after a restart, the processes have new real PIDs. The coordinator's list maps one to the other.
Index ¶
- Constants
- Variables
- func Images(dir string) ([]string, error)
- type Map
- type Peer
- type Tools
- func (t Tools) Check() error
- func (t Tools) Checkpoint(ctx context.Context, dir string, drain, timeout time.Duration) error
- func (t Tools) Coordinator(ctx context.Context) (int, error)
- func (t Tools) Kill(ctx context.Context) error
- func (t Tools) List(ctx context.Context) ([]Peer, error)
- func (t Tools) Quit(ctx context.Context) error
- func (t Tools) QuitLeft(ctx context.Context) error
- func (t Tools) Restart(images []string, log io.Writer) (*exec.Cmd, error)
- func (t Tools) RestartArgs(images []string) []string
- func (t Tools) Setenv() error
- func (t Tools) Version(ctx context.Context) string
- func (t Tools) WaitPeers(ctx context.Context, n int, timeout time.Duration, failed func() error) ([]Peer, error)
- func (t Tools) Wrap(argv []string, dir string) []string
Constants ¶
const ( DefaultDir = "/opt/warmctl/dmtcp/bin" DefaultPlugin = "/opt/warmctl/dmtcp/lib/libdmtcp_fdkeep.so" )
Where the runtime image installs DMTCP and fdkeep. Donor and receiver must run this very build, so a restore never takes another DMTCP from PATH.
const PortFile = "coordinator.port"
PortFile is the file in TmpDir that holds the port of the coordinator Coordinator started until Quit ends it: QuitLeft finds there a coordinator whose agent was killed before it could end it.
Variables ¶
var Env = []string{
"OMP_NUM_THREADS=1", "OPENBLAS_NUM_THREADS=1", "MKL_NUM_THREADS=1",
"VLLM_WORKER_MULTIPROC_METHOD=fork", "UV_USE_IO_URING=0", "UCX_MEM_MMAP_HOOK_MODE=none",
}
Env is what an engine needs to run under DMTCP:
- fork with live OpenBLAS/OpenMP thread pools hangs the child (torch's import runs ldconfig in a subprocess), so the pools get one thread;
- vLLM's workers are forked: spawn adds multiprocessing's resource tracker, one more process to checkpoint (vLLM still spawns once its API server initialized CUDA, which the fork's fcntl64 wrapper made work);
- libuv must not batch epoll_ctl through io_uring, which DMTCP cannot see;
- UCX (NIXL's transport, in the vLLM image) must not hook mmap and shmat: its hooks call the originals past DMTCP's wrappers.
Functions ¶
Types ¶
type Map ¶
Map is a peer list as virtual-to-real and real-to-virtual PIDs.
type Peer ¶
type Peer struct {
Name string `json:"name"`
Virtual int `json:"virtual"`
Real int `json:"real"`
State string `json:"state"`
}
Peer is a process of the computation.
type Tools ¶
type Tools struct {
// Dir holds dmtcp_launch, dmtcp_command, dmtcp_restart and
// dmtcp_coordinator; empty means PATH.
Dir string `json:"dir,omitempty"`
// Plugin is libdmtcp_fdkeep.so.
Plugin string `json:"plugin"`
// Port is the coordinator's on loopback. 0 lets Coordinator take a free
// one, which a coordinator another run left behind cannot hold.
Port int `json:"port,omitempty"`
// TmpDir is DMTCP_TMPDIR, where the coordinator and the workers keep
// their own files: outside the trees a snapshot carries.
TmpDir string `json:"tmp_dir,omitempty"`
}
Tools are DMTCP's programs and the fdkeep plugin.
func (Tools) Checkpoint ¶
Checkpoint writes the images of every process into dir and returns once all are written; the processes keep running. No image is written until every process has drained its sockets, which takes seconds; a drain that does not end fails the checkpoint once drain has passed with no image in dir, instead of at timeout.
func (Tools) Coordinator ¶
Coordinator starts a coordinator in the background and returns its port: Port, or the free one the system gave it when Port is 0, which it writes to PortFile before it forks into the background. It exits with the last process of its computation; one that no process joined waits for Quit.
func (Tools) QuitLeft ¶
QuitLeft ends the coordinator PortFile names, and every process still connected to it: the engine of an in-place run whose agent was killed before its own Quit. No PortFile is nothing to end.
func (Tools) Restart ¶
Restart starts dmtcp_restart on images. Its process becomes the first restored process, the root of the tree; the caller waits on it.
func (Tools) RestartArgs ¶
RestartArgs are dmtcp_restart's arguments. --no-strict-checking drops its one check, that each image's owner is this user: a network file system reports another owner (nobody under geesefs or NFS root_squash). A pull checks every file against its SHA-256; a stage copies by size, its frames checked by zstd.
func (Tools) Setenv ¶
Setenv makes TmpDir this process's DMTCP_TMPDIR, inherited by the coordinator, the engine and dmtcp_restart.
func (Tools) WaitPeers ¶
func (t Tools) WaitPeers(ctx context.Context, n int, timeout time.Duration, failed func() error) ([]Peer, error)
WaitPeers polls the coordinator until n peers run. A restart whose process asserted never gets there, the others wait at a barrier for it, so it fails as soon as a peer leaves or failed, checked on every poll, says so.