chiark / gitweb /
event: add timer accuracy/coalescing logic
authorLennart Poettering <lennart@poettering.net>
Thu, 10 Oct 2013 19:16:21 +0000 (21:16 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 10 Oct 2013 19:22:59 +0000 (21:22 +0200)
commitc2ba3ad6604ef2e189d7e0a36d6911116e84d3ab
tree195bd9feba12c118a6b35fc5aa4710e681d757b2
parent5a045dad1c5adf17d9198b15d085c9425c1dae8e
event: add timer accuracy/coalescing logic

In order to improve energy consumption we should minimize our wake-ups
when handling timers.  Hence, for each timer take an accuracy value and
schedule the actual wake-up time somewhere between the specified time
and the specified timer plus the accuracy.

The specified time of timer event sources hence becomes the time the
handler is called the *earliest*, and the specified time plus the accuracy
the time by which it is called the *latest*, leaving the library the
freedom to schedule the wake-up somewhere inbetween.

If the accuracy is specified as 0 the default of 250ms will be used.

When scheduling timeouts we will now try to elapse them at the same
point within each second, across the entire system. We do this by using
a fixed perturbation value keyed off the boot id. If this point within a
second is not in the acceptable range, we try again with a fixed time
within each 250ms time step. If that doesn't work either, we wake up at
the last possible time.
src/libsystemd-bus/sd-event.c
src/libsystemd-bus/test-event.c
src/shared/prioq.c
src/systemd/sd-event.h