@@ -28,17 +28,16 @@ the host restores the base snapshot, adds the state of that customer, for
2828example a WebAssembly module, and then runs the code of the customer.
2929
3030Caching a snapshot for the top N customers would remove that work from most
31- requests. Unfortunately the memory cost currently makes this impractical as every snapshot stores a full
32- copy of the sandbox memory, so N cached customers means N copies of the
33- WebAssembly runtime, while the customer state is a small fraction of each one.
31+ requests. The memory cost makes this impractical today, because every snapshot
32+ stores a full copy of the sandbox memory. N cached customers means N copies of
33+ the WebAssembly runtime, while the customer state is a small fraction of each
34+ one.
3435
3536With incremental snapshots, a customer snapshot holds only the pages that the
3637state of the customer changed. All N snapshots share the blob of the base
3738snapshot. Thus the cache costs the size of the base snapshot and the sum of the
3839changes, and the host can keep many more customers in memory.
3940
40-
41-
4241## Proposal
4342
4443### Data model
@@ -87,8 +86,9 @@ that they use.
8786### Taking a Snapshot of a Sandbox
8887
89881 . Find the pages that this snapshot must save. Read the guest page tables to
90- get all the mapped pages. If the guest physical address of a page is in a
91- live range of a layer, this snapshot shares that page with a previous snapshot, and does not need to save it. All other pages must be saved.
89+ get all the mapped pages. A page whose guest physical address is in a live
90+ range of a layer is already in a previous snapshot, and this snapshot shares
91+ it. All other pages must be saved.
92922 . Find a place in the guest address space for the new pages. The new blob must
9393 not overlap the layers that this snapshot keeps. Use the first unused part
9494 that is large enough.
@@ -118,8 +118,8 @@ page tables of the snapshot into scratch, and resets the vCPU.
118118A snapshot has one VM memory mapping for each live range of each of its layers.
119119Mapping or unmapping one is a hypervisor call. A restore changes only the
120120mappings that differ, but that can be all of them, so an unbounded number of
121- live ranges would make a restore arbitrarily slow. A snapshot therefore has an
122- arbitrary cap on its total mappings, and taking a snapshot above the cap fails.
121+ live ranges would make a restore arbitrarily slow. A snapshot therefore has a
122+ fixed cap on its total mappings, and taking a snapshot above the cap fails.
123123Every layer except the one with the restore page tables must give at least one
124124live range, so the cap bounds the layer count too.
125125
0 commit comments