summaryrefslogtreecommitdiff
path: root/src/core/cgroup.h
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2019-05-22 12:12:17 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2019-07-18 10:28:39 +0200
commitda8e178296f8a34f4156f1e10b8a313de8efee7c (patch)
treeadc765a31ad324b04810d3cccccb1e522eba9729 /src/core/cgroup.h
parentfcfc7e11370f3c0f9f50f6f046b44f7543cf3397 (diff)
downloadsystemd-da8e178296f8a34f4156f1e10b8a313de8efee7c.tar.gz
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.
Diffstat (limited to 'src/core/cgroup.h')
-rw-r--r--src/core/cgroup.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/core/cgroup.h b/src/core/cgroup.h
index d1537c503e..d8ec070623 100644
--- a/src/core/cgroup.h
+++ b/src/core/cgroup.h
@@ -252,3 +252,5 @@ const char* cgroup_device_policy_to_string(CGroupDevicePolicy i) _const_;
CGroupDevicePolicy cgroup_device_policy_from_string(const char *s) _pure_;
bool unit_cgroup_delegate(Unit *u);
+
+int compare_job_priority(const void *a, const void *b);