The CacULE CPU scheduler is based on interactivity score mechanism. The interactivity score is inspired by the ULE scheduler (FreeBSD scheduler).
The CacULE CPU scheduler is a CFS patchset that is based on interactivity score mechanism. The interactivity score is inspired by the ULE scheduler (FreeBSD scheduler). The goal of this patch is to enhance system responsiveness/latency.
The interactivity score is inspired by the ULE scheduler (FreeBSD scheduler). For more information see: https://web.cs.ucdavis.edu/~roper/ecs150/ULE.pdf CacULE doesn't replace CFS with ULE, it only changes the CFS' pick next task mechanism to ULE's interactivity score mechanism for picking next task to run.
Sets the value m for interactivity score calculations. See Figure 1 in https://web.cs.ucdavis.edu/~roper/ecs150/ULE.pdf The default value of in CacULE is 32768 which means that the Maximum Interactive Score is 65536 (since m = Maximum Interactive Score / 2). You can tune schedinteractivityfactor with sysctl command:
This command changes the schedinteractivityfactor from 32768 to 50.
Instead of calculating a task IS value for infinite life time, we use
sched_max_lifetime_mswhich is 22s by default. Task's
vruntimeshrink whenever a task life time exceeds 30s. Therefore, the rate of change of IS for old and new tasks is normalized. The value
sched_max_lifetimecan be changed at run time by the following sysctl command:
sysctl kernel.sched_max_lifetime_ms=60000The value is in milliseconds, the above command changes
sched_max_lifetimefrom 22s to 60s.
In the first round, when the task's life time became > 22s, the
cacule_start_timeget reset to be (
current_time - 11s), then, the task will keep resetting every 15s.
n is the number of tasks in a runqueue (each CPU has its own runqueue).
Note: O(n) sounds scary, but usually for a machine with 4 CPUS where it is used for desktop or mobile jobs, the maximum number of runnable tasks might not exceeds 10 (at the pick next run time) - the idle tasks are excluded since they are dequeued when sleeping and enqueued when they wake up.
The priorities are applied as the followings: The
vruntimeis used in Interactivity Score as the sum of execution time. The
vruntimeis adjusted by CFS based on tasks priorities. The same code from CFS is used in CacULE. The
vruntimeis equal to
sum_exec_runtimeif a task has nice value of 0 (normal priority). The
vruntimewill be lower than
sum_exec_runtimefor higher tasks priorities, which make Interactivity Score thinks that those task didn't run for much time (compared to their actual run time). The
vruntimewill be higher than
sum_exec_runtimefor lower tasks priorities, which make Interactivity Score thinks that those task ran for much time (compared to their actual run time). So priorities are already taken in the acount by using
vruntimein the Interactivity Score equation instead of actual
This is an experimental load balancer for Cachy/CacULE. It is a lightweight load balancer which is a replacement of CFS load balancer. It migrates tasks based on their HRRN/Interactivity Scores (IS). Most of CFS load balancing-related updates (cfs and se updates loads) are removed. The RDB balancer follows CFS paradigm in which RDB balancing happen at the same points CFS does. RDB balancing happens in three functions:
newidle_balanceis called exactly at the same time as CFS did (when pick next task fails to find any task to run). The RDB
newidle_balancepulls one task that is the highest HRRN/IS from any CPU. The RDB
idle_balanceis called in
trigger_load_balancewhen CPU is idle, it does the same as
newidle_balancebut with slight changes since
newidle_balanceis a special case. The RDB
active_balancechecks if the current (NORMAL) runqueue has one task, if so, it pulls the highest of the highest HRRN/IS among all other CPUS. If the runqueue has more than one task, then it pulls any highest HRRN/IS (same as idle does). A CPU cannot pull a task from another CPU that has fewer tasks (when pull any). For the all three balancing
active_balance, the cpu first tries to pull from a CPU that shares the same cache (
cpus_share_cache). If can't pull any then it tries to pull from any CPU even though they are not in the same core. Only when pulling the highest of the highest HRRN/IS (i.e.
active_balancewhen CPU has one task), there is no check for shared cache.
The following installation links are not only for easier installation, but they are also right configured for best CacULE experience.
cachy / cacule(i.e
To confirm that CacULE is currently running: ```
dmesg | grep -i "cacule cpu" [ 0.122999] CacULE CPU scheduler v5.9 by Hamad Al Marri.
## Suggested Configs For a helper script to auto config use [this](https://github.com/hamadmarri/cacule-cpu-scheduler/blob/master/scripts/apply_suggested_configs.sh)
The tests are ran 11 times and best 10 tests are picked. Between each test, a sleep for 2 minutes such the following script:
for i in (seq 1 11); sleep 2m; ; end ```
For the following tests, CacULE is patched on Ubuntu linux-lowlatency kernel source.
Please see the scripts for responsiveness/latency tests: os-scheduler-responsiveness-test
I made comparison between cfs and cachy on xanmod, for blind test
to reveal the which is which go back to time 0s on the video and see
Note: In one of the tests, the recorder seems to be freezes and lagging, I repeated this test twice, while testing system is not pausing but the recorder maybe freezing or lagging while recording.