Visitar URL original
bootstrap: Make low priority the default by kotauskas · Pull Request #165707 · rust-lang/rust · GitHub
Skip to content

bootstrap: Make low priority the default - #165707

Open
kotauskas wants to merge 3 commits into
rust-lang:mainfrom
kotauskas:low-prio-by-default
Open

kotauskas wants to merge 3 commits into
rust-lang:mainfrom
kotauskas:low-prio-by-default

Conversation

@kotauskas

@kotauskas kotauskas commented Nov 9, 2026 •

Copy link
Copy Markdown

The low-priority option is tucked away so far in bootstrap.example.toml that it's nearly impossible to discover by anyone who doesn't think they're doing anything niche (see #165702). However, it is beneficial to have it enabled on nearly every system, since a build is a CPU-saturating batch job that has no business preempting foreground applications, which predominantly have nice 0. Consider the following three scenarios ensuing from the change from low-priority = "false" to low-priority = "true":

  • There are no processes with non-negligible CPU usage between nice 0 and 10, and bootstrap builds do not get preempted by anything. A system on which this is the case will be unaffected by this change. Examples include CI runners and other build environments with proper build queuing.
  • There are foreground processes between nice 0 and 10 that are relatively light on CPU compared to a bootstrap build and were previously being heavily preempted by bootstrap builds. With this change, a system on which this is the case will see a significant improvement to the latency of interactive programs, enabling the user to comfortably do other things while the build is running without affecting the throughput of the build itself (as the programs are, as established above, light on CPU).
  • There are CPU-intensive but not CPU-saturating foreground processes (games, office and productivity software, Jupyter notebooks, etc.) between nice 0 and 10 that constantly compete with bootstrap builds for CPU time. With this change, a system on which this is the case will see CPU time allocation be biased toward the foreground CPU work at the expense of the build, which is most likely what the user wants, since they wouldn't run CPU-intensive things in the foreground if they didn't want them to have priority over background batch jobs whose completion they are passively waiting for.
  • There are CPU-saturating batch jobs between nice 0 and 10 that constantly compete with bootstrap builds for CPU time, interfering with each other and performing worse than if a batch job queue was in operation and one job ran after the other. With this change, a system on which this is the case will see the bootstrap build receive less CPU time, but the overall sum of batch jobs will complete in approximately the same amount of time regardless, and may even complete sooner due to reduced competition for CPU cache and OS page cache. In any case, this is a misconfigured and a priori suboptimally performing setup, and it will not see good performance unless some form of job queuing is implemented. Admins may implement a low-priority = "false" override as a hacky stopgap if it is desirable for the bootstrap build to engage in disruptive competition for resources and win against some other batch job running in parallel.

Some may wonder why agonizing over this is necessary to begin with if this is such a clear-cut case that operating systems are supposed to deal with automatically. The answer is that the operating systems of today are still not very good at making this sort of scheduling decision in that their capacity to implement such logic automatically is limited and non-robust in unintuitive ways.

For example, the automatic prioritization of foreground programs for scheduling purposes in Windows, known as quantum boosting, can only confer priority boosts to the threads of the process that owns a foreground window, which means that if the graphical application displayed within that window has an IPC dependency on a different process (as is the case with the likes of Jupyter notebooks and even regular web browsers), that dependency will not receive the quantum boost or any other kind of priority increase.

On Linux, meanwhile, no such heuristics exist to begin with (due to graphical applications not holding any special status in the scheduler), and the only mechanism to prevent CPU-intensive and CPU-saturating batch jobs from preempting foreground applications is the emergent heuristic of completely fair scheduling, in which tasks with less total CPU time accrued will have higher priority. This is even more flawed than quantum boosting on Windows, as long-running graphical applications will easily get preempted for long periods of time by the constantly spawning rustc processes of a build that have no history of high CPU usage.

In summary: there are commonly occurring setups on which this change is beneficial, commonly occurring setups on which this change does nothing, and extremely niche and typically broken use cases where this change does something that cannot be conclusively deemed positive or negative.

Large language models were not used in the production of this PR.

@rustbot

rustbot commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

This PR modifies bootstrap.example.toml.

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

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

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

@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 Nov 9, 2026
@rustbot

rustbot commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project has assigned @clubby789 (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks.

Please see the contribution instructions and our LLM policy for more information.

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: bootstrap
  • bootstrap expanded to 6 candidates
  • Random selection from Mark-Simulacrum, clubby789, jieyouxu

@kotauskas

Copy link
Copy Markdown
Author

Change tracker entry probably not necessary, as elaborated above.

@kotauskas

Copy link
Copy Markdown
Author

On second thought, maybe it's worth telling people to get rid of things like alias x="nice ./x" from their setups if they didn't know about this option. I've added a change tracker entry.

@workingjubilee

Copy link
Copy Markdown
Member

I have never once heard of anyone using such an alias.

@bjorn3

bjorn3 commented Nov 9, 2026

Copy link
Copy Markdown
Member

Would it make sense to disable this on the dist profile? Otherwise on systems building multiple packages at the same time we might unnecessarily get slowed down.

@kotauskas

Copy link
Copy Markdown
Author

@bjorn3 Refer to case 4:

With this change, a system on which this is the case will see the bootstrap build receive less CPU time, but the overall sum of batch jobs will complete in approximately the same amount of time regardless, and may even complete sooner due to reduced competition for CPU cache and OS page cache.

"We" might get unnecessarily "slowed down", but that is not a bad thing, unless you are presuming that those running the (as mentioned previously, inefficient and misguided) cross-package-parallel build are measuring the wall time (as opposed to the CPU time) of the Rust build and drawing unsavory conclusions from that. You can't save people with horrible benchmarks from themselves.

@bjorn3

bjorn3 commented Nov 9, 2026

Copy link
Copy Markdown
Member

Increasing wall time means that it takes longer between updating the package definition for rustc and the update actually being available to end users or to build other packages, even if cpu time is identical. And given that rustc already takes a while to build (and is a dependency of other projects that are slow to build, like firefox), making it even longer to build seems bad.

@workingjubilee

Copy link
Copy Markdown
Member

I agree that building packages without handling your own priorities if you care about ordering seems like a "you" problem, but I also agree that there's no reason to have rustc nice its own build when we would, logically, mostly be competing against "peers" of rustc. A dist build should probably avoid trying to take part in prioritization on the assumption that the larger system has handled that.

@kotauskas

Copy link
Copy Markdown
Author

Let's say we have two jobs A and R, where R is the Rust build, being started at the same time, and a job B, which waits for R to finish. Consider the asymptotic starvation behavior: A runs while R gets exactly zero CPU time; R then gets all of the CPU time for itself and completes faster than if it was competing for time (but the wall time will make it look slower, because the timer starts when A and R start, not when A finishes and R begins receiving CPU time). Subsequently, B will get the CPU all to itself, which will only result in CPU sleep compared to equal scheduling if B cannot parallelize. Note that CPU sleeping during execution of B is also possible in the equal scheduling case if A and R complete sooner.

All of this is to say that situations in which rustc being deprioritized could significantly delay the build are very exotic. It would be like trying to rely on pipelining facilitated by build planning when the planning algorithm is "if we can start running a thing, do it".

Although, at the same time, the kinds of workflows that run dist builds often involve nicing the whole build at a higher level (like a renice +10 $$ in a makepkg.conf), so maybe doing deprioritization for dist builds would be unnecessary anyway.

I think I'll special-case dist builds when I get home. I would much prefer if there was some protocol for non-interactive batch job managers to tell their children that they shouldn't auto-prioritize, maybe like a NO_AUTO_PRIO environment variable.

@workingjubilee

Copy link
Copy Markdown
Member

Although, at the same time, the kinds of workflows that run dist builds often involve nicing the whole build at a higher level (like a renice +10 $$ in a makepkg.conf), so maybe doing deprioritization for dist builds would be unnecessary anyway.

Yes, exactly. That "should" be happening, so fiddling with our priority in the dist case seems like it just "gets in the way", even if

I think I'll special-case dist builds when I get home. I would much prefer if there was some protocol for non-interactive batch job managers to tell their children that they shouldn't auto-prioritize, maybe like a NO_AUTO_PRIO environment variable.

in a more perfect world we would have this, yes.

This branch has not been deployed

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

Labels

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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants