[systemd-devel] [EXT] Re: Re: Understanding the effect of AccuracySec=

Windl, Ulrich u.windl at ukr.de
Mon Aug 19 12:15:50 UTC 2024


Thanks to everyone sharing information. Basically that’s what I expected, too, except this:
I run about 10 instances of the timer, and all 10 instances are started at the same second. My initial expectation wad that systemd might spread the instances in the 6 hour windows somehow.
Maybe starting the next instance once the previous instance had finished.
I’m somewhat unsure about the energy saving: Will 10 jobs run simultaneously consume less power than the 10 jobs run sequentially? My guess is that the timer overhead may be negligible.

Regards,
Ulrich

From: Adrian Vovk <adrianvovk at gmail.com>
Sent: Monday, August 19, 2024 10:45 AM
To: Andrei Borzenkov <arvidjaar at gmail.com>
Cc: Barry <barry at barrys-emacs.org>; Windl, Ulrich <u.windl at ukr.de>; Systemd Devel <systemd-devel at lists.freedesktop.org>
Subject: [EXT] Re: [systemd-devel] Re: Understanding the effect of AccuracySec=


I don't have the initial email for some reason (got caught in spam filter? Idk) so I don't have the full context.
On Mon, Aug 19, 2024, 03:55 Andrei Borzenkov <arvidjaar at gmail.com<mailto:arvidjaar at gmail.com>> wrote:
On Mon, Aug 19, 2024 at 10:11 AM Barry <barry at barrys-emacs.org<mailto:barry at barrys-emacs.org>> wrote:
>
>
>
> On 19 Aug 2024, at 06:55, Windl, Ulrich <u.windl at ukr.de<mailto:u.windl at ukr.de>> wrote:
>
>
> Despite of the fact that my version of systemd does not know that setting, can you explain what the effect of AccuracySec= really is?
>
>
> The docs https://www.man7.org/linux/man-pages/man5/systemd.timer.5.html say this
>
>  Note that this setting is primarily a power saving option
>            that allows coalescing CPU wake-ups. It should not be
>            confused with RandomizedDelaySec= (see below) which adds a
>            random value to the time the timer shall elapse next and
>            whose purpose is the opposite: to stretch elapsing of timer
>            events over a longer period to reduce workload spikes. For
>            further details and explanations and how both settings play
>            together, see below.
>
> So if you have 5 timers that expire about the same time this allows them to all run at the sane time thus saving power.

It does explain why timers are run at the same time. It does not
explain why "daily" + accuracy 6h runs at midnight, not close to 6am

When your timer is scheduled for 00:00 but accuracy is 6h, then systemd will try to fire the timer at 00:00 but is allowed to be up to 6 hours "late" to save power. So the timer will fire at any time between 00:00 and 06:00.

Let's say you have another timer set to fire at 01:00 + 6hr accuracy. systemd will likely fire both timers at around 01:00. The first timer is allowed to start anywhere between 00:00 and 06:00 and the second between 01:00 and 07:00. These ranges intersect from 01:00 to 06:00, so systemd will fire both timers at some point in that range. It's free to pick exactly when and I'm not looking at the code, but I wouldn't be surprised if it'll pick a time closer to 01:00 to minimize the amount of time it's "late".

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20240819/80d5c97c/attachment.htm>


More information about the systemd-devel mailing list