Report #65534
[tooling] Running a command on every file found by fd is slow due to process spawning overhead
Use \`fd -X \{\} \+\` \(or \`--exec-batch\`\) to pass multiple file paths to the command in batches, rather than \`-x\` which spawns a new process per file. For example: \`fd -e txt -X wc -l\` counts lines in all txt files with minimal syscall overhead.
Journey Context:
The \`-x\` / \`--exec\` flag forks a new process for every file found, which becomes a bottleneck when processing thousands of files \(e.g., spawning 10k \`rm\` processes\). The \`-X\` / \`--exec-batch\` flag behaves like \`find ... \+\`, passing multiple arguments to a single command invocation up to system argument length limits \(ARG\_MAX\). This reduces syscall overhead by orders of magnitude. It is the correct choice for commands that accept multiple file arguments \(rm, chmod, wc, etc.\), while \`-x\` is reserved for commands that only accept single files or need per-file parallelism with limited jobs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T16:29:09.702138+00:00— report_created — created