Lowlatency on ArchBang

Post fully complete "how to" guides and tutorials here. This is a great place to get feedback on stuff you might put in the wiki.

Moderators: khz, MattKingUSA

User avatar
CrocoDuck
Establlshed Member
Posts: 398
Joined: Sat May 05, 2012 6:12 pm
Contact:

Lowlatency on ArchBang

Postby CrocoDuck » Sun Mar 24, 2013 9:35 pm

Image
...ArchBang Linux is very good for audio after proper configuration...

O Hay Cool People! So, I went for a try of ArchBang Linux (yeah, I'm a noob of ArchBang and Arch...) and I fell in love for it's exquisite lightweight Arch-based performances. So, I installed it and tweaked a little in order to get lowlatency. The results I found are very promising! In the following I'll briefly speak about the tweaking I made on the system while linking the pages I used as base. All the tweaking were performed on a fresh install, after a full system update and are based on info I collected online, mostly from Pro-Audio Gentoo Overlay, Linuxaudio and the Arch Pro Audio guide. This tutorial is mostly intended to sum up all the useful info and act as a quick reference memorandum and links bookmark (Is why I think that it could be useful). So don't expect deep explanations of Arch and ArchBang (I said: I'm a noob), everything will be explained at the linked pages. Let's go!

When talking about package installation please refer to Arch and ArchBang resources for explanations and howtos (the packages are from both repos and AUR). Most of this tweaking are not OS specific, however carefully extend them to your OS (some command, path, package name etc... etc... could be different or need to be treated in another way). Keep in mind that you are experimenting with your system. Be careful and don't make actions you think could be dangerous for system and data. Reading the linked pages is strongly recommended: if done it will minimize the risk of ruining the system. Also, understanding what you are doing will be easier (and maybe you can understand how optimize this tweaking for your particular situation... or maybe you could suggest some further tweaking for my system :wink: ).
After a fresh install I found my user in the audio group, with jack installed... cool! First of all we need a comfortable tool to manage CPU governors. I recommend to install cpupower (WARNING: if you are using a laptop that could be a bad idea... See the UPDATE 4). Here what to know. We will set the governors to "performance" when making music. Then we install systemd-rtirq (check the "UPDATE 2:" at the bottom of the post) and we enable it with

Code: Select all

systemctl enable rtirq


as explained here and here. You find the configuration file under /etc/conf.d/ .

We will also have to boot the kernel with threadirqs option enabled. To do it edit the file /etc/default/grub by changing the argument of GRUB_CMDLINE_LINUX="" to this:

Code: Select all

 GRUB_CMDLINE_LINUX="threadirqs"


then we proceed by regenerating grub.cfg with this:

Code: Select all

grub-mkconfig -o /boot/grub/grub.cfg


As explained here and here.

As always we are going to add noatime to the filesystem mount options. To do it we just have to open /etc/fstab with our favorite text editor and put noatime in the options field, making the line of our disk to look like:

Code: Select all

/dev/sda1              /             ext4      defaults,noatime      0      1


in this example the OS partition is sda1, formatted with ext4. For further explanations see this page. Then, is the time for /etc/sysctl.conf (* Check the "UPDATE:" at the end of the post), add this lines at bottom file:

Code: Select all

vm.swappiness=10
vm.vfs_cache_pressure=50
fs.inotify.max_user_watches = 524288



you can find good explanation of what those lines do at here and here. Is worth enabling real-time prioritizing. For that use the pam package. Follow the instructions to install. The default limits.conf file you find on ArchBang should be enough good, just run:

Code: Select all

pacman -Q --owns /etc/security/limits.conf


Of course, you can edit limits.conf to taste, remember to set up the jack priority at least 10 lower the one you set in rtprio. Also remeber that your user is probably in the audio group since its creation during installation. Now I decided to have a try with cgroups. So install libcgroup from AUR and then edit /etc/cgconfig.conf adding this at bottom:

Code: Select all

namespace {
   cpu = /;
}

group rtaudio {
   perm {
      task {
         uid = root;
         gid = audio;
      }
      admin {
         uid = root;
         gid = root;
      }
   }
   cpu {
      cpu.rt_runtime_us = 950000;
   }
}


as explained here and here . We are going to edit /etc/cgrules.conf too, add the following at bottom:

Code: Select all

# One of the following line is needed for jack
#@audio:jackd      cpu   rtaudio/
@audio:jackdbus      cpu   rtaudio/
# Comment the 2 following lines if not using snd-aloop
@audio:alsa_in      cpu   rtaudio/
@audio:alsa_out      cpu   rtaudio/
@audio:ardour        cpu   rtaudio/
# Add one line for each RT software
@audio:mplayer      cpu   rtaudio/
@audio:jamin        cpu   rtaudio/


everything explained on Pro-Audio Gentoo Overlay linked page. Then comes the reboot time. If everything went OK we are ready to install qjackctl and search the best configuration ever! On laptops we could be interested in killing some interfering process, services or similar to avoid xruns. On my Archbang installation (on top of a Presario CQ61) in the past I had to run this script to prevent xruns, due to wifi card (it makes some further optimizations though):

Code: Select all

#!/bin/sh

########################################################################
# Prepare the system for low latency audio operation. Steps:           #
# Set CPU governors for performances - Unload not needed kernel        #
# modules - Kill not needed processes - Stop unwanted services -       #
# Load the high res timer and set tasklet daemon priority -            #
# Check the timers frequencies.                                        #
########################################################################

# Governors:
echo Setting CPU governors:
# Set CPU governors to performance:
cpupower frequency-set -g performance
echo DONE

# Kernel Modules
echo Unloading unwanted Kernel Modules
# Parallel Port
modprobe -r ppdev
# Printer
modprobe -r lp
# Webcam
modprobe -r uvcvideo
modprobe -r videodev
# Wireless
modprobe -r ath9k
# NIC
modprobe -r r8169
# Bluetooth USB                                                       
modprobe -r btusb
echo DONE

# Unwanted Processes
echo Killing unwanted processes:
# Compositing
killall -w compton
# Wbar
killall -w wbar
# Conky
sudo -u crocoduck killall -w conky
# Panel tint2
sudo -u crocoduck killall -w tint2
echo DONE

# Unwanted Services
echo Stop unwanted services
# Teamviewer
systemctl stop teamviewerd
# Entropy collection
systemctl stop haveged
# Networking
systemctl stop NetworkManager
systemctl stop wpa_supplicant
echo DONE

# High Res Timer and Tasklet
echo Loading ALSA high res timer and TASKLETPR
# Load the ALSA high res timer
modprobe snd-hrtimer
# Define a variable TASKLETPR and set it to 76
TASKLETPR=76
# Set the priority of the tasklet daemon
ps -eLo pid,cmd \
| grep [t]asklet | awk '{ system("chrt -f -p '$TASKLETPR' " $1)}'
echo DONE

# Checking the Timers frequencyes
echo Probing Timers frequencies for hpet and rtc0:
echo HPET:
cat /proc/sys/dev/hpet/max-user-freq
echo RTC0:
cat /sys/class/rtc/rtc0/max_user_freq
echo Finished


Based on a script I found on linux musicians some time ago. It is reversible with this one:

Code: Select all

#!/bin/sh

########################################################################
# Restore default system operation after lowlatency preparation with   #
# ArchPerformances.sh                                                  #
########################################################################

# Governors:
echo Setting CPU governors:
# Set CPU governors to ondemand:
cpupower frequency-set -g ondemand
echo DONE

# Kernel Modules
echo Reloading unwanted Kernel Modules
# Parallel Port
modprobe ppdev
# Printer
modprobe lp
# Webcam
modprobe uvcvideo
modprobe videodev
# Wireless
modprobe ath9k
# NIC
modprobe r8169
# Bluetooth USB                                                       
modprobe btusb
echo DONE

# Unwanted Processes
echo Restarting unwanted processes:
sudo -u crocoduck compton -b &
sudo -u crocoduck wbar &
sudo -u crocoduck conky &
sudo -u crocoduck tint2 &
echo DONE

# Unwanted Services
echo Start unwanted services
# Teamviewer
systemctl start teamviewerd
# Entropy collection
systemctl start haveged
# Networking
systemctl start NetworkManager
systemctl start wpa_supplicant
echo DONE


If you experience troubles with stability, give that script a go (edit it according to the applications/services you need to kill). You may want to set max-user-freq for hardware timers. To change the default 64 for hpet you just have to create the file /etc/sysctl.d/60-max-user-freq.conf with this content:

Code: Select all

dev.hpet.max-user-freq=3072


To change the default value for rtc0 you need a startup script. On a lot of distros you can append the line

Code: Select all

echo 3072 >/sys/class/rtc/rtc0/max_user_freq


to /etc/rc.local , but on Arch and ArchBang init.system has been substituted with systemd. It means that you have to create a service. Here a template for a service intended to run a script on startup. If you follow it the content of /usr/bin/my-script is going to be like this:

Code: Select all

#!/bin/bash
echo 3072 >/sys/class/rtc/rtc0/max_user_freq


Refer to the System configuration page on Linuxaudio for a discussion about hardware timers.

The kernel that comes with a standard ArchBang installation is not so bad for audio tasks. As a matter of fact into his Kernel Configuration we can see:

Code: Select all

CONFIG_PREEMPT_RCU=y
CONFIG_PREEMPT_NOTIFIERS=y
# CONFIG_PREEMPT_NONE is not set
# CONFIG_PREEMPT_VOLUNTARY is not set
CONFIG_PREEMPT=y
CONFIG_PREEMPT_COUNT=y
# CONFIG_PREEMPT_TRACER is not set
CONFIG_IRQ_FORCED_THREADING=y


The scheduler will apply full preemption to all processes, reducing latency. We also see the option needed for rtirq to work. But there is a con in the default kernel's configuration:

Code: Select all

# CONFIG_HZ_100 is not set
# CONFIG_HZ_250 is not set
CONFIG_HZ_300=y
# CONFIG_HZ_1000 is not set
CONFIG_HZ=300


If the frequency of the interrupts generated by the kernel is so low then reducing the maximum latency achievable to the desired one could be an issue. Especially for MIDI stuff an higher frequency is recommended. For changing this (and/or many other) configuration in the kernel you have to build a custom one or install a new one. For example the liquorix kernel has all the configs we like: preemption and irq forced threading are still active and we see

Code: Select all

# CONFIG_HZ_100 is not set
# CONFIG_HZ_250 is not set
# CONFIG_HZ_300 is not set
CONFIG_HZ_1000=y
CONFIG_HZ=1000


the frequency of the interrupts is the highest one allowed. With that kernel lowering jack's Frames/Periods should be possible.

I experienced an issue with any USB soundcard I used, probably because some weirdness in my laptop's USB hardware. When I tried to lower the latency below 8ms a lot of xrun appeared. With the help of cool people from ArchBang forums (they helped me with timer's frequencies too) I found that the issue is related to a driver in use with newer kernels as supplied by arch repos and AUR: ehci-pci . A kernel that still use ehci-hcd doesn't have this problem (check the "UPDATE 3:" at the bottom of the post). The best experience I had is with linux-rt-lts. You can install a lot of interesting kernels from AUR, but if you don't want to compile every single kernel cool rt kernels are supplied by archaudio repos. Just add the following to your pacman.conf:

Code: Select all

[archaudio-production]
SigLevel = Never
Server = http://repos.archaudio.org/$repo/$arch


you may be interested in wine-rt and wineasio too. All in that repo.

Finally, my jack configurations:

When using the internal sound card (standard core repo kernel is enough for good performances with her):

Code: Select all

/usr/bin/jackd -P89 -t5000 -dalsa -r96000 -p64 -n3 -D -Chw:Intel,0 -Phw:Intel,0


2ms of latency for it.

When using USB audio (need to use linux-rt-lts):

Code: Select all

/usr/bin/jackd -v -P89 -p128 -t5000 -dalsa -r48000 -p64 -n3 -D -Chw:CODEC,0 -Phw:CODEC,0


Hope this "tutorial", the first I make, will be useful. Feel free to correct mistakes and make suggestions. Thanks to all the people that replied on this thread helping me to solve the issues and special thanks to pablokal,oliver and Mr Green from ArchBang forums. You guys make me a happy musician penguin!

UPDATE:

As always, stay tuned with Arch and Archbang news: you need that news for taking all the manual interventions that could be required after an update. On 2013-09-17 on the arch's site appeared a message regarding systcl.conf. So:

If you installed Archbang and followed this guide before 2013-09-17 and your system is up to date then you need an adjustment, as we edited sysctl.conf adding

Code: Select all

vm.swappiness=10
vm.vfs_cache_pressure=50
fs.inotify.max_user_watches = 524288


If you are not sure about your systemd version check it with

Code: Select all

systemctl --version


Check your current procps-ng version querying the package database:

Code: Select all

pacman -Qs procps-ng


If the programs are up to date then you need intervention. Also, there is a simple way to undarstand whether or not the sysctl.conf file is being used by the system: just run

Code: Select all

cat /proc/sys/vm/swappiness


If the output is 60 and not 10, as we want, then your system is up to date enough to get rid of sysctl.conf. So, follow the instructions in the linked page. I didn't have a file called /etc/sysctl.conf.pacsave , so I just created /etc/sysctl.d/99-sysctl.conf with the same content of sysctl.conf . Then I renamed sysctl.conf into sysctl.conf.backup .

Finally, I see that the fs.inotify.max_user_watches value is not so effective for audio performances... you can comment it.

If you installed ArchBang after 2013-09-17 and are following this guide now, just create directly /etc/sysctl.d/99-sysctl.conf with this content:

Code: Select all

vm.swappiness=10
vm.vfs_cache_pressure=50


UPDATE 2:

At the time I wrote the guide there were 2 packages in AUR : systemd-rtirq and rtirq. Some time ago the two packages has been merged. As a consequence there is just one now: rtirq. So, if you followed this guide when systemd-rtirq was still alive and you are manually maintaining updated the AUR packages then you can proceed like this:

Remove systemd-rtirq (and its dependencies which are not required by any other installed package):

Code: Select all

pacman -Rs systemd-rtirq


the old configuration file will be saved as /etc/conf.d/rtirq.pacsave , GOOD STUFF: you don't loose your configuration.

Then install rtirq and enable the service as before:

Code: Select all

systemctl enable rtirq


Use /etc/conf.d/rtirq.pacsave as a base to edit the new /etc/conf.d/rtirq configuration file, which is the one actually used by the system (if you never tweaked the configuration of rtirq in the past just use the default).

If you are following this guide now:

Just install the package rtirq. Then enable the service with:

Code: Select all

systemctl enable rtirq


follow the rest of the guide (don't forget the part for kernel boot options!).

Some tip to understand if rtirq is working for real:

give this 2 guys:

Code: Select all

systemctl status rtirq
/usr/bin/rtirq status


If everything is working, the output should look like this (respectively):

Code: Select all

rtirq.service - Realtime IRQ thread system tuning
   Loaded: loaded (/etc/systemd/system/rtirq.service; enabled)
   Active: active (exited) since Wed 2013-12-25 21:13:36 CET; 2min 7s ago
  Process: 869 ExecStart=/usr/bin/rtirq start (code=exited, status=0/SUCCESS)
 Main PID: 869 (code=exited, status=0/SUCCESS)


Code: Select all

  PID CLS RTPRIO  NI PRI %CPU STAT COMMAND   
   42 FF      90   - 130  0.0 S    irq/8-rtc0   
  266 FF      85   - 125  0.0 S    irq/45-snd_hda_   
   70 FF      80   - 120  0.0 S    irq/16-uhci_hcd   
   77 FF      79   - 119  0.0 S    irq/16-uhci_hcd   
   78 FF      79   - 119  0.0 S    irq/18-uhci_hcd   
   73 FF      78   - 118  0.0 S    irq/19-uhci_hcd   
   72 FF      77   - 117  0.0 S    irq/20-uhci_hcd   
   71 FF      76   - 116  0.0 S    irq/21-uhci_hcd   
   40 FF      75   - 115  0.0 S    irq/1-i8042   
   39 FF      74   - 114  0.3 S    irq/12-i8042   
   23 FF      50   -  90  0.0 S    irq/9-acpi   
   37 FF      50   -  90  0.0 S    irq/40-PCIe PME   
   38 FF      50   -  90  0.0 S    irq/41-PCIe PME   
   75 FF      50   -  90  0.0 S    irq/19-ehci_hcd   
   76 FF      50   -  90  0.0 S    irq/20-ehci_hcd   
   79 FF      50   -  90  0.1 S    irq/42-ahci   
  193 FF      50   -  90  0.0 S    irq/43-i915   
  245 FF      50   -  90  0.0 S    irq/16-ath9k   
  611 FF      50   -  90  0.0 S    irq/18-i801_smb   
  825 FF      50   -  90  0.0 S    irq/44-enp3s0   
    3 TS       -   0  19  0.0 S    ksoftirqd/0   
   14 TS       -   0  19  0.0 S    ksoftirqd/1   


UPDATE 3:

Actually, the latest kernel images of linux-rt-lts are supplied with ehci-pci, but I'm having no issues with them. Probably there was some kind of bug in the previous versions of the driver and/or in its implementation.

UPDATE 4:

A note for laptop users: beware laptop-mode-tools and cpupower. They used to be nice tools, but they have started behave strangely on my machine with latest kernels (the kernel version at the time of this UPDATE is 3.17.3-1). I suggest to not install laptop-mode-tools and cpupower. Install tlp instead. It is assuring to me a nice 0 xruns experience!

The symptoms of my machine were: unbalanced CPU frequency between the cores, overheating with not so huge load, USB hardware being shut down without apparent or easily reproducible reason. Have a look at here and here to find out.
Last edited by CrocoDuck on Sun Aug 02, 2015 5:07 pm, edited 63 times in total.
Check my Linux audio experiments on my SoundCloud.
Fancying a swim in the pond?

User avatar
eikakot
Establlshed Member
Posts: 68
Joined: Fri Jan 29, 2010 2:24 pm
Location: Vilnius, Lithuania
Contact:

Re: Lowlatency on Archbang

Postby eikakot » Sun Mar 24, 2013 10:55 pm

Hey it would be cool to see some benchmarking of your system now ;)

User avatar
Capoeira
Establlshed Member
Posts: 1167
Joined: Tue May 12, 2009 1:01 pm
Location: Brazil

Re: Lowlatency on Archbang

Postby Capoeira » Mon Mar 25, 2013 11:05 am

the cgroups thing is new to me. What exactly is the benefit?

User avatar
CrocoDuck
Establlshed Member
Posts: 398
Joined: Sat May 05, 2012 6:12 pm
Contact:

Re: Lowlatency on Archbang

Postby CrocoDuck » Mon Mar 25, 2013 12:14 pm

The cgruops thing was new to me too. I decided to have a try after reading the guide on Pro-Audio Gentoo Overlay. From it: "Control Groups provide a mechanism for aggregating/partitioning sets of tasks, and all their future children, into hierarchical groups with specialized behaviour. This is exactly what the real-time patch is doing: it provide a mechanism for aggregating the audio tasks, and for attributing them a higher priority than the other tasks. The same (and much more) can be done with the Control Groups, this with any recent kernel.". It seems to me that 3.x kernels can have performances close to the performances of rt kernels in fact of audio. I'm still tryng to understand how much the cgroups thing is effective into the lowlatency economy, for now I can get the best stabilty with this jack setup:

Code: Select all

/usr/bin/jackd -t5000 -dalsa -r48000 -p128 -n2 -D -Chw:0,0 -Phw:0,0


the latency is 5.33 ms and no one xrun were detected for 2 hours. This is enough for me, but I'll try to reduce Frames/Period during the week. For now I'm using the HDA-intel integrated soundcard, I'll test soon with a UCA202. The cgroups thing should be active, basing on the output of ps -eLo rtprio,pri,cgroup,class,pid,pcpu,%mem,user,comm --sort pri|less :

Code: Select all

RTPRIO PRI CGROUP                      CLS   PID %CPU %MEM COMMAND
     -  19 1:name=systemd:/system      TS      1  0.0  0.0 systemd
     -  19 3:cpuacct,cpu:/system/Netwo TS    285  0.0  0.1 NetworkManager
     -  19 3:cpuacct,cpu:/system/Netwo TS    285  0.0  0.1 NetworkManager
     -  19 3:cpuacct,cpu:/system/Netwo TS    285  0.0  0.1 gdbus
     -  19 3:cpuacct,cpu:/system/Netwo TS    285  0.0  0.1 gmain
     -  19 3:cpuacct,cpu:/system/polki TS    531  0.0  0.2 polkitd
     -  19 3:cpuacct,cpu:/system/polki TS    531  0.0  0.2 gdbus
     -  19 3:cpuacct,cpu:/system/polki TS    531  0.0  0.2 polkitd
     -  19 3:cpuacct,cpu:/system/polki TS    531  0.0  0.2 runaway-killer-
     -  19 3:cpuacct,cpu:/system/polki TS    531  0.0  0.2 gmain
     -  19 1:name=systemd:/user/crocod TS    601  0.0  0.1 conky
     -  19 1:name=systemd:/user/crocod TS    601  0.0  0.1 conky
     -  19 1:name=systemd:/user/crocod TS    601  0.0  0.1 conky
     -  19 1:name=systemd:/user/crocod TS    601  0.0  0.1 conky
     -  19 1:name=systemd:/user/crocod TS    607  0.0  0.0 at-spi-bus-laun
     -  19 1:name=systemd:/user/crocod TS    607  0.0  0.0 dconf worker
     -  19 1:name=systemd:/user/crocod TS    607  0.0  0.0 gdbus
     -  19 1:name=systemd:/user/crocod TS    607  0.0  0.0 gmain
     -  19 1:name=systemd:/user/crocod TS    614  0.0  0.0 at-spi2-registr
     -  19 1:name=systemd:/user/crocod TS    614  0.0  0.0 gdbus
     -  19 1:name=systemd:/user/crocod TS    616  0.0  0.6 nm-applet
     -  19 1:name=systemd:/user/crocod TS    616  0.0  0.6 dconf worker
     -  19 1:name=systemd:/user/crocod TS    616  0.0  0.6 gdbus
     -  19 3:cpuacct,cpu:/system/udisk TS    687  0.0  0.1 udisks-daemon
     -  19 3:cpuacct,cpu:/system/udisk TS    687  0.0  0.1 gdbus
     -  19 3:cpuacct,cpu:/system/udisk TS    687  0.0  0.1 gmain
     -  19 1:name=systemd:/user/crocod TS    723  0.0  0.4 lxterminal
     -  19 1:name=systemd:/user/crocod TS    723  0.0  0.4 gmain
     -  19 1:name=systemd:/user/crocod TS    952  0.5  1.9 qjackctl
     -  19 1:name=systemd:/user/crocod TS    952  0.0  1.9 QProcessManager
     -  19 1:name=systemd:/user/crocod TS    952  0.0  1.9 qjackctl
     5  45 1:name=systemd:/user/crocod FF    952  0.0  1.9 qjackctl
     -  19 1:name=systemd:/user/crocod TS    984  0.0  0.5 jackd
     -  19 1:name=systemd:/user/crocod TS    984  0.0  0.5 jackd
     -  19 1:name=systemd:/user/crocod TS    984  0.0  0.5 jackd
    20  60 1:name=systemd:/user/crocod FF    984  0.0  0.5 jackd
    10  50 1:name=systemd:/user/crocod FF    984  1.1  0.5 jackd


We see the realtime threads and they are the expected ones.
Check my Linux audio experiments on my SoundCloud.
Fancying a swim in the pond?

User avatar
AutoStatic
Establlshed Member
Posts: 1668
Joined: Wed Dec 09, 2009 5:26 pm
Location: Beverwijk, The Netherlands
Contact:

Re: Lowlatency on Archbang

Postby AutoStatic » Mon Mar 25, 2013 7:20 pm

Capoeira wrote:the cgroups thing is new to me. What exactly is the benefit?
Afaik close to nothing. More info: http://web.archive.org/web/201210061446 ... ki/Cgroups

User avatar
funkmuscle
Establlshed Member
Posts: 1703
Joined: Mon Jun 02, 2008 2:30 pm

Re: Lowlatency on Archbang

Postby funkmuscle » Mon Mar 25, 2013 8:41 pm

@CrocoDuck

you should edit the Pro Audio wiki for Arch by adding your info you've added here. :D

User avatar
CrocoDuck
Establlshed Member
Posts: 398
Joined: Sat May 05, 2012 6:12 pm
Contact:

Re: Lowlatency on Archbang

Postby CrocoDuck » Wed Mar 27, 2013 7:07 pm

Hi, some news. They are not bad, but are still not as good as I expected. I updated the tutorial in order to make rtirq working for real. Now /etc/rc.d/rtirq status gives to me an output like this:

Code: Select all

/etc/rc.d/rtirq status
  PID CLS RTPRIO  NI PRI %CPU STAT COMMAND   
   42 FF      90   - 130  0.0 S    irq/8-rtc0   
  292 FF      85   - 125  0.0 S    irq/45-snd_hda_   
   80 FF      80   - 120  0.0 S    irq/16-uhci_hcd   
   84 FF      79   - 119  0.0 S    irq/16-uhci_hcd   
   85 FF      79   - 119  0.0 S    irq/18-uhci_hcd   
   83 FF      78   - 118  0.0 S    irq/19-uhci_hcd   
   82 FF      77   - 117  0.0 S    irq/20-uhci_hcd   
   81 FF      76   - 116  0.0 S    irq/21-uhci_hcd   
   40 FF      75   - 115  0.0 S    irq/1-i8042   
   39 FF      74   - 114  0.0 S    irq/12-i8042   
   24 FF      50   -  90  0.0 S    irq/9-acpi   
   37 FF      50   -  90  0.0 S    irq/40-PCIe PME   
   38 FF      50   -  90  0.0 S    irq/41-PCIe PME   
   78 FF      50   -  90  0.0 S    irq/19-ehci_hcd   
   86 FF      50   -  90  0.1 S    irq/42-ahci   
   99 FF      50   -  90  0.0 S    irq/20-ehci_hcd   
  272 FF      50   -  90  0.0 S    irq/18-i801_smb   
  274 FF      50   -  90  0.1 S    irq/16-ath9k   
  284 FF      50   -  90  0.0 S    irq/44-i915   
  527 FF      50   -  90  0.0 S    irq/43-enp3s0   
    3 TS       -   0  19  0.0 S    ksoftirqd/0   
   14 TS       -   0  19  0.0 S    ksoftirqd/1   


The jack configuration that I finally chosen when using the onboard sound card is:

Code: Select all

/usr/bin/jackd -P89 -t5000 -dalsa -r48000 -p128 -n2 -D -Chw:1,0 -Phw:1,0


And it sounds good for me. I also Tested the system with a UCA202. WIth enough stability (not fully tested yet) I can get 8 ms of latency:

Code: Select all

/usr/bin/jackd -P89 -t5000 -dalsa -r48000 -p192 -n2 -D -Chw:0,0 -Phw:0,0


In my opinion the maximum latency achievable by system should be 7 ms. I think this because in my experience (and knowledge) latencies as high as 11-12 ms are audible, but that limit is somehow "smooth". As the latency increases and becomes as big as around 10 ms you can feel any kind of groove you are playing, expecially if we are speaking about of a greasy-groovy-picky-spanky swing-thing groove, somehow modified. Forging the groove is actually placing beats in the time. If the computer shifts the beats you place then you hear a groove with another feeling. Even if 10 ms are not so much, playing with that latency gives to me the sensation to being ripped into 2 parts in the brain: I try to forge the groove in a way, but actually it sounds always different. As the latency increases and becomes around 20 ms playing is definitively impossible (and you can clearly notice the delay)! So I gave to myself the limit of 7ms for the highest possible latency. It comes that Archbang is dual boot with Ubuntu Studio 12.04. The configuration is almost the same. The kernel of course is built with different options. Here a difference I found:

Code: Select all

On 3.8.4-1-ARCH

# CONFIG_HZ_100 is not set
# CONFIG_HZ_250 is not set
CONFIG_HZ_300=y
# CONFIG_HZ_1000 is not set
CONFIG_HZ=300


Code: Select all

On 3.2.0-39-lowlatency

# CONFIG_HZ_100 is not set
# CONFIG_HZ_250 is not set
# CONFIG_HZ_300 is not set
CONFIG_HZ_1000=y
CONFIG_HZ=1000


The CONFIG_PREEMPT kinda fields are almost the same. On Archbang It happens to me that when trying to reduce Frames/Period a lot of xruns appears (with both jack configurations). That doesn't happens on Ubuntu Studio. I was wondering why, maybe because of this difference in the kernel options? Any suggestion is welcome!
Last edited by CrocoDuck on Wed Apr 10, 2013 9:32 am, edited 1 time in total.
Check my Linux audio experiments on my SoundCloud.
Fancying a swim in the pond?

User avatar
AutoStatic
Establlshed Member
Posts: 1668
Joined: Wed Dec 09, 2009 5:26 pm
Location: Beverwijk, The Netherlands
Contact:

Re: Lowlatency on Archbang

Postby AutoStatic » Wed Mar 27, 2013 7:53 pm

CrocoDuck wrote:

Code: Select all

/usr/bin/jackd -P89 -t5000 -dalsa -r48000 -p128 -n2 -D -Chw:1,0 -Phw:1,0
Are you using Jack1 or Jack2?

CrocoDuck wrote:And it sounds good for me. I also Tested the system with a UCA202. WIth enough stability (not fully tested yet) I can get 8 ms of latency:

Code: Select all

/usr/bin/jackd -P89 -t5000 -dalsa -r48000 -p192 -n2 -D -Chw:0,0 -Phw:0,0
In my experience USB interfaces just work better with a periods setting of 3.

CrocoDuck wrote:The CONFIG_PREEMPT kinda fields are almost the same. On Archbang It happens to me that when trying to reduce Frames/Period a lot of xruns appears (with both jack configurations). That doesn't happens on Ubuntu Studio. I was wondering why, maybe because of this difference in the kernel options? Any suggestion is welcome!
This is probably because of the different CONFIG_HZ settings. For audio you can really benefit of a 1000Hz kernel timer frequency, or you can go tickless (CONFIG_NO_HZ).

User avatar
CrocoDuck
Establlshed Member
Posts: 398
Joined: Sat May 05, 2012 6:12 pm
Contact:

Re: Lowlatency on Archbang

Postby CrocoDuck » Wed Mar 27, 2013 8:06 pm

I was using jack1. I uninstalled it and now I'm using jack2. The problem persists. I also tryed to setting the period to 3, but still troubles when lowering Frames/Period.
Check my Linux audio experiments on my SoundCloud.
Fancying a swim in the pond?

Shadow_7
Establlshed Member
Posts: 152
Joined: Tue Jun 08, 2010 3:35 pm

Re: Lowlatency on Archbang

Postby Shadow_7 » Tue Apr 02, 2013 3:06 pm

48kHz with jack could cause some latency if you do any software synth from samples. As the source material is 44.1kHz (ripped from cds and the likes). At least that's the case with most of the samples you find for fluidsynth.

User avatar
CrocoDuck
Establlshed Member
Posts: 398
Joined: Sat May 05, 2012 6:12 pm
Contact:

Re: Lowlatency on Archbang

Postby CrocoDuck » Tue Apr 02, 2013 7:12 pm

Shadow_7 wrote:48kHz with jack could cause some latency if you do any software synth from samples. As the source material is 44.1kHz (ripped from cds and the likes). At least that's the case with most of the samples you find for fluidsynth.


Good to know :D ! I''m not usually do software synth from samples, but when I'll do it I'll change Frames/Period to 44.1kHz (or I'll resample the samples to 48000Hz).

I added in the "tutorial" some tip to set_max_user_freq for hardware timers, even if looks that those settings are not so much useful these days... Even if I installed the liquorix kernel, that has CONFIG_HZ=1000, I'm still facing difficulties lowering Frames/Period jack's parameter with both internal and usb soundcards. I'll keep on searching why...
Check my Linux audio experiments on my SoundCloud.
Fancying a swim in the pond?

User avatar
funkmuscle
Establlshed Member
Posts: 1703
Joined: Mon Jun 02, 2008 2:30 pm

Re: Lowlatency on Archbang

Postby funkmuscle » Tue Apr 02, 2013 7:21 pm

Shadow_7 wrote:48kHz with jack could cause some latency if you do any software synth from samples. As the source material is 44.1kHz (ripped from cds and the likes). At least that's the case with most of the samples you find for fluidsynth.


good to know but I've never experience at all even with the stock kernel which is all I use now!!

Shadow_7
Establlshed Member
Posts: 152
Joined: Tue Jun 08, 2010 3:35 pm

Re: Lowlatency on Archbang

Postby Shadow_7 » Wed Apr 03, 2013 7:50 pm

funkmuscle wrote:
Shadow_7 wrote:48kHz with jack could cause some latency if you do any software synth from samples. As the source material is 44.1kHz (ripped from cds and the likes). At least that's the case with most of the samples you find for fluidsynth.


good to know but I've never experience at all even with the stock kernel which is all I use now!!


I experienced it most when I had a pulse over jack setup on ubuntu. Since the pulse version at that time only does 48kHz. Hardly a model of low latency. That and most of my computers are 5+ years old (2GHz or less CPUs). At the time I was trying to work with an ubuntu-studio optical boot option for a less tech savvy drummer to try and solve the bands midi latency issue with linux. Ultimately I had to stop using pulse by adding the "autospawn = no" option to /etc/pulse/client.conf and manually starting and stopping pulse depending on usage.

User avatar
funkmuscle
Establlshed Member
Posts: 1703
Joined: Mon Jun 02, 2008 2:30 pm

Re: Lowlatency on Archbang

Postby funkmuscle » Wed Apr 03, 2013 9:23 pm

just got a quad about a year ago but I been using dual-cores for the longest while.. I never had success with Pulse. Is it worth the try?

User avatar
CrocoDuck
Establlshed Member
Posts: 398
Joined: Sat May 05, 2012 6:12 pm
Contact:

Re: Lowlatency on Archbang

Postby CrocoDuck » Fri Apr 12, 2013 4:15 pm

I found the way to lower Frames/Period and I updated the "tutorial". Now jack doesn't crash if I lower Frames/Period. With this configuration the Internal HDA looks stable:

Code: Select all

/usr/bin/jackd -P89 -t5000 -dalsa -r96000 -p64 -n3 -D -Chw:Intel,0 -Phw:Intel,0


2 ms for it. However, still troubles with USB soundcard, as a lot of xruns comes if I lower the Frames/Period. I'll keep on searching why, In order to solve this last issue. Any suggestion is welcome!
Check my Linux audio experiments on my SoundCloud.
Fancying a swim in the pond?


Return to “HOW TOs, Tips & Tricks”

Who is online

Users browsing this forum: No registered users and 1 guest