Disk usage

Clones share most of their blocks with the golden image, so adding up their sizes says little. On one repo here, the image files add up to 99 GB while they take 26 GB of disk. clove du counts each block once and says what removing each piece would free.

clove duthis repo: golden image, clones, checkpoints, spare, trash, state, logs
clove du --all-reposevery repo, ~/.clove, and the disk's size and free space
clove du --inside feat-loginwhat a clone holds, by folder and by kind (node_modules, target, .git...)
clove du --inside goldenthe same for the golden image
clove du --inside mainand for the main checkout, for comparison (yours, not clove's)
shell
clove  26G on disk  (its files add up to 99G: 73G is shared, counted once here)
                                           KIND    ON DISK                        SHARES WITH GOLDEN  FREED IF REMOVED
golden image (gen-12)                      golden  15G      ███████████·········                      526M by a refresh
feat-disk-usage                            clone   2.9G     ██··················  12G                 2.9G
explore-throwaway                          clone   2.2G     ██··················  8.1G                2.2G
spare                                      spare   273M     ▏···················  14G                 273M
site-commit-graph                          trash   1.1G     █···················  11G                 1.1G
shared by clones, not in the golden image  shared  194M     ▏···················                      -
records and git state                      state   632K     ▏···················                      -
logs                                       logs    68K      ▏···················                      -

The terminal UI shows the same view on B, and the desktop app in each repo's Disk tab, next to List and Map, and on the Disk usage page in the sidebar for every repo.

What each number means

Every byte is in exactly one row, so the rows add up to the total.

  • On disk (total)What this repo's clove state takes, each block once: everything under ~/.clove/repos/<repo>-<hash>/. Deleting all of it (clove deinit --all, or clove deinit once every clone and the trash are gone) gives this much back.
  • Its files add up toThe image files' allocated sizes added up, as du -sh ~/.clove or Finder would count them. The difference is what clones share.
  • Golden image: on diskAll its blocks, including the ones clones share with it. Freed by a refresh: the blocks only it holds, which go when a refresh replaces it.
  • A clone: on diskThe blocks only it holds, its checkpoints included: what it wrote since it was made. Shares with golden: what it still has in common with the golden image, already counted in that row. Freed if removed: the same as its on-disk figure; checkpoints show what dropping each one alone frees.
  • SpareThe clone made ahead of time (macOS). It shares almost everything with the golden image.
  • TrashA removed clone and its checkpoints. clove rm moves a clone here, so its bytes come back only when the entry goes (clove trash empty, or trash.keep after a day by default).
  • Shared by clones, not in the golden imageBlocks two or more clones or trash entries hold together, outside the current golden image. These are mostly an older golden image that those clones were made from, before a refresh. They go when the last clone holding them goes.
  • Records and git state, logsclove's own small files: meta.json, the golden and checkpoint index snapshots, history.jsonl, step logs.

--all-repos adds ~/.clove outside the repos' folders (caches, agent session links, the service's copy of clove) and the disk's size and free space.

--inside walks a mounted worktree and adds up its files' allocated sizes, each hard link once, by top-level folder and by kind wherever it is nested (node_modules, target, .git, Python envs, build output, caches). On macOS it also gives what the clone's volume says it uses. That figure is usually a little lower than the files' total, because files APFS cloned inside the volume count once per file in the walk. The golden image stays unmounted on macOS, so --inside golden reads the spare, a mounted copy of it, and fails when there is no ready spare. The walk takes about half a second for 40k files and is reused for ten minutes in the app and the terminal UI.

How it is measured

macOS

Each image file's data is mapped to its physical blocks on the APFS volume with fcntl(F_LOG2PHYS_EXT), the same mapping the kernel uses for clonefile copies. The blocks of every image are then merged in one pass: a block held by the golden image goes to the golden row, a block held by one clone (or one trash entry) goes to it, and a block held by several goes to "shared". This is exact, not an estimate: the per-file sums match st_blocks, and the total matched df within a few MB in the test below. Mapping a 16 GB image takes about 0.1s; a repo with 8 images takes about 1s. The app and the terminal UI show the last answer while they measure again, at most once a minute, or right away after a clone is made or removed.

Linux

The repo's one btrfs image file holds everything, so its allocated size on the host is the total, exactly. The split comes from btrfs quota groups (simple quotas on kernel 6.7 and later, full qgroups before), read from sysfs:

  • a clone's row is its subvolume's exclusive bytes plus its checkpoints'
  • a trash entry's row is the same for its renamed subvolume and checkpoints
  • the golden image's row is what the volume uses minus those
  • free space inside the image that the host still holds shows as its own row

With simple quotas, a block is charged to the subvolume that wrote it, so a block a clone shares with its own checkpoint counts in the clone's row. The split is marked approximate for that reason. Without quotas (older kernels, or a volume made before they were on), only the total is known: clove du says so and shows one row for the golden image and clones together instead of guessing. The pool must be mounted for anything but the total.

Checking it against df

On a Mac with a scratch repo whose warm step writes 300 MB, in a throwaway CLOVE_HOME. df is the APFS data volume's used space before and after each step; other processes wrote to the same volume meanwhile, so small differences are noise.

Step df change clove du total du -sk of the state
clove init +312.3 MB 312.0 MB 312.0 MB
clove new feat/a +1.3 MB 313.2 MB 624.1 MB
write 200 MB in feat/a +201.3 MB 514.3 MB 824.2 MB
clove new feat/b, write 100 MB +103.7 MB 616.5 MB 1236.3 MB
clove rm feat-a (to the trash) +0.1 MB 616.7 MB 1236.4 MB
clove trash empty (clove du said 202.3 MB) −201.8 MB 414.2 MB 724.1 MB
clove rm --purge feat-b (said 102.2 MB) −97.5 MB 312.0 MB 312.0 MB

du -sk counts the golden image once per clone, so it doubles with each clone while the disk barely moves. clove du tracked df within 2 MB on every step but the last, where df moved 5 MB less than predicted, from another process writing meanwhile or APFS freeing the blocks a moment later.