Merge branch 'master' into dev

latency
tytydraco 4 years ago
commit c63c1d5355

@ -1,6 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Written by Draco (tytydraco @ GitHub) # Written by Draco (tytydraco @ GitHub)
# Maximum unsigned integer size in C
UINT_MAX="4294967295"
write() { write() {
# Bail out if file does not exist # Bail out if file does not exist
[[ ! -f "$1" ]] && return 1 [[ ! -f "$1" ]] && return 1
@ -128,63 +131,80 @@ then
write /dev/stune/top-app/schedtune.prefer_idle 1 write /dev/stune/top-app/schedtune.prefer_idle 1
fi fi
for cpu in /sys/devices/system/cpu/cpu*/cpufreq/ # Loop over each CPU in the system
for cpu in /sys/devices/system/cpu/cpu*/cpufreq
do do
avail_govs="$(cat "${cpu}scaling_available_governors")" # Fetch the available governors from the CPU
case "$avail_govs" in avail_govs="$(cat "$cpu/scaling_available_governors")"
*schedutil*)
write "${cpu}scaling_governor" schedutil # Stretch CPU bounds
write "$cpu/scaling_max_freq" "$(cat "$cpu/cpuinfo_max_freq")"
# Consider changing frequencies once per scheduling period write "$cpu/scaling_min_freq" "$(cat "$cpu/cpuinfo_min_freq")"
write "${cpu}schedutil/up_rate_limit_us" 5000
write "${cpu}schedutil/down_rate_limit_us" 5000 # Attempt to set the governor in this order
write "${cpu}schedutil/rate_limit_us" 5000 for governor in schedutil interactive
do
# Jump to max frequency at 90% load # Once a matching governor is found, set it and break for this CPU
write "${cpu}schedutil/hispeed_load" 90 if [[ "$avail_govs" == *"$governor"* ]]
write "${cpu}schedutil/hispeed_freq" "$(cat "${cpu}cpuinfo_max_freq")" then
;; write "$cpu/scaling_governor" "$governor"
*interactive*) break
write "${cpu}scaling_governor" interactive fi
done
# Consider changing frequencies once per scheduling period done
write "${cpu}interactive/timer_rate" 5000
write "${cpu}interactive/min_sample_time" 5000 # Apply governor specific tunables for schedutil
find /sys/devices/system/cpu/ -name schedutil -type d | while IFS= read -r governor
# Jump to max frequency at 90% load do
write "${cpu}interactive/go_hispeed_load" 90 # Consider changing frequencies once per scheduling period
write "${cpu}interactive/hispeed_freq" "$(cat "${cpu}cpuinfo_max_freq")" write "$governor/up_rate_limit_us" 5000
;; write "$governor/down_rate_limit_us" 5000
esac write "$governor/rate_limit_us" 5000
# Jump to max frequency at 90% load
write "$governor/hispeed_load" 90
write "$governor/hispeed_freq" "$UINT_MAX"
done
# Apply governor specific tunables for interactive
find /sys/devices/system/cpu/ -name interactive -type d | while IFS= read -r governor
do
# Consider changing frequencies once per scheduling period
write "$governor/timer_rate" 5000
write "$governor/min_sample_time" 5000
# Jump to max frequency at 90% load
write "$governor/go_hispeed_load" 90
write "$governor/hispeed_freq" "$UINT_MAX"
done done
for queue in /sys/block/*/queue/ for queue in /sys/block/*/queue
do do
# Choose the first governor available # Choose the first governor available
avail_scheds="$(cat "${queue}scheduler")" avail_scheds="$(cat "$queue/scheduler")"
for sched in cfq noop kyber bfq mq-deadline none for sched in cfq noop kyber bfq mq-deadline none
do do
if [[ "$avail_scheds" == *"$sched"* ]] if [[ "$avail_scheds" == *"$sched"* ]]
then then
write "${queue}scheduler" "$sched" write "$queue/scheduler" "$sched"
break break
fi fi
done done
# Do not use I/O as a source of randomness # Do not use I/O as a source of randomness
write "${queue}add_random" 0 write "$queue/add_random" 0
# Disable I/O statistics accounting # Disable I/O statistics accounting
write "${queue}iostats" 0 write "$queue/iostats" 0
# Only attempt simple merges # Only attempt simple merges
write "${queue}nomerges" 1 write "$queue/nomerges" 1
# Reduce heuristic read-ahead in exchange for I/O latency # Reduce heuristic read-ahead in exchange for I/O latency
write "${queue}read_ahead_kb" 16 write "$queue/read_ahead_kb" 16
# Reduce the maximum number of I/O requests in exchange for latency # Reduce the maximum number of I/O requests in exchange for latency
write "${queue}nr_requests" 64 write "$queue/nr_requests" 64
done done
# Always return success, even if the last write fails # Always return success, even if the last write fails

Loading…
Cancel
Save