View previous topic :: View next topic |
Author |
Message |
kernelOfTruth Watchman
Joined: 20 Dec 2005 Posts: 6111 Location: Vienna, Austria; Germany; hello world :)
|
Posted: Fri Jul 10, 2015 8:26 pm Post subject: Realtime & Low-latency scheduling (Gaming, Pro-Audio, et |
|
|
Hi guys,
[WIP]
This is mainly a stub for now and is mostly tailored towards CFS
here's a incomplete list of settings to set up to get a nice low-latency response from your system.
The intention to get this kind of behavior can be to do Gaming on Linux - either native (e.g. via Steam) or WINE (e.g. Crysis, Mass Effect 3 [with or without MultiPlayer], etc.)
or tasks that require that the system is processing load in a deadline-like fashion.
kernel-related settings:
run the kernel with
threadirqs
appended to your bootloader
For CFS (classical, vanilla) CPU scheduler
Code: | zgrep GROUP /proc/config.gz
CONFIG_CGROUPS=y
CONFIG_CGROUP_DEBUG=y
CONFIG_CGROUP_FREEZER=y
# CONFIG_CGROUP_DEVICE is not set
CONFIG_CGROUP_CPUACCT=y
# CONFIG_CGROUP_HUGETLB is not set
CONFIG_CGROUP_PERF=y
CONFIG_CGROUP_SCHED=y
CONFIG_FAIR_GROUP_SCHED=y
CONFIG_RT_GROUP_SCHED=y
CONFIG_BLK_CGROUP=y
# CONFIG_DEBUG_BLK_CGROUP is not set
CONFIG_SCHED_AUTOGROUP=y
CONFIG_CFQ_GROUP_IOSCHED=y
CONFIG_CGROUP_BFQIO=y
|
For BFS (tweaked, aka "beefy") CPU scheduler
...
fixme
Scheduler behavior related changes (general):
General scheduler changes for CFS:
Code: | echo "6000000" > /proc/sys/kernel/sched_latency_ns
echo "100000" > /proc/sys/kernel/sched_min_granularity_ns
echo "10000" > /proc/sys/kernel/sched_wakeup_granularity_ns
echo "7000000" > /proc/sys/kernel/sched_migration_cost_ns
echo "8" > /proc/sys/kernel/sched_nr_migrate
echo "80000" > /proc/sys/kernel/sched_shares_window_ns
echo "970000" > /proc/sys/kernel/sched_rt_runtime_us
echo "1000000" > /proc/sys/kernel/sched_rt_period_us |
General scheduler changes for BFS:
Code: | echo "4" > /proc/sys/kernel/rr_interval
echo "85" > /proc/sys/kernel/iso_cpu |
IRQ-related tweaking:
Sample:
Code: | #!/bin/bash
# Sorted view:
# ps -eLo rtprio,cls,pid,pri,nice,cmd | grep "FF" | sort -r
# ps -eLo pid,cls,rtprio,pri,nice,cmd | grep -i "irq"
# For a non-RT kernel, use kernel option: threadirqs
# http://subversion.ffado.org/wiki/IrqPriorities
# http://alsa.opensrc.org/Rtirq
#piwl=$(pgrep "irq/.*-iwlwifi")
#[[ -n $piwl ]] && chrt -f -p 10 $piwl
#peth=$(pgrep "irq/.*-eth0")
#[[ -n $peth ]] && chrt -f -p 30 $peth
#peth=$(pgrep "irq/.*-eth1")
#[[ -n $peth ]] && chrt -f -p 30 $peth
peth=$(pgrep "irq/.*-eth")
[[ -n $peth ]] && chrt -f -p 50 $peth
# ehci instead of uhci
pmouse=$(pgrep "irq/23-ehci")
[[ -n $pmouse ]] && chrt -f -p 59 $pmouse
pmouse=$(pgrep "irq/20-ehci")
[[ -n $pmouse ]] && chrt -f -p 59 $pmouse
#pmouse=$(pgrep "irq/19-uhci")
#[[ -n $pmouse ]] && chrt -f -p 59 $pmouse
psnd=$(pgrep "irq/.*-snd_")
[[ -n $psnd ]] && chrt -f -p 85 $psnd
#pnouveau=$(pgrep "irq/.*-nouveau")
#[[ -n $pnouveau ]] && chrt -f -p 80 $pnouveau
pnvkm=$(pgrep "irq/.*-nvkm")
[[ -n $pnvkm ]] && chrt -f -p 84 $pnvkm
pnvidia=$(pgrep "irq/.*-nvidia")
[[ -n $pnvkm ]] && chrt -f -p 84 $pnvidia
#pkbd=$(pgrep "irq/.*-i8042")
## 2 of them
#for p in $pkbd ; do
# chrt -f -p 60 $p
#done
prtc=$(pgrep "irq/.*-rtc0")
[[ -n $prtc ]] && chrt -f -p 90 $prtc
#( while true ; do
# # Does not have an IRQ until Xorg is running
# pnvidia=$(pgrep "irq/.*-nvidia")
# if [[ -n $pnvidia ]] ; then
# chrt -f -p 80 $pnvidia
# break
# fi
# sleep 20
#done ) &
|
priority for the nvidia kernel-module doesn't seem to get changed thus - I'll usually do it manually:
Code: | ps -eLo rtprio,cls,pid,pri,nice,cmd | grep "FF" | sort -r |
<-- look for nvidia
Quote: | 50 FF 13613 90 - [irq/39-nvidia] |
so
Code: | chrt -f -p 84 13613 |
software-related tweaking:
Giving the X-server some more bite:
Code: | chrt -a -p -r 9 `pidof X` |
check in htop or top afterwards whether priority got raised to -10
Gaming and app-related tweaking:
Running WINE ?
Code: | schedtool -R -p 90 $(pidof wineserver) |
and on top of that Mass Effect 3 Multiplayer ?
Code: | ps aux | grep MassEffect3.exe |
Does it e.g. reveal 15436 as PID ?
Code: | chrt -a -p -r 89 15436 |
WINE-related considerations:
Make sure to emerge WINE with the staging-USE-flag
and enable CSMT-support in winecfg
Results:
(especially)
Mass Effect 3 Multiplayer
and
Borderlands2
run way much smoother than before !
Borderlands runs flawlessly (at least the native port launched from within Steam)
and
ME3 MP runs 75-95% (in my impression) at speed.
You might need to disable dynamic shadows and AA, do a little tweaking in the GameSettings.ini
but overall it runs surprisingly well.
1920x1080 vs. 1920x1080 in Windows
Whereas previously I couldn't bear to do several rounds on Linux - so only as a occasional bite
it now could prevent me from booting into Windows
Acknowledgements:
- PaulBredbury https://forums.gentoo.org/viewtopic-p-7153966.html#7153966
You ROCK
- Rookie1337 http://www.overclock.net/t/1519964/experiment-overclocking-the-linux-os-through-the-sysclt-proc-sys-sys-block-and-other-settings#post_23094293
That's some sick well-documented shift
- All Gentooligans
Ricers UNITE ! _________________ https://github.com/kernelOfTruth/ZFS-for-SystemRescueCD/tree/ZFS-for-SysRescCD-4.9.0
https://github.com/kernelOfTruth/pulseaudio-equalizer-ladspa
Hardcore Gentoo Linux user since 2004 |
|
Back to top |
|
|
joe4379 n00b
Joined: 19 Jan 2015 Posts: 7
|
Posted: Thu Dec 01, 2016 4:38 pm Post subject: thanks, and a script |
|
|
Thanks! This is huge!
I made a script to semi-automate setting the Nvidia priority (nothing to remember at least). It has sudos and i dont care...
Code: | GNU nano 2.7.1 File: /usr/bin/tweaks
sudo chrt -a -p -r 9 `pidof X`
#[[ -n $pnvkm ]] && chrt -f -p 84 $pnvidia
ps -eLo rtprio,cls,pid,pri,nice,cmd | grep "FF" | sort -r |grep nvidia
echo "What's the third number (PID of nVidia IRQ)?"
read -e PIDOFNVIDIA
sudo chrt -f -p 84 $PIDOFNVIDIA
chrt -p $PIDOFNVIDIA
echo "100000" | sudo tee /proc/sys/kernel/sched_latency_ns
echo "100000" | sudo tee /proc/sys/kernel/sched_min_granularity_ns
echo "1000" | sudo tee /proc/sys/kernel/sched_wakeup_granularity_ns
echo "25000" | sudo tee /proc/sys/kernel/sched_migration_cost_ns
echo "4" | sudo tee /proc/sys/kernel/sched_nr_migrate
echo 1024 | sudo tee /proc/sys/kernel/msgmax && echo 2048 | sudo tee /proc/sys/kernel/msgmnb && echo 8192 | sudo tee /proc/sys/kernel/msgmni
echo "990000" | sudo tee /proc/sys/kernel/sched_rt_runtime_us
echo "1000000" | sudo tee /proc/sys/kernel/sched_rt_period_us
|
|
|
Back to top |
|
|
timofonic n00b
Joined: 13 Sep 2005 Posts: 16
|
Posted: Sun Dec 11, 2016 12:59 pm Post subject: Re: thanks, and a script |
|
|
Hello.
Nvidia proprietary support for this? Thanks a lot! My laptop will be very happy (I plan to install Gentoo on a laptop, I'll have a big workstation later).
It could be nice to standarize the process, make a github.com repository and a package and publish it in Gentoo wiki. This way, realtime and low latency could be more easily adopted. Even better, a database of tweaks for different apps could be made and including Wine software too.
Really: Why isn't realtime and low latency options part of a default Linux desktop installation? I tired it a few times and the results are amazing from my point of view, but the process is really quite cumbersome.
Kind regards.
joe4379 wrote: | Thanks! This is huge!
I made a script to semi-automate setting the Nvidia priority (nothing to remember at least). It has sudos and i dont care...
Code: |
sudo chrt -a -p -r 9 `pidof X`
#[[ -n $pnvkm ]] && chrt -f -p 84 $pnvidia
ps -eLo rtprio,cls,pid,pri,nice,cmd | grep "FF" | sort -r |grep nvidia
echo "What's the third number (PID of nVidia IRQ)?"
read -e PIDOFNVIDIA
sudo chrt -f -p 84 $PIDOFNVIDIA
chrt -p $PIDOFNVIDIA
echo "100000" | sudo tee /proc/sys/kernel/sched_latency_ns
echo "100000" | sudo tee /proc/sys/kernel/sched_min_granularity_ns
echo "1000" | sudo tee /proc/sys/kernel/sched_wakeup_granularity_ns
echo "25000" | sudo tee /proc/sys/kernel/sched_migration_cost_ns
echo "4" | sudo tee /proc/sys/kernel/sched_nr_migrate
echo 1024 | sudo tee /proc/sys/kernel/msgmax && echo 2048 | sudo tee /proc/sys/kernel/msgmnb && echo 8192 | sudo tee /proc/sys/kernel/msgmni
echo "990000" | sudo tee /proc/sys/kernel/sched_rt_runtime_us
echo "1000000" | sudo tee /proc/sys/kernel/sched_rt_period_us
|
|
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|