DiskPrism app icon

The disk map that fits in 612 KiB

DiskPrism is a native macOS disk space analyzer. It scans with getattrlistbulk, draws a cushion treemap or a sunburst with Metal, and goes completely quiet when you stop moving.

Complete app bundle, no dependencies
612 KiB
Files scanned per second
454,024
Draw calls for 47,841 blocks
1
CPU and GPU when idle
0%

Try it here

The same layouts and shaders, ported to WebGL. The tree is made up: 4,627 files, 35 of them in iCloud only, a few hard-linked between two apps, and two sparse disk images. Click a folder to open it. Switch to Logical and back to see the cloud files appear and collapse.

Loading the demo

Contents

    File types

      The demo could not start in this browser. The screenshots above show the same views.

      Benchmarks

      Measured on an Apple M2 with 8 GB, Release build, warm disk cache. Run --benchmark to get the numbers for your own Mac.

      Scanning /Applications 224,913 files in 47,003 folders

      Solid bars end at the fastest run, hatching at the slowest. That makes DiskPrism about 10× faster than du -sk: 8× comparing the fastest runs and 14× comparing medians. du uses one thread. Peak memory was 35 MB.

      The whole app 612 KiB on disk

      Executable, arm64
      435,744 B
      App icon
      163,596 B
      Shaders.metal, as source
      14,180 B
      Signature and Info.plist
      4,921 B

      Whole disk

      Files
      2,046,512
      Folders
      520,131
      Time
      9.4 s
      Peak memory
      192 MB
      Inodes counted twice
      0

      Drawing

      Nodes
      440,000
      Blocks drawn
      47,841
      Draw calls
      1
      GPU time, 2880×1800
      1.8 ms
      Layout
      9 to 11 ms

      Interaction

      Hit test, treemap
      59 ns
      Hit test, sunburst
      97 ns
      Hover to read-out
      0.56 ms
      Frames per second, idle
      0
      CPU, idle
      0.0%

      Correctness

      CTest
      17 of 17
      Checks
      28,500+
      Fuzzed kernel buffers
      20,000
      ASan, UBSan, TSan reports
      0
      Leaks, core and live app
      0

      The inode check compared every path of the whole-disk scan: 2,006,687 single-link files and 520,932 folders. Idle means zero frames submitted, so the GPU has nothing to do.

      Four decisions behind the numbers

      Ask the kernel for a whole directory at once

      getattrlistbulk returns names, sizes, dates, flags and link counts for a batch of entries in one call. A pool of work-stealing threads decodes each 128 KiB buffer with bounds checks and memcpy, because 8-byte fields sit on 4-byte boundaries.

      macOS gives / and /System/Volumes/Data the same device ID, so comparing st_dev would count your files twice. Three checks keep a scan on its volume:

      1. Mount status of each entry, from ATTR_DIR_MOUNTSTATUS
      2. Mount table, looked up before a directory is opened
      3. Device ID of every entry in the batch
      One file record, byte by byte
      1. 0length4
      2. 4returned_attrs20
      3. 24error4
      4. 28name_ref8
      5. 36devid4
      6. 40objtype4
      7. 44modtime16
      8. 60flags4
      9. 64fileid8
      10. 72linkcount4
      11. 76allocsize8
      12. 84datalength8

      92 bytes, then the name. allocsize comes before datalength: the kernel packs by bit value.

      Keep the tree in one array

      Every file is a 56-byte record in one contiguous block of virtual memory, linked by 32-bit indices. Names live back to back in a string pool. Threads reserve space with a single atomic step and never invalidate each other's pointers.

      A parent always comes before its children, so adding up two million sizes is one backward pass. Deleting a file subtracts its size up the ancestor chain and the map updates without a rescan.

      One node of the tree
      1. 0allocated_bytes8
      2. 8logical_bytes8
      3. 16mtime8
      4. 24parent_idx4
      5. 28first_child_idx4
      6. 32next_sibling_idx4
      7. 36name_offset4
      8. 40file_count4
      9. 44child_count4
      10. 48flags4
      11. 52name_len2
      12. 54ext_id2

      56 bytes. With its name, a file costs about 74.

      Count what is really on the disk

      A file's length says little about the space it takes. DiskPrism reads the allocated blocks and treats four cases separately. The scan threads run under an I/O policy that forbids downloading cloud files, and cloud-only folders are never opened.

      In the demo treeLogicalOn disk
      iCloud file, not downloaded SF_DATALESS22.5 GB0 B
      Second name of a hard-linked library417.7 MB0 B
      Sparse disk image68.7 GB21.2 GB
      Symbolic linkits own length0 B, never followed

      Draw everything in one call

      Each block carries the coefficients of its cushion: a parabola per nesting level, summed. The fragment shader derives the surface normal from them, so shading needs no textures and no geometry beyond four vertices. The sunburst computes exact polar distances for smooth edges.

      The shader ships as text and compiles at launch with newLibraryWithSource:, so building needs only the Command Line Tools.

      [encoder drawPrimitives:MTLPrimitiveTypeTriangleStrip
                  vertexStart:0
                  vertexCount:4
                instanceCount:47841];
      Cross-section of a cushion: one parabola for the folder, one for each subfolder, one for each file.

      Download

      For macOS 14 or later. A workflow builds both apps from the tagged commit, and publishes them only if the tests pass on every system it tries.

      Latest release on GitHub

      Choose a file

      arm64 is for Apple silicon and unpacks to 612 KiB. x86_64 is for Intel and unpacks to 648 KiB.

      First launch

      The app is signed ad hoc and not notarized by Apple, so macOS blocks it the first time. In System Settings, open Privacy & Security, scroll down, click Open Anyway and confirm.

      Tested on

      Virtual machines with macOS 15, 26 and 27 on Apple silicon and macOS 15 on Intel. macOS 14 and the graphics drivers of physical Intel Macs are untested.

      Build from source

      You need macOS 14 or later, CMake 3.24 or later, and the Command Line Tools (xcode-select --install). Xcode is not required.

      Get the code

      git clone https://github.com/berkayceylan/DiskPrism.git
      cd DiskPrism

      Build

      cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
      cmake --build build -j

      Launch

      open build/DiskPrism.app

      Benchmark your Mac

      build/DiskPrism.app/Contents/MacOS/DiskPrism --benchmark /Applications --runs 5

      Run the tests

      ctest --test-dir build --output-on-failure

      Signing

      The build signs the app ad hoc, on your own Mac. An app you build yourself opens normally. If you copy it to another Mac, macOS blocks the first launch there, as with a download.

      Full Disk Access

      DiskPrism works without it. macOS then hides some protected folders, and the app tells you how many it skipped. If you grant it, macOS ties the permission to that build and may ask again after you rebuild.

      If the C++ headers are missing

      Some Command Line Tools updates leave a stale usr/include/c++ folder behind that hides the real headers. CMake detects this, warns, and builds against the SDK's headers.