feat(provider): store snapshots in a sparse format #9
All Vouch review confidence checks passed
Residual risk 0.26 = Change Risk (0.48) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 540 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.377
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #9"
general
weight: 0.35
aramase
Snapshot files, above all a microVM's guest memory image (
memory-ranges), are mostly holes. TodayUploadSnapshotreads them as zeros andFetchSnapshotwrites those zeros back withio.Copy, so each file crosses Azure and lands on disk at its full logical size. A Nov 6 benchmark (3,000 glutton agents, 256 MiB, AKS) measured ~268 MB of Blob egress per wake (exactly 256 MiB) and restoredmemory-rangesfiles allocated at ≥244 MB p95, against ~98 MB from local snapshots. Disk busy and iowait climbed with wake rate. The benchmark below shows that keeping snapshots sparse removes that I/O, the checkpoint slowdown and the capacity failures that followed.internal/provider/sparse.go): each blob is a header (AZSPARSE, version, logical size, frame count) followed by one(offset, length, data)frame per populated range, found withSEEK_DATA/SEEK_HOLE. It is uncompressed. A restore holds one frame's position at a time, so a crafted blob can't inflate memory. Modeled on substrate's in-tree sparse-extent format (pkg/objectstorage/sparsezstd.go), minus zstd; not compatible with it.DataLosson anything malformed.substrate_format=sparse-v1picks the decoder. Version-specific code is suffixedV1, so a later format (for example zstd) adds a decoder and a case indecoderFor. Copy keeps the metadata without decoding and refuses blobs without it.Unavailablein fetch, buffered copy and ranged copy. The two copy paths were already misclassifying these before this change.Not included: compression, parallel ranged download, server-side copy, fsync changes.
Benchmark
Substrate v1.0.0 on AKS westus3: 12 × Standard_D16ds_v7, 3,000 glutton agents (256 MiB, ½ vCPU), every wake restored from Blob. Wake rate 10 → 20 → 30/s, measuring the last 4 minutes of each step. main is
5639af0; this PR isc3a4e52, the same code as the head (the later commit is docs only). One run each, on fresh clusters and storage accounts.| | main | this PR |
|---|---|---|
| Blob bytes per wake / per suspend | ~266 MB / ~266 MB | ~78 MB / ~78 MB |
|
memory-rangesallocated, p95 (histogram) | ~488 MB | ~98 MB || Suspend p95 at 10 / 20 / 30 per s | 1.1 / 12 / 19 s | 0.21 / 0.24 / 0.41 s |
|
worker_checkpointp95 at 20 / 30 per s | 19.3 / 19.6 s | 0.24 / 0.44 s || Resume p95 at 10 / 20 / 30 per s | 2.5 / 6.6 / 6.1 s | 1.3 / 1.4 / 1.5 s |
| Succeeded at the 30/s step | 17.9/s, 39.9% failed (
no worker has room) | 30.1/s, 0 failures || Node disk busy / iowait at 30/s (median) | 67% / 37% | 45% / 6% |
Restored guests stay sparse, so their next snapshots stay at the populated size (~76 MB) instead of 256 MiB. Checkpoints stop writing full guest memory, suspends finish in well under a second, and worker slots free quickly enough to remove the capacity failures. Resume is now mostly the single-stream download (p95 ~2.2–2.4 s for ~76 MB), which parallel ranged downloads could address in a follow-up.
Follow-ups
AI use: AI-assisted (GitHub Copilot CLI); I've reviewed the diff.
Breaking change: blobs written before this change have no format metadata and fail
FetchSnapshot/CopySnapshotwithDataLoss. The plugin has no released users yet; on upgrade, start from empty snapshot containers and upgrade every node and control sidecar together. Requesting thebreaking-changelabel.make verify,go test -race ./...,make test-integration)