apfs-cow-sandbox

command
v0.6.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

apfs-cow-sandbox

Zero-CGo, zero-sudo APFS Copy-on-Write directory-tree sandboxes and a zero-copy SHA-256 content-addressed artifact store built with x/apfs.

What It Demonstrates

  • Instant CoW Directory-Tree Sandboxes (apfs.CloneFile): Seeds a multi-file workspace (main.go, config.json, src/worker.go, and an 8 MiB data/state.db), forks 4 isolated sandboxes via clonefile(2) (apfs.WithNoOwnerCopy()), mutates all 4 concurrently, and verifies the base tree and sibling sandboxes remain byte-identical.
  • Zero-Copy Content-Addressed Artifact Cache (cas/): Stores a 4 MiB object by SHA-256 digest, materializes it into a workspace with apfs.CloneFile instead of a hardlink, mutates the materialized copy in-place, and proves the CAS object is untouched.

Usage

CGO_ENABLED=0 go run ./examples/kernel/apfs-cow-sandbox

Measured Output (Apple M4 Max, CGO_ENABLED=0)

apfs-cow-sandbox (temp=/var/folders/kj/qbc32fzd2pv6ngnsysy8vpmw0000gn/T/apfs-cow-sandbox-2230249086)

[Part A] Instant CoW Directory-Tree Sandboxes (base: 4 files, 8 MiB data blob)
  fork sandbox-1: clonefile(dir) =    978 µs
  fork sandbox-2: clonefile(dir) =    367 µs
  fork sandbox-3: clonefile(dir) =    465 µs
  fork sandbox-4: clonefile(dir) =    540 µs
  mean full-tree clone latency: 588 µs across 4 sandboxes
  isolation verified: base byte-identical (sha256=2fcc5f39e3bc…), 4/4 sandboxes isolated

[Part B] Zero-Copy SHA-256 Content-Addressed Artifact Store (4 MiB object)
  stored cas/c38fa574d100b48c…
  materialized via apfs.CloneFile in 478 µs
  mutated workspace copy (sha256=0837b77ea45f…); CAS object intact: true

Documentation

Rendered for darwin/amd64

Overview

Command apfs-cow-sandbox demonstrates instant APFS copy-on-write directory tree sandboxes and a zero-copy content-addressed artifact store using x/apfs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL