diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2019-05-22 12:12:17 +0200 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2019-07-18 10:28:39 +0200 |
commit | da8e178296f8a34f4156f1e10b8a313de8efee7c (patch) | |
tree | adc765a31ad324b04810d3cccccb1e522eba9729 /src/core/job.h | |
parent | fcfc7e11370f3c0f9f50f6f046b44f7543cf3397 (diff) | |
download | systemd-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/job.h')
-rw-r--r-- | src/core/job.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/core/job.h b/src/core/job.h index a5f966ee03..0781328a56 100644 --- a/src/core/job.h +++ b/src/core/job.h @@ -115,7 +115,6 @@ struct Job { Unit *unit; LIST_FIELDS(Job, transaction); - LIST_FIELDS(Job, run_queue); LIST_FIELDS(Job, dbus_queue); LIST_FIELDS(Job, gc_queue); @@ -147,6 +146,8 @@ struct Job { JobResult result; + unsigned run_queue_idx; + bool installed:1; bool in_run_queue:1; bool matters_to_anchor:1; |