macOS slowdown due to temporary files outside of Library/Caches
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 15.5k
- Forks
- 3k
- Avg merge
- 23h 30m
- Merged PRs (30d)
- 51
Description
I've noticed that when I'm working on Rust projects, macOS processes mds and mds_worker are consuming high amount of CPU and disk I/O. These processes are indexing the disk for macOS Spotlight search functionality. I suspect churn of large numbers of files in target/ subdirectories like .fingerprint and incremental causes Spotlight to continually rescan and reindex these directories.
macOS expects well-behaved applications to use ~/Library/Caches or /tmp for all temporary files, so it doesn't have any official APIs for reducing negative impact of file churn elsewhere. Officially the only way to exclude folders from Spotlight is to add them as "private" in GUI settings, which is cumbersome.
I see two ways of fixing this problem:
- Move
build,incrementalto a subdirectory in~/Library/Caches/Cargo.
- The subdirectory could be derived from a hash of
destdir, so that these directories remain separate. - Optionally the could be moved to the correct temp dir only if
CARGO_TARGET_DIRis not set, so that users who have customizedCARGO_TARGET_DIRare not surprised by files being put elsewhere. - Optionally there could be symlinks in target/ to the new temp location, so that 3rd party utilities that peek into Cargo's internals continue to work.
- or rename them to
build.noindex,incremental.noindex. This naming convention is a poorly documented way of excluding folders from Spotlight indexing. It isn't as good as using~/Library/Caches, but would solve the Spotlight issue with a smaller change to Cargo's behavior.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by investigating Cargo's handling of target/ directories, especially build and incremental, along with the CARGO_TARGET_DIR behavior described in the issue. Compare the proposed Library/Caches relocation and .noindex naming approaches, including compatibility implications for users and third-party tools. Done means selecting and implementing a clearly scoped approach that reduces Spotlight churn without breaking expected target-directory behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100