Repository navigation
Conversation
Check guest command exit codes and resize /dev/shm before writing 1 GiB. Propagate bounded-runner failures and add unit and opt-in Firecracker regression tests.
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 3 selected item(s). |
| let samples = run().with_context(|| format!("run {name}"))?; | ||
| print_samples(name, &samples); | ||
| Ok(true) |
There was a problem hiding this comment.
This changes a single benchmark failure from a logged skip into an error that exits run_default_snapshot_benchmarks immediately. Consequently, a failure in an environment-dependent workload (for example the 1 GiB memory case or a throughput setup) prevents all later selected benchmarks from running and makes the default command fail. If these workloads are intended to be independently runnable, retain per-benchmark reporting/continuation (while perhaps aggregating failures), or explicitly make this fail-fast behavior part of the default runner contract.
| let options = format!("remount,size={HEAVY_DATA_SIZE_MIB}M"); | ||
| let output = sandbox | ||
| .run_command("mount", &["-o", &options, "/dev/shm"]) | ||
| .await?; | ||
| ensure_guest_command_success("resize guest /dev/shm", &output)?; |
There was a problem hiding this comment.
This assumes every benchmark guest has /dev/shm mounted as a remountable tmpfs and that the benchmark process has permission to change its limit. A different image/mount setup (or a guest where /dev/shm is absent or non-tmpfs) now makes the entire 1 GiB memory benchmark fail before sampling. Consider validating the mount configuration during setup and/or handling unsupported configurations explicitly rather than hard-coding this remount as a prerequisite.
| let reply = self.replies.lock().unwrap().pop_front().unwrap(); | ||
| Ok(ProcessOutput { |
There was a problem hiding this comment.
The scripted executor panics if the helper issues more commands than the currently scripted replies. That makes adding a valid preparation step fail with an unrelated unwrap() panic instead of identifying the unexpected command; return an error (ideally including the command and arguments) when the queue is exhausted.
Suggestion:
| let reply = self.replies.lock().unwrap().pop_front().unwrap(); | |
| Ok(ProcessOutput { | |
| let reply = self | |
| .replies | |
| .lock() | |
| .unwrap() | |
| .pop_front() | |
| .ok_or_else(|| anyhow::anyhow!("unexpected guest command {cmd:?} {args:?}"))?; | |
| Ok(ProcessOutput { |
| fn dd_write_failure_prevents_snapshot_sampling() { | ||
| let output = run_dd("of=/dev/full"); |
There was a problem hiding this comment.
This integration test is always built and run, but it assumes a Unix/Linux /dev/full device and an external dd with these operands. On supported non-Linux targets (and minimal environments without dd) the test either fails at runtime or cannot exercise the intended behavior. Gate this test target/tests consistently with the benchmark's platform support, or replace the host dd dependency with a portable fixture.
| let cleanup = sandbox.stop().await; | ||
| let daemon_cleanup = UblkDeviceManager::global().shutdown_daemon().await; | ||
| result?; | ||
| cleanup?; | ||
| daemon_cleanup |
There was a problem hiding this comment.
If any command in the body fails (the normal path this reproduction is meant to diagnose), result? returns before either cleanup future is awaited. Cancellation while the body is running has the same effect. Use a cleanup guard or an unconditional cleanup path that records the body error while still stopping the sandbox, removing the workload, and shutting down ublk; otherwise an ignored test can leave a VM/daemon running and contaminate later tests or the host.
Suggestion:
| let cleanup = sandbox.stop().await; | |
| let daemon_cleanup = UblkDeviceManager::global().shutdown_daemon().await; | |
| result?; | |
| cleanup?; | |
| daemon_cleanup | |
| let cleanup = sandbox.stop().await; | |
| let daemon_cleanup = UblkDeviceManager::global().shutdown_daemon().await; | |
| result?; | |
| cleanup?; | |
| daemon_cleanup |
| let cleanup = sandbox.stop().await; | ||
| let daemon_cleanup = UblkDeviceManager::global().shutdown_daemon().await; | ||
| result?; | ||
| cleanup?; | ||
| daemon_cleanup |
There was a problem hiding this comment.
Correction to the cleanup concern: because result is awaited before this block but only propagated after both cleanup futures are awaited, ordinary body errors do not skip cleanup. The remaining gap is cancellation while the body is running (or during cleanup), which would require a drop/guard-based cleanup strategy if cancellation safety is required.
| let cleanup = sandbox.stop().await; | ||
| let daemon_cleanup = UblkDeviceManager::global().shutdown_daemon().await; | ||
| result?; | ||
| cleanup?; | ||
| daemon_cleanup |
There was a problem hiding this comment.
|
Cross-referencing #487, where we posted restore-latency numbers from our own Firecracker fleet; on the preparation-correctness side that this PR fixes, two things we hit internally reinforce the strictness:
Related note on cache state (the |
Thanks for sharing your experience. I agree that preparation failures should abort measurement. |
|
Thanks for the confirmation, and for the cleanup addition in d241336 — that closes a real gap the original report didn't cover: a failed preparation that leaks a sandbox would otherwise pollute the next run's environment on a shared host, and preserving the original preparation error with the cleanup diagnostic attached keeps the root cause primary in the report. Covering both the bounded and Criterion runners matters too, since either entry point leaving a stray sandbox behind would produce the same hard-to-diagnose downstream noise. Worth linking the two halves explicitly: the contamination your cleanup fences off after a failed preparation is the same failure family as the one the exit-code contract fences off during preparation — the |
What
Ensure snapshot benchmarks only measure successfully prepared workloads:
dd,sync, and guest cache-clearing commands./dev/shmto 1 GiB before preparing the memory workload.Why
run_command(...).await?checks whether command execution returned a result, but does not reject a nonzero process exit code. The benchmark previously discardedProcessOutput, allowing failedddcommands to leave partially prepared workloads without stopping measurement.The memory fixture also allocates 1536 MiB of guest RAM while relying on the default tmpfs size limit, approximately half of guest RAM. This is insufficient for its intended 1 GiB write.
Related issue
None. This is a small benchmark correctness fix with a real-VM reproduction.
Scope and non-goals
Limited to snapshot benchmark preparation, failure reporting, tests, and documentation. No new performance metrics or sandbox runtime behavior are introduced.
Design and behavior changes
Preparation commands must exit successfully before measurement starts. Remount failure prevents the memory fixture from running
dd; write failure aborts preparation.The default bounded runner now propagates selected workload errors to a nonzero process exit.
The real-VM test runs the original command, records the failure and partial file size, removes the partial file, then calls the fixed production preparation function and verifies the resulting size.
Real-VM comparison
Executed through Docker using Firecracker
1.15.1-patch-v2, guest kernel6.18.0-agentenv-nestedvirt, 1 vCPU, and 1536 MiB RAM.Both phases ran in the same guest:
/dev/shmcapacityddexit codeNo space left on deviceThis is a workload correctness comparison; no snapshot latency or throughput improvement is claimed.
Compatibility and operations
async-traitis added as a benchmark development dependency.Validation
make fmtmake clippymake test-unitmake -C services testmaketargetCommands and results:
Skipped checks and reasons:
Risks and reviewer notes
The bounded runner intentionally changes automation behavior: selected workload failures now return a nonzero exit status.
Increasing the tmpfs limit does not allocate memory immediately; the fixture's
ddperforms the intended 1 GiB allocation. Changes are confined to disposable benchmark guests.Checklist