Skip to content

Support a placeholder variable for optimal job-level parallelism #57

@Vrantheo

Description

@Vrantheo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions