[systemd-devel] [EXT] Re: Understanding the effect of AccuracySec=
Adrian Vovk
adrianvovk at gmail.com
Mon Aug 19 08:44:52 UTC 2024
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> wrote:
> On Mon, Aug 19, 2024 at 10:11 AM Barry <barry at barrys-emacs.org> wrote:
> >
> >
> >
> > On 19 Aug 2024, at 06:55, Windl, Ulrich <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/8e4ad216/attachment-0001.htm>
More information about the systemd-devel
mailing list