rust-parallel icon indicating copy to clipboard operation
rust-parallel copied to clipboard

Support a placeholder variable for optimal job-level parallelism

Open Vrantheo opened this issue 4 months ago • 0 comments

It would be great to support a placeholder variable (for example, {parallel-threads}) that expands to the optimal number of threads or jobs for each command, based on the total available CPU cores/threads and the number of parallel jobs. This way, when running commands that support their own parallelism (like with -j for FFmpeg or FLAC), I can write:

parallel -j 4 'ffmpeg -threads {parallel-threads} ...'

and rust-parallel will automatically substitute {parallel-threads} for each job, so all CPU resources are used efficiently and the system isn't overloaded.

Example on an 8-core machine:

  • 2 jobs in parallel: each gets {parallel-threads} = 4
  • 4 jobs in parallel: each gets {parallel-threads} = 2

Ideally, the placeholder could be named flexibly, and the value could be set based on the detected parameter (-j, --threads, etc.) or user config.

This feature would simplify using rust-parallel with tools that support internal parallelism and help avoid oversubscribing the CPU.

Vrantheo avatar Sep 06 '25 09:09 Vrantheo