增加最新请求的RTC中断频率
默认频率是64hz。先使用su命令,进入管理员权限才能操作。
echo 2048 > /sys/class/rtc/rtc0/max_user_freq
echo 2048 > /proc/sys/dev/hpet/max-user-freq
修改交换分区频率与inotify
交换分区频率是由swappiness定义的,默认是60,修改为10,在硬盘写入之前,系统会等待更久一些。
还有一个inotify用来发现app请求的文件修改,如果有大量的音频数据在操作,这个inotify需要调更高。
这两个设置都可以设置在做/etc/sysctl.d/99-sysctl.conf
sudo vim /etc/sysctl.d/99-sysctl.conf
vm.swappiness = 10
fs.inotify.max_user_watches = 524288
安装Linux-rt内核(可选)
注意!这个是可选的,lowlatency的内核也能获得较低的延迟。有的nVidia或AMD/ATI显卡驱动在rt内核会不工作。
如果你了解到你的显卡在rt内核上工作良好,或想一尝新鲜,继续吧。我的Intel显卡工作很良好。
Arch Linux
yaourt linux-rt
Ubuntu
sudo apt-get install linux-realtime linux-headers-realtime
更新grub配置
sudo grub-mkconfig -o /boot/grub/grub.cfg
其他的可选项
最大化PCI声卡的延迟时间,等等。具体见WIKI
使用Quickscan脚本检查设置
这个脚本是perl语言写成的,需要先安装perl。如果没有git也需先安装git。
Arch Linux
sudo pacman -S perl git
Ubuntu
sudo apt-get install perl git-all
获取脚本并运行
git clone git://github.com/raboof/realtimeconfigquickscan.git
cd realtimeconfigquickscan
perl ./realTimeConfigQuickScan.pl
在运行结果中看有没有not good的,如果只有RT内核检测是not good,你也不需要RT内核,就完满成功啦!
参考一下我的检测结果:
== GUI-enabled checks ==
Checking if you are root... no - good
Checking filesystem 'noatime' parameter... 4.10.6 kernel - good
(relatime is default since 2.6.30)
Checking CPU Governors... CPU 0: 'performance' CPU 1: 'performance' CPU 2: 'performance' CPU 3: 'performance' - good
Checking swappiness... 10 - good
Checking for resource-intensive background processes... none found - good
Checking checking sysctl inotify max_user_watches... >= 524288 - good
Checking access to the high precision event timer... readable - good
Checking access to the real-time clock... readable - good
Checking whether you're in the 'audio' group... yes - good
Checking for multiple 'audio' groups... no - good
Checking the ability to prioritize processes with chrt... yes - good
Checking kernel support for high resolution timers... found - good
Kernel with Real-Time Preemption... not found - not good
Kernel without real-time capabilities found
For more information, see http://wiki.linuxaudio.org/wiki/system_configuration#installing_a_real-time_kernel
Checking if kernel system timer is high-resolution... found - good
Checking kernel support for tickless timer... found - good
== Other checks ==
Checking filesystem types... ok.
ok.
wiki参考资料:
https://lado.me/2017/04/06/configure-the-linux-audio-system/