Hi Lennart, thanks for your answer! Please, see some more questions below.
On Wed, May 3, 2017 at 11:54 PM, Lennart Poettering <[email protected]> wrote: > On Wed, 03.05.17 18:02, Boris Dolgov ([email protected]) wrote: > >> Hello! >> >> I am using systemd and repeatedly need to do the following: >> - Start a process with memory limit and cpu affinity; >> - Be notified when it and all its children are finished (typically in >> 0.01-1 second); >> - Get cpu and memory usage statistics. >> >> Cgroups look perfect for me, but what is the best way of managing them? >> >> As far as I understand, ControlGroupInterface article advises to >> create a transient scope unit for each process I run, but I need to >> preserve cpu accounting information, so scope units will not work. > > They will. Just make sure to use a recent systemd version that > provides you with the Ref/Unref() bus calls, which permits you to ref > specific units, so that you can read statistics off them. Looks like Fedora 26 has these calls, that's nice. >> Alternatively, I could create service units, but I am concerned with >> performance issues and would like to create processes by myself. >> >> Are any lower-level APIs available and advised to use? >> For example, I'd be happy to create a slice using systemd, create its >> subtrees manually and manage them myself, but the aforementioned >> article does not recommend it. > > It should be sufficient to use scopes with Ref/Unref and the CPUShares > setting. > > However, the cpuset controller is still not exposed in systemd, for > the reason that its semantics are really really broken, still. We'll > add support as soon as that is cleaned up in the kernel. > > However, given that the per-process CPU affinitty stuff exposed by > libc is usually enough this should not be a big limitation. Yes, looks like sched_setaffinity is enough for me. But I am still concerned with performance issues for a lot of short-lived processes. I've tried to run the following program: https://gist.github.com/bdolgov/539214149042830318e0f8e5073ea274 With CMD=nosd_cmd it does 200 runs per second, but with CMD=sd_cmd, it does only 120 runs per second. It looks like a 40% slowdown, which is not very good for me. Thanks, Boris. _______________________________________________ systemd-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/systemd-devel
