{"by":"adammiribyan","descendants":72,"id":47412569,"kids":[47420878,47422572,47424649,47420684,47414113,47420820,47420508,47420810,47423147,47418613,47426329,47420839,47425541,47420711,47421263,47421087,47426557,47419095,47430244,47448770,47427004,47427307,47420340,47421663,47447824,47420521,47420889,47425955,47427786,47422034,47422210],"score":311,"text":"I wanted to see how fast an isolated code sandbox could start if I never had to boot a fresh VM.<p>So instead of launching a new microVM per execution, I boot Firecracker once with Python and numpy already loaded, then snapshot the full VM state. Every execution after that creates a new KVM VM backed by a `MAP_PRIVATE` mapping of the snapshot memory, so Linux gives me copy-on-write pages automatically.<p>That means each sandbox starts from an already-running Python process inside a real VM, runs the code, and exits.<p>These are real KVM VMs, not containers: separate guest kernel, separate guest memory, separate page tables. When a VM writes to memory, it gets a private copy of that page.<p>The hard part was not CoW itself. The hard part was resuming the snapshotted VM correctly.<p>Rust, Apache 2.0.","time":1773755024,"title":"Show HN: Sub-millisecond VM sandboxes using CoW memory forking","type":"story","url":"https://github.com/adammiribyan/zeroboot"}