Skip to content

perf(clean): Optimize (legacy) clean with multiple -p specifiers - #16264

Merged
epage merged 1 commit into
rust-lang:masterfrom
osiewicz:clean-perf
Dec 4, 2025
Merged

perf(clean): Optimize (legacy) clean with multiple -p specifiers#16264
epage merged 1 commit into
rust-lang:masterfrom
osiewicz:clean-perf

Conversation

@osiewicz

Copy link
Copy Markdown
Contributor

Co-authored-by: dino dinojoaocosta@gmail.com

What does this PR try to resolve?

This commit optimizes implementation of cargo clean -p by reducing the amount of directory walks that take place.
We now batch calls to rm_rf_prefix_list, thus potentially avoiding multiple walks over a single subdirectory. In practice this helps us significantly reduce the runtime for clearing large workspaces (as implemented in #16263); for Zed, cargo clean --workspace went down from 73 seconds to 3 seconds.

We have 216 workspace members.

How to test and review this PR?

We've tested it by hand, running it against regex, ruff and zed codebases.

This PR is still marked as draft, as I don't love the code. I would also understand if y'all were against merging this, given that new build directory layout is in flight.