Skip to content

Add opt-in per-disk sync= and cache= attachment modes#42

Open
amr-mesbah wants to merge 1 commit into
s-u:masterfrom
amr-mesbah:feature/disk-sync-cache-modes
Open

Add opt-in per-disk sync= and cache= attachment modes#42
amr-mesbah wants to merge 1 commit into
s-u:masterfrom
amr-mesbah:feature/disk-sync-cache-modes

Conversation

@amr-mesbah

@amr-mesbah amr-mesbah commented Jun 13, 2026

Copy link
Copy Markdown

Exposes VZDiskImageStorageDeviceAttachment cachingMode/synchronizationMode (macOS 12+) as two optional, opt-in storage options, settable from both the JSON config and the --disk CLI:

sync=<full|fsync|none>       (default: full — unchanged)
cache=<auto|cached|uncached> (default: auto — unchanged)

Why

Ephemeral VMs pay a large per-fsync stall under the default full synchronization: every guest fsync blocks on a host-stable commit. Allowing sync=none,cache=cached removes that stall.

Measured (macOS 26.2 guest, same disk, only the sync mode changed)

full sync (default) sync=none,cache=cached
5000 fsync'd small writes 32.16s 4.99s (6.4x)
sequential write (1GB) 984 MB/s 1593 MB/s (1.6x)

Safety / compatibility

  • With neither option set, behaviour is byte-for-byte identical to before (legacy initWithURL:readOnly:error: path) — existing configs unaffected.
  • The macOS 12 initializer is used only when an option is supplied, gated by if (@available(macOS 12.0, *)) plus a __MAC_OS_X_VERSION_MAX_ALLOWED >= 120000 compile guard, so the macOS 11 build is preserved.
  • Invalid values raise a clear VMConfigDiskStorageError.

Note: sync=none is intended for ephemeral VMs (no host-crash durability); not for golden/base images or during --restore.

Expose VZDiskImageStorageDeviceAttachment's cachingMode and
synchronizationMode (macOS 12+) via two new, optional storage options
settable from both the JSON config and the --disk CLI:

  sync=<full|fsync|none>      (default: full, unchanged)
  cache=<auto|cached|uncached> (default: auto, unchanged)

When neither is set the behaviour is byte-for-byte identical to before
(legacy initWithURL:readOnly:error: path), so existing configs are
unaffected. The new initializer is taken only when an option is supplied
and only under `if (@available(macOS 12.0, *))`, with a >=120000 SDK
compile guard, preserving the macOS 11 build. Invalid values raise a
clear VMConfigDiskStorageError.

Motivation: ephemeral CI VMs pay a large per-fsync stall under the
default full synchronization (every guest fsync blocks on a host-stable
commit). Allowing sync=none,cache=cached removes that stall. Measured on
a macOS 26.2 guest: 5000 fsync'd small-file writes dropped from 32.2s to
5.0s (6.4x), sequential write 984 -> 1593 MB/s.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant