# How it stays fast

A scan has a budget of 5 seconds. Three habits keep it inside that.

## 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 `.git` file, `HEAD`, `commondir`, `packed-refs` and stash log are read from disk. No subprocess runs for them. One `git rev-list` per repository tells which `HEAD`s no remote has. `git status` runs only for a checkout nothing cheaper has decided.
- **The process table.** One read of every working directory (`/proc` on Linux, `lsof` on macOS) tells which checkouts are in use.
- **Settings files.** The pnpm store path comes from the environment, `pnpm/rc` and `~/.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

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

`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

A report is always whole entries. A budget cut never leaves half an entry. Three fields say what is missing:

- `partial` is `true` when a source or a walk didn't finish.
- `skipped` names each source that had no answer, with `budget`, `error` or `remote` as the reason.
- Each entry's `bytes.precision` says how far to trust its size. See [the JSON report](https://whatfrees.loadsheet.dev/reference/report#precision).

## 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](https://whatfrees.loadsheet.dev/guide/installation#where-the-size-cache-goes) for the folder. `--no-cache` skips it.

<!-- vitehub-docs:section-links -->
## In this section

- [Introduction](https://whatfrees.loadsheet.dev/raw/guide.md)
- [Installation](https://whatfrees.loadsheet.dev/raw/guide/installation.md)
- [How it stays fast](https://whatfrees.loadsheet.dev/raw/guide/speed.md) (this page)
- [Verdicts](https://whatfrees.loadsheet.dev/raw/guide/verdicts.md)
- [Sources](https://whatfrees.loadsheet.dev/raw/guide/sources.md)
- [whatfrees check](https://whatfrees.loadsheet.dev/raw/guide/check.md)
- [For agents](https://whatfrees.loadsheet.dev/raw/guide/agents.md)

Next: [Verdicts](https://whatfrees.loadsheet.dev/raw/guide/verdicts.md)

All pages: [llms.txt](https://whatfrees.loadsheet.dev/llms.txt)

Something on this page does not work as written? Tell the user, and draft an issue for them to post: [issue tracker](https://github.com/words-with-agents/whatfrees/issues). Report a security vulnerability privately, never in a public issue.
