Repository navigation
perf(vm): resolve a cached digest-pinned bootstrap image without a preparation worker - #6057
balajinvda wants to merge 2 commits into
Conversation
…rker Every launch starts an image preparation worker (an exec of the driver binary, which then probes for a local container engine, plus the parent's 10 ms exit poll) to resolve its root disk. When the workload image is the bootstrap image, pinned by digest, its root disk is cached and no local container engine answers, the worker writes nothing: it finds no engine and answers from the cache without a registry call (since ai-openshell#4582). The driver now answers that case in its own process, with the same logs and the same Pulling, CacheHit and Pulled events under the same vm.resolve_bootstrap_image span. Everything else keeps the worker: a rootfs tar, another workload image, a tag, a locally built image, a reachable container engine, a cache miss, a registry credential error, a missing bootstrap image, a sandbox that is gone or already preparing. Those checks run before any log or event, so the worker then prepares, reports and fails exactly as before. The overlay preparation keeps its worker. The engine probe is passed in (LocalEngineProbe) so the tests can run on a host where Docker answers. Test: cached_digest_pinned_image_plan_skips_the_worker_only_on_a_digest_cache_hit runs eight cases through a recording worker and checks which ones the worker answered, the plan and the events; it fails when the fast path is disabled. cached_digest_pinned_image_plan_keeps_the_worker_path_errors checks a missing and a deleting sandbox still fail as Cancelled with a cached root disk present. Closes ai-openshell#6055 Signed-off-by: Balaji Ganesan <bganesan@nvidia.com>
|
This PR should include or follow the build-time guest runtime identity change from #6056 ( In Before this PR, that work ran in the image preparation worker. With this PR, every eligible request performs it on the parent driver's async runtime before checking the cache. A cache miss then falls back to the worker and repeats the hashing; a cached image with a reachable engine also pays the parent hash and probe before taking the worker path. This can delay unrelated driver operations under concurrent creates. The stub-artifact tests do not exercise the production-sized hashing cost, and the reported 114 → 1–2 ms measurement includes the companion identity change. Please land the build-time guest identity commit first and rebase this PR, or include that change here. Alternatively, move the expensive computation off the async runtime. This dependency is specific to the guest identity change: neither overlay batching nor the supervisor hash cache is required, so the supervisor-cache integrity concern raised on #6056 can remain separate. |
Every bootstrap root disk's image cache key includes sandbox_guest_runtime_identity(), a SHA-256 over the embedded sandbox, vm-init and umoci blobs and the guest init script. It was computed on every call, and every launch resolves its root disk in a fresh image preparation worker process, so every launch hashed the embedded blobs again, even on a cache hit. On an x86-64 host without SHA instructions most of the 90 ms between the worker's "ensuring cached root disk image" and its cache hit is this hash (inferred from the driver log gap, not profiled). build.rs now hashes exactly the files the crate embeds (from OUT_DIR, plus the init script, which build.rs now watches) and the function returns that constant. The value is unchanged, so cached root disks stay valid. Test: guest_runtime_identity_built_once_matches_the_embedded_bytes holds the build-time value equal to the hash of the embedded bytes computed at run time, as before. Cherry-picked from ai-openshell#6056 (ea6c298) so that this PR stands alone: cached_digest_pinned_image_plan calls bootstrap_image_cache_identity on the async runtime, which must not hash the embedded blobs there. Refs ai-openshell#6054 Signed-off-by: Balaji Ganesan <bganesan@nvidia.com>
|
@TaylorMutch the build-time identity commit from #6056 is now included here (ea6c298), so this PR stands alone, and the measurement note is corrected. Could you take another look, and approve the pending Branch Checks / Helm Lint runs? |
Summary
A create whose image is the bootstrap image, pinned by digest, with its root disk cached and no local container engine, started an image preparation worker that only read the cache. The driver now resolves that case in its own process, with the same plan, logs and events; every other case keeps the worker unchanged.
Related Issue
Closes #6055
Changes
perf(vm): hash the guest runtime identity at build time, cherry-picked from perf(vm): stop repeating per-launch bookkeeping before the VM starts #6056 (ea6c298), so this PR stands alone:cached_digest_pinned_image_plancallsbootstrap_image_cache_identityon the driver's async runtime, and without that commitsandbox_guest_runtime_identity()hashes every embedded blob there on each eligible create. With it the identity is a build-time constant (same value, so cached root disks stay valid). Whichever of perf(vm): stop repeating per-launch bookkeeping before the VM starts #6056 and this PR lands second drops that commit on rebase.prepare_images_in_workerfirst askscached_digest_pinned_image_plan. It returns a plan only when: no rootfs tar; a bootstrap image is configured; the requested image is the bootstrap image (or the request is bootstrap-only); the sandbox is registered, not deleting and not already preparing; the reference is not a local build image and carries a digest; the root diskimage_cache_rootfs_image(bootstrap_image_cache_identity(digest))exists;registry_authsucceeds; and no local container engine answers. These are the conditions under which the worker answers from the cache without a registry call since fix(vm): boot a digest-pinned image from the cache without a registry call #4582.vm.resolve_bootstrap_imagespan: theno local container engine availablewarning,ensuring cached root disk image (registry),root disk image cache hit (digest-pinned, no registry call), andpublish_registry_cache_hit(Pulling,CacheHit,Pulled).Nonebefore any log or event and goes to the worker, which prepares, reports and fails exactly as before. Errors are left to the worker on purpose (for example a missing sandbox is stillCancelled, from the worker path), so error precedence does not change. Cancellation after the plan is still caught by the existingensure_provisioning_activecheck that follows image resolution. The overlay preparation keeps its worker.LocalEngineProbefunction so the tests can run on hosts where Docker answers (CI runners included); production passesconnect_local_container_engine.create_sandbox received→sandbox root disk plan resolved114 → 1–2 ms. This figure is not a measurement of the worker bypass alone. Measured on the v0.1.7 driver with the same changes; the code path is unchanged onmain(659b45f3b), which this branch is based on.Testing
cargo fmt -p openshell-driver-vm -- --check,cargo clippy -p openshell-driver-vm --all-targets -- -D warnings,cargo test -p openshell-driver-vm(lib: 304 passed)cached_digest_pinned_image_plan_skips_the_worker_only_on_a_digest_cache_hit: eight cases through a stub worker that records each run (bootstrap-only hit, workload equal to the bootstrap image, cache miss, tag, other workload image, rootfs tar, reachable engine, locally built image); checks which ones ran the worker, the plan, and that the fast path emitsPulling,CacheHit,Pulled. With the fast path disabled it fails withbootstrap-only hit: worker ran.guest_runtime_identity_built_once_matches_the_embedded_bytes(from the cherry-picked commit): the build-time value equals the hash of the embedded bytes computed at run time.cached_digest_pinned_image_plan_keeps_the_worker_path_errors: with the root disk cached, a missing and a deleting sandbox still fail asCancelledand no worker starts.The same change, on the v0.1.7 driver, booted VM sandboxes from a cached digest-pinned image on an x86-64 KVM host, and the unit tests above (in their v0.1.7 form) also passed on arm64.
Checklist