Skip to content

Report APFS clone sharing and estimate reclaimable space - #9

Merged
Harold Hunt (huntharo) merged 1 commit into
mainfrom
port/apfs-clone-accounting
Oct 30, 2026
Merged

Harold Hunt (huntharo) merged 1 commit into
mainfrom
port/apfs-clone-accounting

Conversation

@huntharo

Copy link
Copy Markdown

APFS clones have distinct inodes but share allocated blocks. PwrDisk currently counts each clone in full and projects those listed bytes as savings, so selecting copies while retaining their original can overstate the space freed. A remaining hardlink can likewise retain data after a marked name is removed.

This ports the accounting from huntharo/disktree#3 at 87c02c7 onto PwrDisk main 8f63e4d. The marking and review performance fixes already merged in #5 are reused, without replaying their commit history. PwrDisk branding and release packaging are preserved.

  • Preserve allocated/apparent treemap weights; show clone allocation and estimated repeated allocation separately.
  • Read clone hints with bulk directory metadata. Query private size only for potentially shared files, with bounded, sharded per-scan reuse scoped by real APFS volume and clone identity.
  • Estimate the accepted marks together. Complete clone groups credit shared data once; retained hardlinks prevent crediting their inode. Unknown metadata and allocation outside the data fork produce conservative ranges. The volume meter uses the lower bound and the existing volume attribution.
  • Reuse scan-derived estimates for unchanged selections. Removal plans and worker guards remain fresh. SSH selections retain their read-only, export-only behavior and do not use local APFS accounting.

Fresh real-APFS fixture results, using an 8 MiB original and two cp -c copies:

Scan root Listed, both modes Estimate, metadata disabled Estimate, metadata enabled
Copies, with original outside root 16 MiB 16 MiB 0 B
Original and both copies 24 MiB 24 MiB 8 MiB

These compare the same port binary with metadata disabled/enabled, not separately built main and feature binaries. No deletion was performed in this fixture. Snapshots, open files and subsequent filesystem changes can retain space; the completed removal still reports the measured free-space change.

The node layout grows from 88 to 104 bytes; detailed allocation facts remain sparse. No new home-directory scan or elapsed-time benchmark was run. Historical source evidence is explicitly labelled in the accounting report.

Validation on macOS:

  • cargo xtask lint passed.
  • cargo xtask test: 315 passed (108 app, 200 core, 4 helper integration, 3 xtask); 8 opt-in/manual tests ignored. This includes real clones, modified clones, hardlinks, followed links, resource forks, accepted-set cache invalidation, remote boundaries and operation budgets.
  • cargo build --release -p disktree-app and pwrdisk --help passed.
  • Windows-target core Clippy passed with all targets/features; Windows binaries were not executed locally.

The port also carries the source branch's deterministic window-test palette and platform-correct remote fixture expectations so native theme callbacks and Unix-only live previews do not invalidate the cross-platform regression suite.

Port clone metadata, bounded per-scan reuse, accepted-set savings, and separate UI estimates from huntharo#3 at 87c02c7. Reuse the marking and review performance fixes already in PwrDisk main. Preserve PwrDisk branding, packaging, remote selection boundaries, and fresh removal guards.
@huntharo
Harold Hunt (huntharo) merged commit db9d2e0 into main Oct 30, 2026
6 checks passed
@huntharo
Harold Hunt (huntharo) deleted the port/apfs-clone-accounting branch November 9, 2026 03:30
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