A scan has a budget of 5 seconds. Three habits keep it inside that.
Owners first
Section titled "Owners first"The owner of a thing already knows its size and its state. whatfrees asks the owner before it reads a single file.
- Git. A checkout's
.gitfile,HEAD,commondir,packed-refsand stash log are read from disk. No subprocess runs for them. Onegit rev-listper repository tells whichHEADs no remote has.git statusruns only for a checkout nothing cheaper has decided. - The process table. One read of every working directory (
/procon Linux,lsofon macOS) tells which checkouts are in use. - Settings files. The pnpm store path comes from the environment,
pnpm/rcand~/.npmrc. pnpm doesn't start.
A source that can't answer in time is skipped and named in skipped. The rest of the report still prints.
A walker with a deadline
Section titled "A walker with a deadline"What no owner sized, a pool of four worker threads walks. It never follows a symlink and never crosses into another file system.
The likeliest deletions go first: orphan, then safe, ask, unchecked, unsaved, and live last. git status gets half of what is left of the budget, and sizing gets the rest.
When the deadline comes, a tree still being read returns what was counted so far. Its precision is lower-bound, and the text report prints it as ≥4.2 GB. A tree the walker never reached is unmeasured. The report sets partial to true, and its next list suggests a longer budget.
| Flag | Effect |
|---|---|
--budget 10 | Ten seconds for the whole scan |
--budget 0 | Owners answer, nothing is walked. Owners get a short floor even then |
--exact | No deadline and no size cache. Every tree is read to the end |
Bytes that come back
Section titled "Bytes that come back"du counts a file once however many links it has. That isn't what deleting frees. A file with a second link outside the folder stays on disk.
whatfrees counts disk blocks per inode and splits them in two:
| Field | Meaning |
|---|---|
frees | Blocks of files whose links are all inside the folder |
shared | Blocks of hard-linked files that a link outside the folder keeps |
apparent | frees + shared, what du prints |
A pnpm or bun project links its node_modules files to the store. Deleting the project frees little of them, and deleting the store frees little while projects still link to it. shared shows that.
Sizes come from st_blocks, so a sparse file counts the blocks it uses, not the length it claims.
Partial results
Section titled "Partial results"A report is always whole entries. A budget cut never leaves half an entry. Three fields say what is missing:
partialistruewhen a source or a walk didn't finish.skippednames each source that had no answer, withbudget,errororremoteas the reason.- Each entry's
bytes.precisionsays how far to trust its size. See the JSON report.
The size cache
Section titled "The size cache"A single file's size is stored in measure.json, keyed by path and modification time, and checked against the file's current blocks and link count before it is used. A hit sets cached: true on the entry. Directories are never cached, because a directory's stat says nothing about what is under it. See Installation for the folder. --no-cache skips it.