pop-os / system76-scheduler

Auto-configure CFS and process priorities for improved desktop responsiveness
Mozilla Public License 2.0
545 stars 33 forks source link

Feature Request: Systemd services that have a `Nice=` value given explicitly should not be touched by default background priority adjustments #54

Open techsy730 opened 2 years ago

techsy730 commented 2 years ago

SystemD allows configuration of services with a Nice property. Which, to little surprise, adjusts the process(es) niceness on launch.

For services that have such a Nice= explicitly given, system76-scheduler shouldn't subject them to the default background priority adjustments. Since in that case the service probably is lower or higher priority for good reason.

(I'm classifying this as a feature request, not a bug, due to the sheer scope of work needed just to "fix" this bug)

For a bit more nuance, we could have

IMO, per-process assignments in assignments should override systemd configured niceness by default. Maybe introduce a new config option (false by default) to have systemd managed services still take priority over process assignments.

I don't know of a current (efficient) way to tell the difference between an explicitly set Nice=0 vs the Nice=0 coming from the default of that property (either case shows Nice=0) I'd be fine with treating Nice=0 the same as unset though.

There is a libsystemd crate you can probably use to avoid the pitfalls of parsing command line output.

(If you ever want support for other distros that don't mandate SystemD init, you will probably want to introduce a build configuration option to build without systemd support)

techsy730 commented 2 years ago

For "extra credit", also reading the per-user systemd sessions would be nice. But it is kind of tricky to connect to a different user's systemd session.