Skip to content

macOS slowdown due to temporary files outside of Library/Caches #8684

Open
@kornelski

Description

@kornelski

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:

  1. Move build, incremental to a subdirectory in ~/Library/Caches/Cargo.
  • The subdirectory could be derived from a hash of dest dir, so that these directories remain separate.
  • Optionally the could be moved to the correct temp dir only if CARGO_TARGET_DIR is not set, so that users who have customized CARGO_TARGET_DIR are 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.
  1. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugO-macosOS: macOSPerformanceGotta go fast!S-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions