[systemd-devel] How to schedule a resource consuming service
Lennart Poettering
lennart at poettering.net
Mon Feb 4 12:03:57 UTC 2019
On Sa, 02.02.19 14:50, Fabrice Salvaire (fabrice.salvaire at orange.fr) wrote:
> This is painful when we want to use the machine asap, for a quite full 500
> GB disk, it hangs during several minutes. I encountered an unusable machine
> during more than 10 min due to mlocate and/or gnome indexer saturating IO
> and package cache update saturating a low ADSL connexion.
>
> I noticed IOSchedulingClass=2 could be set to "idle", maybe it would
> improve.
Setting IOSchedulingClass to 2 is equal to "best-effort", which is
actually the Linux default.
Setting to "idle" might work, but I am not sure it's really the ideal
approach either, as it means that this service could be starved out
entirely until all eternity if something else wants IO
constantly. Usually it's better and sufficient to just set the Nice=
level to something really high, as that propagates to both the CPU and
IO schedulers, and means that everything else will be scheduled
preferably, but your service will still get a bit of CPU/IO time every
now and then so that it doesn't starve to death. (that said, playing
around with "idle" might definitely be worth the excercise)
Quite frankly, if Nice=19 is not sufficient for your usecase, and this
still affects behaviour of your system too badly, then this indicates
that the IO scheduler on selected on your system isn't any good or the
hw really limited?
If nicing some IO heavy job to 19 still affects everything else so
badly, then ultimately I figure this becomes a question for the kernel
IO folks. systemd after all can only tell the kernel at what priority
to schedule something, how things are actually scheduled is done by
the kernel itself.
> I also read
> https://www.freedesktop.org/software/systemd/man/systemd.timer.html but I
> don't understand if there is a way to prevent to run the service during 1h
> after boot.
There's currently no concept of defining "negative" timers, i.e. to
first say "run this so and so often", but then say "but not at these
times". It might be worth adding that, but this would require a bit of
work, and I am not sure how the syntax could look like...
> Well a way to run theses services during idle time.
We have no concept for that. The assumption so far that the Linux IO
scheduler is good enough so that we don't have to second guess it, and
it knows on its own when it's a good time to schedule a process as
long as we tell it a useful priority...
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list