]> git.ipfire.org Git - thirdparty/systemd.git/commit
job: make the run queue order deterministic 12639/head
authorMichael Olbrich <m.olbrich@pengutronix.de>
Wed, 22 May 2019 10:12:17 +0000 (12:12 +0200)
committerMichael Olbrich <m.olbrich@pengutronix.de>
Thu, 18 Jul 2019 08:28:39 +0000 (10:28 +0200)
commitda8e178296f8a34f4156f1e10b8a313de8efee7c
treeadc765a31ad324b04810d3cccccb1e522eba9729
parentfcfc7e11370f3c0f9f50f6f046b44f7543cf3397
job: make the run queue order deterministic

Jobs are added to the run queue in random order. This happens because most
jobs are added by iterating over the transaction or dependency hash maps.

As a result, jobs that can be executed at the same time are started in a
different order each time.
On small embedded devices this can cause a measurable jitter for the point
in time when a job starts (~100ms jitter for 10 units that are started in
random order).
This results is a similar jitter for the boot time. This is undesirable in
general and make optimizing the boot time a lot harder.
Also, jobs that should have a higher priority because the unit has a higher
CPU weight might get executed later than others.

Fix this by turning the job run_queue into a Prioq and sort by the
following criteria (use the next if the values are equal):
- CPU weight
- nice level
- unit type
- unit name

The last one is just there for deterministic sorting to avoid any jitter.
src/core/cgroup.c
src/core/cgroup.h
src/core/job.c
src/core/job.h
src/core/manager.c
src/core/manager.h