Skip to content

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

Merged
s-u merged 1 commit into
s-u:masterfrom
amr-mesbah:feature/disk-sync-cache-modes
Jun 22, 2026
Merged

s-u merged 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
Contributor

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) <[email protected]>
@amr-mesbah

Copy link
Copy Markdown
Contributor Author

@s-u What do you think of the change?

@s-u

s-u commented Jun 16, 2026

Copy link
Copy Markdown
Owner

@amr-mesbah Thanks! Looks like it's worthwhile. I had only time for a quick scan and it looked reasonable, so I'll have a closer look later today.

@s-u
s-u merged commit 5f9e6bf into s-u:master Jun 22, 2026
@s-u

s-u commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Thanks!

@BillyONeal

Copy link
Copy Markdown

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

Does this mean that if today we do setup with ~/macosvm ./vm.json and then run normal runs with ~/macosvm --ephemeral ./vm.json afterwards we should edit the json to add these?

Thanks for the feature!

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.

3 participants