Skip to content

Be ionice on unix #5569

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

Open
richard-uk1 opened this issue May 25, 2018 · 9 comments
Open

Be ionice on unix #5569

richard-uk1 opened this issue May 25, 2018 · 9 comments
Labels
A-build-execution Area: anything dealing with executing the compiler A-documenting-cargo-itself Area: Cargo's documentation C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.

Comments

@richard-uk1
Copy link
Contributor

richard-uk1 commented May 25, 2018

When building on unix, I don't think there would be any harm setting the i/o nice value, and it may improve UX in some circumstances. From rustc-perf#232.

Edit The original post meant specifically the i/o scheduling nice, not the general process nice.

@alexcrichton alexcrichton added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label May 25, 2018
@richard-uk1
Copy link
Contributor Author

I'm happy to implement this, just want to see if there were any reasons it isn't a good idea first.

@alexcrichton
Copy link
Member

I don't think that we'll want this to be the default because it runs the risk of making builds slower by default, but having it as a configuration option seems reasonable

@lukaslueg
Copy link
Contributor

This should at least be behind a config-option so the default behavior remains the expected behavior, which is niceness 0. At least on Linux, you are always able to automatically move cargo into its own control group and set its CPU-, RAM-, and IO-priority. Sure it's more complicated and not built-in, yet there is a strong case to be made that cargo is first and foremost a process like any other; and the cgroup-solution is strictly more powerful & beyond reach by cargo.

@matklad
Copy link
Member

matklad commented May 29, 2018

At least on Linux, you are always able to automatically move cargo into its own control group and set its CPU-, RAM-, and IO-priorit

Interesting! Perhaps we should add instructions of how to do that to Cargo docs? I feel that "I run cargo build on my dev laptop while also using a browser and IDE" is a common use-case, so many people might want to reduce Cargo's priority, even if they don't realize that it is possible.

@richard-uk1
Copy link
Contributor Author

richard-uk1 commented May 29, 2018 via email

@lukaslueg
Copy link
Contributor

@matklad, let me actually check on it. There once was a control-groups management daemon which by now seems to have been replaced by systemd, which itself lacks the feature.

@hammerandtongs
Copy link

@derekdreery

I'm the linked post from that thread.

Just to be clear I said IONICE

"""ionice - set or get process I/O scheduling class and priority"""

This is much more effective for me with less negative impact on the build.

Linux desktop io scheduling needs a bit more help then process scheduling but ymmv.

@richard-uk1 richard-uk1 changed the title Be nice on unix Be ionice on unix May 30, 2018
@richard-uk1
Copy link
Contributor Author

@hammerandtongs Updated.

@lukaslueg
Copy link
Contributor

lukaslueg commented Nov 5, 2018

I've looked into this again and it seems that the daemon to place processes into control groups automatically has been deprecated without being replaced. The way to go seems to be using systemd-run to create a transient, resource-constrained scope and spawn cargo within. For example

systemd-run --scope --slice=user.slice -p IOAccounting=true -p IOAccounting=true -p CPUWeight=1 -p IOWeight=1 cargo test

This creates a new scope under user.slice with minimal IO- and CPU-weights. That is, the user-1000-slice (or whatever your "real" users runs under) and all its processes will completely dominate the cargo-process for resources.

Relevant documentation for systemd-run and systemd.resource-control.

@epage epage added A-documenting-cargo-itself Area: Cargo's documentation A-build-execution Area: anything dealing with executing the compiler S-triage Status: This issue is waiting on initial triage. labels Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build-execution Area: anything dealing with executing the compiler A-documenting-cargo-itself Area: Cargo's documentation C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

6 participants