Repository navigation
Conversation
|
🔍 OpenCodeReview found 3 issue(s) in this PR.
|
| !command.trim().is_empty(), | ||
| "{RESUME_COMMAND_ENV} must not be empty" | ||
| ); | ||
| println!("Resume workload (sh -c): {command:?}"); |
There was a problem hiding this comment.
This prints the complete user-supplied shell command to benchmark/CI output. Since AENV_BENCH_RESUME_COMMAND is explicitly configurable, it can contain credentials, tokens, or other sensitive values intended for the guest, which would then be exposed in logs. Avoid logging the raw command (or provide an explicit opt-in/redaction mechanism) while retaining the command for execution.
Suggestion:
| println!("Resume workload (sh -c): {command:?}"); | |
| println!("Resume workload configured via {RESUME_COMMAND_ENV}"); |
| // standard test harness to exercise its hardware-independent runner. | ||
| #[allow(dead_code)] | ||
| mod snapshot_benchmark { | ||
| include!("../benches/snapshot_benchmark.rs"); |
There was a problem hiding this comment.
This test target textually includes the entire benchmark binary in order to reach private helpers. That makes the test's compilation and namespace depend on every future top-level import/declaration in the benchmark (and can also pull benchmark-only setup into the test), so an unrelated benchmark refactor can break or alter this test rather than test a stable API. Consider extracting the hardware-independent resume/cleanup helpers into a library module and testing that module directly, leaving the benchmark as a thin caller.
| "snapshot_benchmark::criterion_only_validates_resume_command_for_selected_benchmarks", | ||
| "--nocapture", |
There was a problem hiding this comment.
The child invocation hard-codes this test's fully qualified harness name. Renaming the module/test or changing the test harness layout will make this test fail before exercising Criterion filtering, and the exact diagnostic assertion below has the same coupling to an implementation detail. Prefer isolating the filtering logic behind a callable helper (or otherwise avoid recursively invoking the test binary) and assert a stable error classification/message at the boundary.
|
We run a Firecracker-based sandbox fleet and have built similar restore-latency baselines internally; sharing measured data points that may help calibrate these scenarios (FC v1.17.0, guest kernel 6.1.190, 1 vCPU / 512 MiB guests, busybox-class templates, ext4/NVMe local tier unless noted): Restore-to-ready vs restore-to-first-command. Our primary metric is restore → in-guest agent HTTP 200 (analogous to the restore/readiness boundary here): warm P50 ≈ 10.2–10.5 ms, P99 ≈ 13.5 ms; with the template's page cache explicitly evicted (per-target
A spectrum that bounds the metric (same guest size across all tiers):
Practical takeaway: the same "resume" operation spans 10 ms → 3.4 s depending on locality tier, so encoding the tier in the scenario name ( Workload descriptors worth recording per sample: guest RAM size, the command's working set, and for prefetch studies the unique-page churn rate — in our measurements the dirty-page fraction over a window is strongly bimodal (~0.5% for idle-ish network services, ~58–59% for continuous writers) and both restore and delta costs scale with it. Also echoing the direction of #486: validated preparation (exit-checked, size-verified) is what makes the workload dimension trustworthy in the first place. |
What
Add
snapshot_resume_to_commandandsnapshot_resume_to_command_unpinnedto measure the time from backend snapshot resume through completion of the first specified guest command.Why
Restore-to-ready latency can miss memory faults and disk reads deferred until the first workload runs. Measuring command completion provides a baseline for evaluating whether changes such as prefetching improve the time to useful work.
Related issue
Related to #125 and #215.
Related implementation: #219.
Scope and non-goals
This change adds benchmark scenarios, focused regression tests, and documentation. Runtime behavior, snapshot formats, and storage formats are unchanged.
PR #219 already includes total timings spanning snapshot restore and guest command execution, plus first-workload experiments for pre-fault evaluation. This PR overlaps that measurement goal.
The difference is scope: #219 integrates measurements with its pre-fault implementation and specialized experiments. This PR provides a standalone baseline through existing restore interfaces, with a configurable shell command, warm/unpinned scenarios, bounded and Criterion runners, and filtering/timeout/cleanup regression tests. It requires no new pre-fault API or matching Firecracker changes. Overlapping helpers may be consolidated when the changes are integrated.
This is a baseline measurement tool, not a controlled cold-cache or prefetch A/B experiment.
Design and behavior changes
printf 'aenv-resume-command-ok\n'. Accept a shell workload throughAENV_BENCH_RESUME_COMMANDand print its exact value.AENV_BENCH_PRINT_SAMPLES=1, report restore/readiness and command portions separately. Formatting and printing occur after sample timing.Compatibility and operations
async-traitdev dependency and Tokiotest-utilfeature. The seven focused tests need no VM.Validation
make fmtmake clippymake test-unitmake -C services test(required whenservices/changes)maketargetRun in Docker as the non-root developer user on this isolated branch:
git diff --checkalso passed. The Criterion filtering regression failed before the fix and passed afterward during development.Tests cover filtered versus selected command validation, startup timeout, a shared startup/completion deadline, nonzero exit status, cleanup after sample/warmup/resume failure, and error precedence when cleanup fails. Cleanup tests exercise the same sampling loop as the real runner through controlled callbacks.
Skipped checks and reasons:
Risks and reviewer notes
unpinneddoes not evict host page caches or OverlayBD caches. The default shell workload measures basic resume-to-command overhead. Application and prefetch studies need a fixed representative workload and controlled cache conditions. The locally prepared snapshot has no startup-pack descriptor.The 60-second deadline covers the command call, not the entire VM restore. Mock cleanup tests verify stop calls and ordering, not actual device release.
Review the sampling loop and lazy Criterion setup in
crates/benchmarks/benches/snapshot_benchmark.rs.Checklist