szt

See what's taking up your disk.

Run szt (short for sizetree) in any folder to get a tree of where the space went: biggest first, every folder with the total of everything inside it, opened up only where the space is. On a Mac Studio it scans 667,000 files in 2.4 seconds, where du takes 17.

macOS 15+ · Native Swift binary · MIT licensed

Typing szt /Applications: a progress line counts files for about a second, then a colored tree of folder sizes with bars shows the biggest apps, Xcode at 4.20 GB, iMovie at 3.97 GB and Android Studio at 3.22 GB, out of 33.3 GB

szt on /Applications: 33 GB in 447,000 files, scanned in 1.2 seconds. Sizes and bars are colored from cool to hot by their share of the total, and by default the report fits in your terminal; --all prints every entry.

Get started

Installation

Release notes →
Install
brew install urtti/szt/szt
Update
brew update && brew upgrade szt
Benchmarks

How it compares

szt against dua, dust, diskus, gdu, du and ncdu, each with its default settings, on a Mac Studio (M2 Ultra).1

Scanning a folder of software projects123 GB in 667,000 files and 112,000 folders · lower is better
  • szt2.4 s
  • dua2.6 s1.1× slower
  • dust8.1 s3.4× slower
  • diskus11.4 s4.7× slower
  • gdu11.6 s4.8× slower
  • du17.2 s7.2× slower
  • ncdu17.5 s7.3× slower

Median of five runs per tool. Hover or focus a bar for CPU time and memory.

Examples

Everyday use

  • $ sztWhat's big in the current folder
  • $ szt ~ -n 80The 80 biggest things in your home folder
  • $ szt ~/Library -d 2No more than two levels deep
  • $ szt . -m 1GOnly things of 1 GB or more
  • $ szt ~/Downloads -aBy file length instead of space on disk
  • $ sudo szt / -XThe whole startup disk, system volumes too
Under the hood

Why it's fast

A disk usage tool never reads your files. Sizes live in the file system's records, so the whole job is listing folders and asking how big each entry is. How a tool asks, and how many threads ask at once, turns out to be almost everything.

One call per folder, not one per file

Most tools list a folder's names with readdir and then make a separate call (stat, lstat or fstatat) for every file to learn its size. macOS has a better way: getattrlistbulk returns names, types and sizes for hundreds of entries at once. szt lists every folder that way, so a file never gets a system call of its own.

The per-file calls add up: in a profile of du on the projects folder, 60% of its CPU time goes to fstatat. The system calls each tool's binary imports show who does what:

ToolLists a folder withThen, for every file
szt, duagetattrlistbulknothing
ncdugetdirentriesfstatat
dust, diskus, gdureaddirlstat or fstatat
duftsfstatat

dua is the other tool built on getattrlistbulk, which is why it's the close one in the benchmark.

More threads made it slower

With the per-file calls gone, what's left is opening each folder before listing it, and that has a ceiling. Here's szt on the projects folder with different thread counts:

ThreadsTimeKernel CPU time
112.80 s5.1 s
26.52 s5.4 s
43.27 s5.8 s
62.66 s8.5 s
82.50 s11.7 s
102.70 s18.1 s
123.58 s32.4 s
167.63 s106.8 s
2410.59 s200.3 s

A single thread spends much of its time waiting rather than working, so the first few threads help a lot. Up to eight the scan keeps getting faster. Past that it gets slower while the kernel works harder and harder: 24 threads burn 200 seconds of CPU time to finish in 10.6. A profile at 24 threads shows why: 93% of the time is spent inside open, the call that opens a folder so it can be listed. Opening a folder goes through vnode and name-cache bookkeeping that every process on the Mac shares (on this machine the vnode table was full, 263,168 entries out of 263,168, so an open often has to evict an old entry first). Past a handful of threads, they mostly wait for each other.

So szt stops at eight threads. dua's authors arrived at the same number: its thread count defaults to 8 on macOS and to the number of cores elsewhere. Most other tools start a thread per core or more, which on this 24-core Mac means 24 threads for dust and gdu and 72 for diskus. It shows in their CPU time: 122 to 211 seconds for the projects folder, against szt's 12.

Tuned, the per-file calls still cost about double

To tell the two effects apart, here are the other tools at their best thread count on the same Mac:

ToolSettingProjectsCompared with szt
ncdu-t 84.24 s1.8×
dust-T 84.33 s1.8×
diskus-j 84.55 s1.9×
gdu-m 25.87 s2.4×

With threads out of the picture they still take 1.8 to 2.4 times as long, and that's the price of asking about every file separately.

Efficiency cores don't help

Apple silicon mixes fast performance cores with slower efficiency cores. macOS runs background-priority threads on efficiency cores only, which makes it possible to try different mixes on one machine:

ThreadsProjects
4 performance threads3.17 s
4 performance + 4 efficiency threads3.09 s
8 performance threads2.36 s
8 efficiency threads6.55 s
16 threads on the 8 efficiency cores7.15 s

Four efficiency threads on top of four performance threads barely help (3.09 s against 3.17 s), and more threads than cores is a little slower. So szt starts one thread per performance core, as macOS reports in hw.perflevel0.physicalcpu, up to eight: four on a base M-series chip, and up to eight on the Pro, Max and Ultra.