Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootstrap: allow setting --jobs in config.toml #131838

Merged
merged 1 commit into from
Oct 19, 2024
Merged

Conversation

jieyouxu
Copy link
Member

Allow setting --jobs in config.toml's [build] section.

[build]
jobs = 0

If this is unset or set to zero in config.toml, we look at --jobs flag. If that is also unset, then we fallback to std::thread::available_parallelism. If that is not available, then we default to 1. The flags and available_parallelism fallback are already setup, this PR just adds a config.toml option to wire that up.

Closes #131836.

r? bootstrap

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Oct 17, 2024
@rustbot
Copy link
Collaborator

rustbot commented Oct 17, 2024

This PR modifies src/bootstrap/src/core/config.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

This PR modifies config.example.toml.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

@rust-log-analyzer

This comment has been minimized.

@jieyouxu
Copy link
Member Author

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 17, 2024
@jieyouxu jieyouxu force-pushed the boopjob branch 2 times, most recently from 8302cba to e057ca5 Compare October 18, 2024 02:54
@jieyouxu
Copy link
Member Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 18, 2024
Comment on lines 1626 to 1630
if let Some(jobs) = jobs {
if jobs > 0 {
config.jobs = Some(jobs);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should handle it here:

config.jobs = Some(threads_from_config(flags.jobs as u32));

Copy link
Member Author

@jieyouxu jieyouxu Oct 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that there's two layers of precedence, the line there is the top priority --jobs flag. I changed the logic to better reflect the precedence such that:

  • config.jobs and flags.jobs are initially None.
  • config.jobs is Some based on --jobs=N if N > 0 and still None otherwise.
  • If config.jobs is still None, then we fallback to --set build.jobs then [build] jobs. Note that the build toml section is read below this.

I added a precedence test to check this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Remark: I found this config layering somewhat hard to follow)

src/bootstrap/src/core/config/tests.rs Show resolved Hide resolved
config.example.toml Outdated Show resolved Hide resolved
@jieyouxu jieyouxu force-pushed the boopjob branch 2 times, most recently from 4adaf51 to 2fdc3b1 Compare October 18, 2024 05:25
@rust-log-analyzer

This comment has been minimized.

@jieyouxu
Copy link
Member Author

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 18, 2024
@jieyouxu
Copy link
Member Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 18, 2024
@jieyouxu jieyouxu added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 18, 2024
@jieyouxu
Copy link
Member Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 19, 2024
Copy link
Member

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me with/without the nit suggestion

src/bootstrap/src/core/config/config.rs Outdated Show resolved Hide resolved
@onur-ozkan
Copy link
Member

Thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Oct 19, 2024

📌 Commit 65458ae has been approved by onur-ozkan

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 19, 2024
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Oct 19, 2024
bootstrap: allow setting `--jobs` in config.toml

Allow setting `--jobs` in config.toml's `[build]` section.

```toml
[build]
jobs = 0
```

If this is unset or set to zero in config.toml, we look at `--jobs` flag. If that is also unset, then we fallback to `std::thread::available_parallelism`. If that is not available, then we default to `1`. The flags and `available_parallelism` fallback are already setup, this PR just adds a config.toml option to wire that up.

Closes rust-lang#131836.

r? bootstrap
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 19, 2024
…kingjubilee

Rollup of 8 pull requests

Successful merges:

 - rust-lang#127462 (std: uefi: Add basic Env variables)
 - rust-lang#131537 (Fix range misleading field access)
 - rust-lang#131838 (bootstrap: allow setting `--jobs` in config.toml)
 - rust-lang#131871 (x86-32 float return for 'Rust' ABI: treat all float types consistently)
 - rust-lang#131876 (compiler: Use LLVM's Comdat support)
 - rust-lang#131890 (Update `use` keyword docs to describe precise capturing)
 - rust-lang#131899 (Mark unexpected variant res suggestion as having placeholders)
 - rust-lang#131908 (rustdoc: Switch from FxHash to sha256 for static file hashing.)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 19, 2024
bootstrap: allow setting `--jobs` in config.toml

Allow setting `--jobs` in config.toml's `[build]` section.

```toml
[build]
jobs = 0
```

If this is unset or set to zero in config.toml, we look at `--jobs` flag. If that is also unset, then we fallback to `std::thread::available_parallelism`. If that is not available, then we default to `1`. The flags and `available_parallelism` fallback are already setup, this PR just adds a config.toml option to wire that up.

Closes rust-lang#131836.

r? bootstrap
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 19, 2024
…iaskrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#127462 (std: uefi: Add basic Env variables)
 - rust-lang#131537 (Fix range misleading field access)
 - rust-lang#131838 (bootstrap: allow setting `--jobs` in config.toml)
 - rust-lang#131871 (x86-32 float return for 'Rust' ABI: treat all float types consistently)
 - rust-lang#131876 (compiler: Use LLVM's Comdat support)
 - rust-lang#131890 (Update `use` keyword docs to describe precise capturing)
 - rust-lang#131899 (Mark unexpected variant res suggestion as having placeholders)
 - rust-lang#131908 (rustdoc: Switch from FxHash to sha256 for static file hashing.)
 - rust-lang#131916 (small interpreter error cleanup)
 - rust-lang#131919 (zero-sized accesses are fine on null pointers)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 19, 2024
bootstrap: allow setting `--jobs` in config.toml

Allow setting `--jobs` in config.toml's `[build]` section.

```toml
[build]
jobs = 0
```

If this is unset or set to zero in config.toml, we look at `--jobs` flag. If that is also unset, then we fallback to `std::thread::available_parallelism`. If that is not available, then we default to `1`. The flags and `available_parallelism` fallback are already setup, this PR just adds a config.toml option to wire that up.

Closes rust-lang#131836.

r? bootstrap
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 19, 2024
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#127462 (std: uefi: Add basic Env variables)
 - rust-lang#131537 (Fix range misleading field access)
 - rust-lang#131838 (bootstrap: allow setting `--jobs` in config.toml)
 - rust-lang#131871 (x86-32 float return for 'Rust' ABI: treat all float types consistently)
 - rust-lang#131890 (Update `use` keyword docs to describe precise capturing)
 - rust-lang#131899 (Mark unexpected variant res suggestion as having placeholders)
 - rust-lang#131908 (rustdoc: Switch from FxHash to sha256 for static file hashing.)
 - rust-lang#131916 (small interpreter error cleanup)
 - rust-lang#131919 (zero-sized accesses are fine on null pointers)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 19, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#127462 (std: uefi: Add basic Env variables)
 - rust-lang#131537 (Fix range misleading field access)
 - rust-lang#131838 (bootstrap: allow setting `--jobs` in config.toml)
 - rust-lang#131890 (Update `use` keyword docs to describe precise capturing)
 - rust-lang#131899 (Mark unexpected variant res suggestion as having placeholders)
 - rust-lang#131908 (rustdoc: Switch from FxHash to sha256 for static file hashing.)
 - rust-lang#131916 (small interpreter error cleanup)
 - rust-lang#131919 (zero-sized accesses are fine on null pointers)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 21475b7 into rust-lang:master Oct 19, 2024
6 checks passed
@rustbot rustbot added this to the 1.84.0 milestone Oct 19, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Oct 19, 2024
Rollup merge of rust-lang#131838 - jieyouxu:boopjob, r=onur-ozkan

bootstrap: allow setting `--jobs` in config.toml

Allow setting `--jobs` in config.toml's `[build]` section.

```toml
[build]
jobs = 0
```

If this is unset or set to zero in config.toml, we look at `--jobs` flag. If that is also unset, then we fallback to `std::thread::available_parallelism`. If that is not available, then we default to `1`. The flags and `available_parallelism` fallback are already setup, this PR just adds a config.toml option to wire that up.

Closes rust-lang#131836.

r? bootstrap
@jieyouxu jieyouxu deleted the boopjob branch October 21, 2024 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bootstrap feature request: set --jobs in config.toml
5 participants