---
title: "Memory snapshots: Checkpoint/restore for sub-second startup"
description: "Modal cuts serverless container cold starts roughly 2.5x by checkpointing a gVisor container's full process tree and filesystem mutations just before it accepts a request, then restoring it instead of re-running Python's syscall-heavy import path (import torch alone makes 26,000 syscalls through OverlayFS and a FUSE lazy-loading server)."
url: "https://swe.quest/articles/memory-snapshots-checkpoint-restore-for-sub-second-startup-543b0ee4c645204a"
canonical: "https://modal.com/blog/mem-snapshots"
source: "Modal"
published: "2025-01-28"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 9
tags: ["serverless","containers","sandboxing","performance","linux"]
---

# Memory snapshots: Checkpoint/restore for sub-second startup

A post on [Modal](https://swe.quest/sources/modal.md), published 2025-01-28, 9 min read, Deep dive. Original: [https://modal.com/blog/mem-snapshots](https://modal.com/blog/mem-snapshots)

## Summary

Modal cuts serverless container cold starts roughly 2.5x by checkpointing a gVisor container's full process tree and filesystem mutations just before it accepts a request, then restoring it instead of re-running Python's syscall-heavy import path (import torch alone makes 26,000 syscalls through OverlayFS and a FUSE lazy-loading server). Restore speed depends mostly on getting the main process's memory pages into the page cache. gVisor loads pages in the background, prioritizing faulting pages, while the FUSE layer aggressively preloads the pages file. Snapshots are created on demand per worker because of CPU feature, NVIDIA driver and runtime compatibility. GPU state can't be saved, so models are loaded into CPU RAM before the snapshot and moved to the GPU after restore via snap=True/snap=False lifecycle hooks.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Serverless](https://swe.quest/tags/serverless.md) (Backend & APIs)
- [Containers](https://swe.quest/tags/containers.md) (Infrastructure)
- [Sandboxing & isolation](https://swe.quest/tags/sandboxing.md) (Security)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Linux](https://swe.quest/tags/linux.md) (Infrastructure)

## Prerequisites

- Linux containers ([easy posts on Linux](https://swe.quest/tags/linux.md?difficulty=easy))
- virtual memory and page cache ([easy posts on Caching](https://swe.quest/tags/caching.md?difficulty=easy))
- Python import system ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))

## Keywords

gVisor, CRIU, Modal, FUSE, OverlayFS, PyTorch, runsc

## Related posts

- [GPU Memory Snapshots: Supercharging sub-second startup](https://swe.quest/articles/gpu-memory-snapshots-supercharging-sub-second-startup-14c07f765f85f384.md): Modal · 2025-07-30 · Medium · 6 min read · Serverless, Inference & serving, Hardware, Performance engineering
  Modal's GPU memory snapshots extend its gVisor-based checkpoint/restore to capture GPU state, using NVIDIA's new CUDA checkpoint API (driver branches 570/575) to lock CUDA processes, copy device memory, kernels, streams, contexts and memory mappings to host memory, then snapshot CPU and GPU state together.
- [How we achieved truly serverless GPUs](https://swe.quest/articles/how-we-achieved-truly-serverless-gpus-d82b0620ff18c95f.md): Modal · 2026-05-12 · Medium · 23 min read · Serverless, Inference & serving, Containers, Storage systems, Capacity planning
  Modal cuts GPU inference replica cold starts from roughly 2,000 seconds to about 50 seconds, a 40x speedup, by attacking each stage of spin-up.
- [Modal becomes a gVisor maintainer](https://swe.quest/articles/modal-becomes-a-gvisor-maintainer-053bd8f08ca6c19d.md): Modal · 2026-11-11 · Medium · 9 min read · Sandboxing & isolation, Containers, Multi-tenancy, Hardware, Open source
  Google is donating gVisor to the CNCF under maintainer-led governance, and Modal, which launches over 40 million gVisor containers a day for GPU inference, training, and AI sandboxes, is joining as a maintainer. gVisor's Go-based Sentry application kernel implements the Linux syscall interface and is itself confined by namespaces, cgroups and seccomp, giving tenant isolation without hardware virtualization: about 25 ms boot and 12 MB overhead.
- [Inside Modal Notebooks: How we built a cloud GPU notebook that boots in seconds](https://swe.quest/articles/inside-modal-notebooks-how-we-built-a-cloud-gpu-notebook-that-boots-in-seconds-cfb6050987f03347.md): Modal · 2025-09-16 · Medium · 8 min read · System design, Containers, Storage systems, Real-time systems, Developer tools
  Modal Notebooks runs Jupyter kernels inside Modal Sandboxes, using a \`modal-kernelshim\` daemon that translates ZeroMQ kernel protocol messages into HTTP tunneled through the control plane.
- [How to catch crypto miners using syscall signatures](https://swe.quest/articles/how-to-catch-crypto-miners-using-syscall-signatures-d0f6cd50f5ee160a.md): Modal · 2024-06-06 · Medium · 7 min read · Threat detection, Sandboxing & isolation, Linux, Serverless, Containers
  Modal detects cryptominers abusing its GPU serverless platform by analyzing container syscalls at runtime rather than relying only on user metadata, which abusers can fake with stolen credit cards.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
