Repository navigation
fix(replay): isolate blocking resource sampling from trajectory scheduling - #138
Open
zhaoyuuu0624 wants to merge 2 commits into
Open
zhaoyuuu0624 wants to merge 2 commits into
zhaoyuuu0624 wants to merge 2 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(replay): isolate blocking resource sampling from trajectory scheduling
Problem
Concurrent replay performs synchronous host resource reads (including cgroup files and
/proc/<pid>/smaps_rollup), JSON serialization, and sample writes on the asyncio thread that also schedules trajectories. Slow sampling delays timer wakeups and command-control callbacks, adding measurement overhead to the workload being measured. Sampling also needs to finish before the associated VM is torn down.In the previous 80-trajectory UKSM run, mean extra waiting per trajectory was 249.11 seconds after subtracting the original planned sleeps. This is replay-controller overhead, not evidence that the task needed additional computation or that the VM runtime itself spent that time sleeping.
Upstream scope
This PR extracts the validated sampling and wait-timing helpers for explicit adoption by concurrent deployment controllers. It does not change the current synchronous single-task runner or VM runtime. The historical controller integration (including the UKSM-only scan change) is retained as a diagnostic diff, not an automatically applied upstream backend change. This is independent of the checked-exec startup changes in PR #135; their older optional sampler can subsequently be consolidated.
Changes
The shared sampling fix is implemented for both replay adapters. The full-run validation below covers the updated pVisor UKSM adapter; the AgentENV result is the existing reference run, not a new run of its updated adapter.
Validation
The frozen deployment package passes 13 local tests; the extracted upstream helpers pass 7 standalone tests.
miseis unavailable on this host, so validation used standard-library unittest discovery directly. The deployment tests cover covering event-loop responsiveness under blocking reads, bounded workers, executor separation, cancellation draining, error propagation, real observer integration, unchanged sleep budgets, and offload/shutdown safeguards.The four-trajectory A/B completed 290 commands in each arm with clean shutdowns. Mean extra waiting fell from 6.65 to 1.85 seconds; batch time changed only from 29m51s to 29m45s. The larger effect appears in the full concurrent workload below.
Full-run conditions: same 80 trajectories, five waves of 16 arriving every five minutes, 24 physical CPU cores, a 48 GiB parent cgroup limit, 2 vCPU/5 GiB guests, 4 GiB admission headroom, at most one launch per second, and a 30-second command timeout. Original commands and waits are unchanged; a cleaned command timeout does not abort its trajectory. No filesystem access-path or runtime-binary optimization is included.
The fixed run finished 8m55s earlier (14.9%) than the previous UKSM run, and 1m30s later than the AgentENV reference. Mean extra waiting is nearly eliminated; tool execution cost remains largely unchanged (97.96 vs 98.83 guest-command seconds per trajectory). Final audits report no live VMs, mounts, or workspaces, with no OOM or swap use.