LinuxCommandLibrary

jj-parallelize

Execute commands in parallel

TLDR

Parallelize given revisions

$ jj parallelize [revsets]
copy

SYNOPSIS

jj parallelize [-j --jobs JOBS] [-p --plain] <REVSET> -- <COMMAND> [<ARGS>...]

PARAMETERS

-j, --jobs <JOBS>
    Maximum number of parallel jobs (default: 128)

-p, --plain
    Disable colored output from executed commands

<REVSET>
    Revset to select working copies (default: all())

-- <COMMAND> [<ARGS>...]
    Shell command and arguments to run in each working copy

DESCRIPTION

The jj parallelize command from Jujutsu (jj), a Git-compatible version control system, enables running a shell command simultaneously across multiple working copies matching a specified revset. Ideal for monorepos or multi-repo setups, it automates tasks like building, testing, or syncing on diverse codebases.

Jujutsu treats working copies as lightweight, allowing operations on many repos efficiently. By default, it targets all working copies (all() revset) and runs up to 128 jobs in parallel, prefixing output with the working copy path for clarity. Each command executes in its respective working copy directory, preserving context.

Use cases include: cargo check on Rust crates, npm test in Node projects, or custom scripts. Output interleaves due to parallelism, but --plain simplifies parsing. Errors from any job halt further execution only if configured, but typically reports all failures.

This boosts productivity in large-scale development, reducing sequential wait times from hours to minutes. Requires Jujutsu installed and working copies initialized via jj init. Integrates seamlessly with jj's revset language for precise selection, like branch("main") or remote("origin").

CAVEATS

Output from jobs interleaves; use --plain and redirect for parsing. Runs in working copy dirs—absolute paths may fail. No built-in error aggregation; check exit codes manually. Limited to local working copies.

EXAMPLES

jj parallelize all() -- cargo check
jj parallelize 'remote("origin")' -- git fetch origin
jj parallelize -j 8 'branch("main")' -- npm test

GLOBAL OPTIONS

Inherits jj globals: -R --repository PATH, --color when, -v verbose levels.

HISTORY

Introduced in Jujutsu v0.1.0 (April 2023) by Martin von Zweigbergk. Evolved for large-repo efficiency at Google; now at v0.20+ with improved parallelism and revset support.

SEE ALSO

parallel(1), xargs(1), make(1), jj(1)

Copied to clipboard