Concurrency¶
Every mpm command fans out over the managers it selected and drives them at the same time. That is where most of the speed comes from: an mpm outdated on a machine carrying a dozen managers costs about as long as its slowest one, rather than the sum of all twelve.
Two things bound that parallelism: how many managers you let run at once, and the handful that reach a backend some other manager reaches too.
How many run at once¶
--jobs caps the number of managers running concurrently. It takes a count, or one of two keywords: auto, the default, is one fewer than the machine’s logical CPU cores, leaving one free for mpm itself and for the system; max is all of them. --jobs 1 runs the managers one after another.
Two situations ignore that setting and run sequentially anyway. A batch of one manager has nothing left to parallelize. And --verbosity DEBUG streams every manager’s raw output line by line, where interleaving a dozen of them would scramble the narration the flag exists to produce.
Before any of that, every command detects which of the managers it selected are installed, by asking each of them for its version. That round is bounded by --jobs and takes the same two exceptions, and it is the only work mpm managers does: --jobs therefore still matters to a command driving no package operation at all.
What each command spreads¶
⇶⇶⇶ every selected manager runs at once.
⇉⇶→ mixed concurrency, where every manager runs at once, except the ones sharing the same backend which runs sequentially.
→→→ one manager at a time, whatever
--jobssays.
Command |
Concurrency |
|---|---|
|
⇉⇶→ |
|
⇉⇶→ |
|
⇶⇶⇶ |
|
⇉⇶→ |
|
→→→ |
|
⇶⇶⇶ |
|
⇶⇶⇶ |
|
⇶⇶⇶ |
|
⇉⇶→ |
|
⇉⇶→ |
|
⇶⇶⇶ |
|
⇶⇶⇶ |
|
⇉⇶→ |
|
⇉⇶→ |
Managers run in parallel; a single manager’s own packages do not. An mpm remove pkg-a pkg-b drives brew and cargo at the same time, but hands pkg-a and pkg-b to brew one at a time. No package manager is safe to invoke twice at once against its own state.
The one command that parallelizes nothing is an mpm install naming a package you left untied to a manager. That install is a priority search: try the managers in order and stop at the first one carrying the package, which cannot be answered by running them all at once. mpm notes at INFO when an explicit --jobs is ignored for this reason. Tie the package to a manager, with --brew or with a purl like pkg:brew/curl, and the install joins the ⇉⇶→ row above.
The subcommands that drive no package operation of their own are left out of the table: there is nothing for them to spread.
Managers that escalate on their own¶
A few managers run sudo from inside their own commands: cask escalates for a privileged payload, fink re-execs its root commands through it, and the AUR helpers call sudo pacman. On a state-changing run that can reach a password prompt, mpm holds such a manager back and runs it once every other manager is done.
The prompt is the reason. A tool writes it straight to the terminal, wherever the cursor sits, and gives it no line of its own. Raised in the middle of a concurrent batch, it lands mid-line between two other managers’ outputs, or behind the progress bar. Nobody can read it there, so nobody answers it, and the run waits until the operation times out. Held to the end, the prompt gets a terminal no other manager is writing to.
Everything else keeps its concurrency and its progress bar: only the last stretch is sequential. Nothing is held back on a read-only query, which never escalates, nor when the credential cache is already warm, which serves the escalation silently. See Privilege escalation and sudo for the probe that decides.
See also¶
Privilege escalation and sudo — why a run that escalates privileges probes the credential cache before fanning out.
Package managers — the full pool, one page each.
CLI parameters —
--jobsalongside every other global option.