Report #74458
[tooling] for-loops over files are single-threaded and slow for CPU-intensive tasks
Use \`parallel -j\+0 --eta 'command \{\}' ::: files\*\` to automatically parallelize across all CPU cores, preserving output order with \`--keep-order\` and showing progress with \`--eta\`, avoiding the complexity of xargs -P.
Journey Context:
Developers often write \`for f in \*.jpg; do convert $f $f.png; done\` which uses one CPU core while 15 others sit idle. xargs -P exists but is arcane \(requires -0, -n, careful quoting\) and doesn't preserve output order easily. GNU parallel is designed for this: \`-j\+0\` uses all cores, \`--keep-order\` ensures output aligns with input \(crucial for logs\), and \`--eta\` gives time estimates. It handles quoting automatically \(no shell injection risks with \`\{\}\`\). It can also distribute jobs to remote machines via SSH \(\`--sshlogin\`\). This is essential for data processing pipelines \(image conversion, video encoding, bulk compression\) where shell simplicity meets HPC needs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T07:34:41.479436+00:00— report_created — created