From 790b98663f1fa668a43115f550f5c66d5c7b156f Mon Sep 17 00:00:00 2001 From: Tyler Nijmeh Date: Mon, 7 Sep 2020 17:43:31 -0700 Subject: [PATCH] Reduce wakeup preemption latencies Signed-off-by: Tyler Nijmeh --- README.md | 4 ++-- system/bin/ktweak | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 42f509d..fc2dab3 100644 --- a/README.md +++ b/README.md @@ -70,8 +70,8 @@ Set the default scheduling period to 5ms. Reduce the maximum scheduling period t ### kernel.sched_min_granularity_ns: 500000 (0.5ms) Set the minimum task scheduling period to 0.5ms. With kernel.sched_latency_ns set to 5ms, this means that 10 active tasks may execute within the 10ms scheduling period before we exceed it. -### kernel.sched_wakeup_granularity_ns: 2500000 (2.5ms) -Require the current task to be surpassing the new task in vmruntime by 2.5ms instead of 1ms before preemption occurs. In testing, `hackbench -pl 8000` times were reduced by ~94% (NOT a typo). This increases wakeup preemption latency slightly but results in more consistent scheduling latency. +### kernel.sched_wakeup_granularity_ns: 1000000 (1ms) +Require tasks to be running for at least 1ms longer than the waiting task before preemption can happen. Reducing this value to 1ms reduces wakeup preemption latencies by up to 50% at a 50th percentile and around 10% for higher percentiles. Hackbench scores suffer if this value is reduced too low. ### kernel.sched_migration_cost_ns: 500000 (0.5ms) --> 1000000 (1ms) Increase the time that a task is considered to be cache hot. According to RedHat, increasing this tunable reduces the number of task migrations. This should reduce time spent balancing tasks and increase per-task performance. diff --git a/system/bin/ktweak b/system/bin/ktweak index 38c7144..6277b60 100644 --- a/system/bin/ktweak +++ b/system/bin/ktweak @@ -112,7 +112,7 @@ write /proc/sys/kernel/sched_child_runs_first 1 write /proc/sys/kernel/sched_tunable_scaling 0 write /proc/sys/kernel/sched_latency_ns 5000000 write /proc/sys/kernel/sched_min_granularity_ns 500000 -write /proc/sys/kernel/sched_wakeup_granularity_ns 2500000 +write /proc/sys/kernel/sched_wakeup_granularity_ns 1000000 write /proc/sys/kernel/sched_migration_cost_ns 1000000 write /proc/sys/kernel/sched_min_task_util_for_colocation 0 write /proc/sys/kernel/sched_nr_migrate 128