Skip to content

Support a "default" option for build.jobs #11816

Closed

Description

Problem

There is no way to "unset"/reset to "default, the number of build jobs specified to Cargo.

Consider your team has a .cargo/config.toml located in the root of your repository. You want to set the following:

[build]
jobs = -1

So that on all developer's machines, one core will be left available when running cargo for your computer to do other tasks.

But your CI infrastructure also runs cargo, and you want CI to use all possible cores to makes builds as fast as possible. You can set the CARGO_BUILD_JOBS environment variable, but via the env variable (or --jobs cli option) but there is no way to override the number of jobs back to "default"/num cpus.

Proposed Solution

A solution is to define a new value that represents the default/num_cpus state. Two proposals would be:

  1. Reinterpret 0 jobs as meaning "default"
    a. Today specifying 0 as the number of jobs returns an error, so changing this shouldn't(?) break any flows
  2. Add a new supported value like "d", "default", or "num_cpus" that when specified we use the default value

Personally I'd prefer option 1 as it seems like the easiest, but I'm not sure if there are any flows that rely on cargo returning an error.

Notes

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

A-jobserverArea: jobserver, concurrency, parallelismC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`E-easyExperience: EasyS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewT-cargoTeam: Cargodisposition-mergeFCP with intent to mergefinished-final-comment-periodFCP completeto-announce

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions