https://pantsbuild.org/ logo
#general
Title
# general
f

flat-zoo-31952

02/03/2022, 10:39 PM
Probably a stupid question, but is there a good reliable way to run pants commands with nice? I guess once pantsd is started you have to renice it, but you also never know when pantsd will need to be restarted, so you'd have to nice the invocation of
./pants
too? Like this:
Copy code
renice 19 $(cat .pids/**/pid)
nice ./pants ...
Does this make sense or am I thinking about this all wrong?
just realized that i really like typing
nice ./pants
๐Ÿ˜‚
๐Ÿ’ฏ 1
๐Ÿ˜‚ 1
f

fast-nail-55400

02/03/2022, 10:45 PM
Would you want all invoked subprocesses to also be `nice`โ€™d?
f

flat-zoo-31952

02/03/2022, 10:49 PM
yeah that's actually what I want niced
i don't think pants/pantsd uses that much CPU, it's the stuff it spawns
w

witty-crayon-22786

02/03/2022, 10:56 PM
thatโ€™s charitable ๐Ÿ˜‰
it looks like we could probably do this programmatically based on a setting with setpriority (linux / macOS)
f

flat-zoo-31952

02/04/2022, 2:56 PM
That would be useful in the future
I'm not really using pants as a runner for the moment (just a tool for calculating targets affected by changes), but I will be moving in that direction, and this could be helpful
f

fast-nail-55400

02/04/2022, 3:32 PM
also this is a relatively easy change to make to Pants especially for a new contributor. Define an option (e.g.,
--subprocess-environment-priority=...
), thread it through into the local execution runner in Rust (there are several PRs that serve as examples), and then invoke the correct API from the libc crate to set the nice value (probably using https://doc.rust-lang.org/std/os/unix/process/trait.CommandExt.html#tymethod.pre_exec on the
Command
and
setpriority
https://docs.rs/libc/0.2.117/libc/fn.setpriority.html)
๐Ÿค” 1
2 Views