From ec92c35ddafb14a156c145741cb6576319d6bbef Mon Sep 17 00:00:00 2001 From: tytydraco Date: Sun, 22 Nov 2020 09:57:44 -0800 Subject: [PATCH] Migrate for throughput Signed-off-by: tytydraco --- ktweak | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/ktweak b/ktweak index 465ad69..6312b7e 100644 --- a/ktweak +++ b/ktweak @@ -1,14 +1,17 @@ #!/usr/bin/env bash # Written by Draco (tytydraco @ GitHub) +# The name of the current branch for logging purposes +BRANCH="throughput" + # Maximum unsigned integer size in C UINT_MAX="4294967295" # Duration in nanoseconds of one scheduling period -SCHED_PERIOD="$((1 * 1000 * 1000))" +SCHED_PERIOD="$((10 * 1000 * 1000))" # How many tasks should we have at a maximum in one scheduling period -SCHED_TASKS="8" +SCHED_TASKS="6" write() { # Bail out if file does not exist @@ -40,19 +43,19 @@ grep -q android /proc/cmdline && ANDROID=true # Log the date and time for records sake echo "Time of execution: $(date)" -echo "Branch: dev" +echo "Branch: $BRANCH" # Sync to data in the rare case a device crashes sync # Limit max perf event processing time to this much CPU usage -write /proc/sys/kernel/perf_cpu_time_max_percent 5 +write /proc/sys/kernel/perf_cpu_time_max_percent 20 -# Group tasks for less stutter but less throughput -write /proc/sys/kernel/sched_autogroup_enabled 1 +# Sacrifice latency for throughput when grouping tasks +write /proc/sys/kernel/sched_autogroup_enabled 0 -# Execute child process before parent after fork -write /proc/sys/kernel/sched_child_runs_first 1 +# Process child-parent forks naturally +write /proc/sys/kernel/sched_child_runs_first 0 # Preliminary requirement for the following values write /proc/sys/kernel/sched_tunable_scaling 0 @@ -73,7 +76,7 @@ write /proc/sys/kernel/sched_migration_cost_ns 5000000 [[ "$ANDROID" == true ]] && write /proc/sys/kernel/sched_min_task_util_for_colocation 0 # Improve real time latencies by reducing the scheduler migration time -write /proc/sys/kernel/sched_nr_migrate 8 +write /proc/sys/kernel/sched_nr_migrate 128 # Disable scheduler statistics to reduce overhead write /proc/sys/kernel/sched_schedstats 0 @@ -82,7 +85,7 @@ write /proc/sys/kernel/sched_schedstats 0 write /proc/sys/kernel/printk_devkmsg off # Start non-blocking writeback later -write /proc/sys/vm/dirty_background_ratio 10 +write /proc/sys/vm/dirty_background_ratio 15 # Start blocking writeback later write /proc/sys/vm/dirty_ratio 30 @@ -102,8 +105,8 @@ write /proc/sys/vm/stat_interval 10 # Swap to the swap device at a fair rate write /proc/sys/vm/swappiness 100 -# Prioritize page cache over simple file structure nodes -write /proc/sys/vm/vfs_cache_pressure 200 +# Allow inodes and dentries to build up a larger cache +write /proc/sys/vm/vfs_cache_pressure 80 # Enable Explicit Congestion Control write /proc/sys/net/ipv4/tcp_ecn 1 @@ -125,8 +128,8 @@ fi [[ "$ANDROID" == true ]] && if [[ -d "/dev/stune/" ]] then - # Prefer to schedule top-app tasks on idle CPUs - write /dev/stune/top-app/schedtune.prefer_idle 1 + # We are not concerned with prioritizing latency + write /dev/stune/top-app/schedtune.prefer_idle 0 # Mark top-app as boosted, find high-performing CPUs write /dev/stune/top-app/schedtune.boost 1 @@ -159,7 +162,7 @@ do write "$governor/rate_limit_us" "$((SCHED_PERIOD / 1000))" # Jump to hispeed frequency at this load percentage - write "$governor/hispeed_load" 90 + write "$governor/hispeed_load" 85 write "$governor/hispeed_freq" "$UINT_MAX" done @@ -171,7 +174,7 @@ do write "$governor/min_sample_time" "$((SCHED_PERIOD / 1000))" # Jump to hispeed frequency at this load percentage - write "$governor/go_hispeed_load" 90 + write "$governor/go_hispeed_load" 85 write "$governor/hispeed_freq" "$UINT_MAX" done @@ -194,11 +197,11 @@ do # Disable I/O statistics accounting write "$queue/iostats" 0 - # Reduce heuristic read-ahead in exchange for I/O latency - write "$queue/read_ahead_kb" 128 + # Sacrifice I/O and memory efficiency for a possible throughput gain + write "$queue/read_ahead_kb" 256 - # Reduce the maximum number of I/O requests in exchange for latency - write "$queue/nr_requests" 64 + # Buffer more requests at once + write "$queue/nr_requests" 512 done # Always return success, even if the last write fails