dmtcp

package
v2.0.0-beta.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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

View Source
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

func Images

func Images(dir string) ([]string, error)

Images are the checkpoint images in dir, one per process.

Types

type Map

type Map struct{ ToReal, ToVirtual map[int]int }

Map is a peer list as virtual-to-real and real-to-virtual PIDs.

func NewMap

func NewMap(peers []Peer) Map

NewMap indexes peers.

func (Map) Real

func (m Map) Real(virtual []int) ([]int, error)

Real translates virtual PIDs; it fails on one the computation lacks.

func (Map) Virtual

func (m Map) Virtual(pids []int) ([]int, error)

Virtual translates real PIDs; it fails on one the computation lacks.

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.

func ParseList

func ParseList(text string) ([]Peer, error)

ParseList reads dmtcp_command --list: one peer per client line.

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 DefaultTools

func DefaultTools() Tools

DefaultTools uses the release's own runtime, never another build from PATH. Resolve the executable symlink before looking beside it (custom prefixes).

func (Tools) Check

func (t Tools) Check() error

Check finds every program and the plugin.

func (Tools) Checkpoint

func (t Tools) Checkpoint(ctx context.Context, dir string, drain, timeout time.Duration) error

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

func (t Tools) Coordinator(ctx context.Context) (int, error)

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) Kill

func (t Tools) Kill(ctx context.Context) error

Kill ends the computation.

func (Tools) List

func (t Tools) List(ctx context.Context) ([]Peer, error)

List asks the coordinator for the computation's processes.

func (Tools) Quit

func (t Tools) Quit(ctx context.Context) error

Quit kills the processes connected to the coordinator and ends it.

func (Tools) QuitLeft

func (t Tools) QuitLeft(ctx context.Context) error

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

func (t Tools) Restart(images []string, log io.Writer) (*exec.Cmd, error)

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

func (t Tools) RestartArgs(images []string) []string

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

func (t Tools) Setenv() error

Setenv makes TmpDir this process's DMTCP_TMPDIR, inherited by the coordinator, the engine and dmtcp_restart.

func (Tools) Version

func (t Tools) Version(ctx context.Context) string

Version is dmtcp_launch's first line: "dmtcp_launch (DMTCP) 5.0".

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.

func (Tools) Wrap

func (t Tools) Wrap(argv []string, dir string) []string

Wrap is argv under dmtcp_launch: raw images into dir, the plugin loaded.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL