[Feature Request] Restore a chain of Diff snapshots with the `File` memory backend, without merging
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 28/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- linux, rust
- Ambito
- infrastructure, operating-systems
Direzione di ricerca
Start with the snapshot loading path for PUT /snapshot/load and the memory mapping code described in the issue; compare it with the single-file hole handling in #6396. The issue proposes layered File mappings and optional Diff hole filling, but leaves design choices open. Done means loading a Diff chain works as described while preserving shared page cache and addressing mapping contention.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Feature Request
We restore many short-lived microVMs from layered snapshots: a Full snapshot of a booted guest, with Diff snapshots on top, each taken from a microVM restored from its parent. Today the File backend can only restore such a chain after it has been merged. The snapshot docs say a Diff "must be merged with a base snapshot into a full snapshot", by copying each layer over the base with snapshot-editor edit-memory rebase.
For us, merging has two costs:
- A full-size memory file for every leaf snapshot. Each new Diff means writing a complete copy of guest memory, however small the Diff is.
- No sharing between leaves. A
Filerestore shares page cache between microVMs restored from the same memory file. Once each leaf is merged into its own file, microVMs restored from different leaves of the same base no longer share the base's pages.
The other option today is a UFFD handler that layers the chain. That works, but every page a microVM touches is copied into its own private memory, and every microVM needs a handler process.
Describe the desired solution
An optional list of Diff memory files on PUT /snapshot/load with the File backend, oldest first. Firecracker would map the bottom memory file MAP_PRIVATE as it does today. It would then map each layer's data extents, found with SEEK_DATA/SEEK_HOLE, over that mapping with MAP_FIXED | MAP_PRIVATE, so every guest page maps the newest layer that holds it. All of this happens during the load, before the microVM runs. The kernel then serves each page from the page cache of the file that holds it. That page cache is shared by every microVM restored from the same layers, with no handler involved.
The request could look like this:
curl --unix-socket /tmp/firecracker.socket -i \
-X PUT 'http://localhost/snapshot/load' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"snapshot_path": "./diff2/snapshot_file",
"mem_backend": {
"backend_type": "File",
"backend_path": "./full/mem_file"
},
"mem_file_layers": ["./diff1/mem_file", "./diff2/mem_file"]
}'
Mapping count. Each data extent splits the guest memory mapping, so a layer costs about two mappings per extent. That could run into vm.max_map_count at around 32k runs. We hit lock contention well before that:
- The cost: When the diff has a large number of extents, a restore can have a large number of mappings as well. When testing, a significant percentage of the top on-CPU kernel stacks were spinning on the memory files'
i_mmap_rwsem. Each extent takes it for writing in__split_vmaat restore, and each mapping takes it again inunlink_file_vmaat teardown. Every microVM restored from the same files shares that lock. - The fix: we gave the Diff a minimum hole size of 64 pages (256 KiB). When the Diff is written, any shorter gap between two dirty pages is written as data too. Those pages are clean, so their contents are still in guest memory. This helped to reduce the contention.
- Where it could live: an orchestrator could enforce this offline, by copying the parent's bytes into short holes. It's cheaper in Firecracker, which has the dirty bitmap and guest memory at hand when it writes the Diff. Possible ways include adding it as an optional field on
PUT /snapshot/create(diff_gap_fill_pages), or maybe a name likediff_min_hole_pages, or a KiB value, might read better.
Describe possible alternatives
- Merge first (
snapshot-editor edit-memory rebase), as documented, with the costs above. - *A UFFD handler that layers the chain: Every touched page becomes a private copy, and each microVM needs a handler.
- An explicit extent list instead of
SEEK_DATA: entries of (file, file offset, guest memory offset, length). That would also cover:- layers on hugetlbfs, which can't report holes;
- files that lost their holes in transit;
- chunk files from a content-addressed store.
- #5840's fd replies. Its page responses already carry (fd, file offset, guest offset, length), the same data as a layer's extents. A handler could install this layout through it given two things:
- a range could be mapped private, copy-on-write
- the layout could be applied during the load, before the microVM runs, rather than per fault.
Curious whether you'd rather go that way than add a load field, also would be happy to send a PR!
Additional context
- #6396 does something very similar at
Fileload for a single file: it walks the memory file and maps anonymous memory over its holes withMAP_FIXED. Based on that, it seems natural to map anonymously only the ranges that are holes in every layer.
Checks
- Have you searched the Firecracker Issues database for similar requests?
- Have you read all the existing relevant Firecracker documentation?
- Have you read and understood Firecracker's core tenets?
- Lingua principale
- Rust
- Stelle
- 38.2k
- Fork
- 2.8k
- Merge medio
- 2g 12h
- PR unite (30g)
- 59
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di firecracker-microvm/firecracker
-
[Bug] jailer: misc device minors below 100 are never found in /proc/misc (/dev/nitro_enclaves, /dev/userfaultfd missing from the jail)Forse già presa @Gaspardcode l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
firecracker-microvm/firecracker#6490 ·
I maintainer di solito rispondono entro 1 giorno
-
chore(deps): update libseccomp to v2.6.2Forse già presa @pederbe l’ha presa 2 giorni fa. Apertadependencies
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
firecracker-microvm/firecracker#6460 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
firecracker-microvm/firecracker#6486 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] vsock: a guest connection still handshaking when a snapshot is taken can hang forever after restoreForse già presa @not4s l’ha presa 2 giorni fa. ApertaStatus: Awaiting assignee
Difficoltà 4/5 3-5 giorni Idoneità per principianti 15/100
firecracker-microvm/firecracker#6464 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] virtio: a driver features page written again is ORed into the acked features instead of replacing themForse già presa @zulinx86 l’ha presa 2 giorni fa. ApertaStatus: Awaiting assignee
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
firecracker-microvm/firecracker#6463 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di firecracker-microvm/firecracker
Issue simili
-
Find/Replace panel: "Previous/Next occurrence" labels overlap and overflow their buttons (French)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
obi1kenobi/cargo-semver-checks#1839 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Bash init calls `cygpath` unconditionally on Windows, which breaks non-Cygwin shells like `brush`Forse già presa @iliqiliev l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ajeetdsouza/zoxide#1381 ·
I maintainer di solito rispondono entro 5 giorni
-
triage
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
kornia/kornia-rs#1416 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni