Expand description
The parallel walker: one pass over a tree, pruning at every directory it claims.
§Prune on match
When a rule claims a directory the walker records it and returns WalkState::Skip. That
single decision is the performance thesis. npkill walks into node_modules to size it,
enumerating tens of thousands of inodes through its full scan pipeline to produce one
number the user is about to discard by deleting the tree. Here the scan stops at the
boundary and the subtree, if it is measured at all, is handed to the tight loop in
crate::size.
§Why every ignore file is switched off
ignore is here for two things: the parallel walk, and the gitignore stack that tier
two needs. Tier one must not use the second. node_modules, target and .venv are
gitignored in every repo that has a .gitignore, so a walk with the default filtering on
would find almost nothing — and hidden(false) matters for the same reason, since
.venv, .gradle, .nx and .build all start with a dot. Tier two therefore brings its
own matcher, and asks it per path rather than letting it steer the walk. See
crate::fallback.
§The two tiers, in order
Tier one is asked first at every directory, and it prunes. That ordering is tier two’s fourth condition, “no tier-one rule already claimed it”: there is no separate check for it anywhere, and there does not need to be.
Structs§
- Hit
- One reclaimable thing: a directory, or — when the walk was asked for them — a gitignored file.
- Ignored
Claim - A claim made by the tier-two gitignore fallback.
- Ignored
File Claim - A claim on a gitignored file.
- Priced
- A price for a claim that was published without one.
- Rule
Claim - A claim made by the curated ruleset.
- Walk
Error - Something the walk could not read. Collected rather than fatal: one unreadable directory must not cost the user the rest of the scan.
- Walk
Outcome - What a walk found.
- Walker
- A configured scan of one tree.
Enums§
- Claim
- Why something is reclaimable, and what is known about it.
- Found
- What a walk reports, as it happens.
Constants§
- UNLABELLED
- What tier two says in place of a label.
- WORK_
TREE_ FLOOR - How long a linked work tree has to have been left alone before it is offered at all.
- WORK_
TREE_ LABEL - What a claimed linked work tree is called on a row.