[systemd-devel] How to use cgroups for Tracker?
David Timothy Strauss
david at davidstrauss.net
Wed Oct 15 08:01:05 PDT 2014
I'm responding here only to the systemd list.
On Tue, Oct 14, 2014 at 4:35 PM, Martyn Russell <martyn at lanedo.com> wrote:
> Another option would be to use systemd. However, I am mindful that it's not
> available everywhere just yet (but soon will be I hear) I am also aware, I
> might get a biased answer here :)
systemd probably won't ever be available everywhere, if you define
everywhere to be any machine running the Linux kernel. But, that's
true of many extremely common tools we've come to rely on, including
the GNU userland. I think systemd is a reasonable dependency for tools
like Tracker that target desktop Linux.
> Does anyone have any suggestions or projects that lead by example that
> Tracker could/should follow?
Your case with the out-of-control plugins is hard, but I think a
simple hard limit on memory is the wrong answer (as the bug
demonstrates). With cgroups, you can register handlers for memory
pressure to elegantly handle shutting down or unloading plugins. You
can also query the memory usage "charged" to a cgroup to determine
when things are getting out of control. While cgroups can also set
memory limits where the processes will swap when allocation exceeds a
specified limit, you may find that creates an even more undesirable
load on I/O.
It is easier to throttle CPU or I/O as prevention against running
wild. For those, I recommend reading what systemd offers for
cgroups-cased resource management [1]. Those controls may be overkill,
though, if you don't care about starvation, so please consider my
answer to your next question, too.
> Orthogonal to all of this, is another idea I had, which is to completely
> pause Tracker when the user is present (keyboard/mouse use) to avoid wasting
> cycles on stuff the user doesn't care about - a bit like how chat clients
> know when you're away or not. Maybe we should do both?
The user being active doesn't mean substantial load is on the system.
Plus, users might get annoyed that changes they're making aren't
getting indexed. If you're okay with the Tracker getting starved --
and you seem to be given the thought of stopping it when a user is
active -- I would have the Tracker run with IOSchedulingClass=idle and
Nice=19 [2], which aren't options exclusive to systemd in any way.
[1] http://www.freedesktop.org/software/systemd/man/systemd.resource-control.html
[2] http://www.freedesktop.org/software/systemd/man/systemd.exec.html
More information about the systemd-devel
mailing list