Improve performance and reduce latency

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

steinwayer
Established Member
Posts: 18
Joined: Fri Oct 12, 2018 11:25 pm

Re: Improve performance and reduce latency

Post by steinwayer »

CrocoDuck wrote:
steinwayer wrote: First of all, thanks SOOO MUCH for all the help and effort you are putting into helping me find the perfect config.
It is actually a good thing to rehearse this stuff. I was lagging behind not having done this for a while.
steinwayer wrote:So, as far as the KX Studio repos go, you should know that, at least in my case (tried with several distros as well) the kx studio repos tend to break the entire os generating conflicts of versions, so when i can, i always avoid adding repos to my distro.
Uhm... that's not supposed to happen.
steinwayer wrote:Don't get me wrong, i already like the configuration i have, i can record without efforts multiple tracks even utilizing heavy samplers like Kontakt. It's just that I am trying to dig deep into linux audio configuration in order to demonstrate that it's actually possible to achieve mac/win level latency and recording setup also on Linux. And i still think it's possible.
Yes it is. I think in this case though measurements are better suited. For example, due to how Mac OS works, normally working at sample rate Fs and buffer size Bs results in additional latency of maybe 30 samples with respect Linux. This is due to how Core Audio works.

Probably the best way to compare OS performance is set up various configurations of sample rate a buffer size, measure latency, and then measure stability somehow, as a function of load. That would be a huge task, though. It would be very interesting to do, though.
steinwayer wrote:I think that must be an issue of some sort with jack (or maybe with the way jack interacts with alsa settings) i tried uninstalling jackd2 in favor of jackd1 just as a test, but apparently if i do that, apt-get wants to remove also bitwig and a bunch of stuff that i actually need , so that's not happening
Not sure whether we should expect an issue. I think it is most likely just the additional overhead of JACK. In this case, slimming down your system by using a light weight window manager, like Open Box, and possibly disabling not needed services can help. Switching to from XFCE to LXDE few years ago made a huge difference for me. This is another path you can go first if you don't want to test a rt kernel.
steinwayer wrote:Ideally, if i could find the deb files to just install in the distro and try how it works, it would be much better.
Not sure where to find RT kernels for Ubuntu. Maybe someone else can fill this gap.
uhm, i tried doing that too, without any good results. The thing is that I am having the same results on audio aimed distributions like ubuntu studio (which by default, runs xfce). What is strange is that the JACK developers, claim on their website that Jack does not add any latency WHATSOEVER , just a little more processing on the cpu, less than 1% as they say.
User avatar
sysrqer
Established Member
Posts: 2519
Joined: Thu Nov 14, 2013 11:47 pm
Has thanked: 319 times
Been thanked: 148 times
Contact:

Re: Improve performance and reduce latency

Post by sysrqer »

You mention that you have tried audio aimed distros but do you mean you have installed them or tried in a live environment? I would suggest trying something like AVlinux in a live environment (because it is set up and ready to go, you can test without installing anything or turning on wifi etc) and see if the results are any different, although I'm not sure how much running off USB would affect latency.

How about turning off networking, does that change the number of xruns?

Have you checked which services are running?

Do you have the Plasma indexer, baloo, enabled?

These are a bit of a stab in the dark but it sounds like there is a problem realtime priorities or your computer doing something at the same time as jack trying to do what it does.
CrocoDuck
Established Member
Posts: 1133
Joined: Sat May 05, 2012 6:12 pm
Been thanked: 17 times

Re: Improve performance and reduce latency

Post by CrocoDuck »

steinwayer wrote:I think that must be an issue of some sort with jack (or maybe with the way jack interacts with alsa settings) i tried uninstalling jackd2 in favor of jackd1 just as a test, but apparently if i do that, apt-get wants to remove also bitwig and a bunch of stuff that i actually need , so that's not happening.
I am not too sure about this. Beside the various parameters, there is very little to JACK configuration. You cannot dictate "how" it interacts with ALSA, to the best of my knowledge. The interaction is really as straightforward as it can be. In my experience, stability issues always boiled down to something unwanted stealing CPU time.

You might want to read more info about it:

https://wiki.archlinux.org/index.php/Pr ... audio#JACK
https://wiki.linuxaudio.org/wiki/system ... _processes
steinwayer
Established Member
Posts: 18
Joined: Fri Oct 12, 2018 11:25 pm

Re: Improve performance and reduce latency

Post by steinwayer »

CrocoDuck wrote:
steinwayer wrote:I think that must be an issue of some sort with jack (or maybe with the way jack interacts with alsa settings) i tried uninstalling jackd2 in favor of jackd1 just as a test, but apparently if i do that, apt-get wants to remove also bitwig and a bunch of stuff that i actually need , so that's not happening.
I am not too sure about this. Beside the various parameters, there is very little to JACK configuration. You cannot dictate "how" it interacts with ALSA, to the best of my knowledge. The interaction is really as straightforward as it can be. In my experience, stability issues always boiled down to something unwanted stealing CPU time.

You might want to read more info about it:

https://wiki.archlinux.org/index.php/Pr ... audio#JACK
https://wiki.linuxaudio.org/wiki/system ... _processes
I found this... It's old but... What's that "VERY IMPORTANT" mixer option he talks about? He says that cannot jack cannot play nicely with intel hda without that enabled... How do I enable that???

Rsysger in respobse to your question, i did try em both installed and live .i wanted to try avlinux, but the iso i download and burn, does not boot and do not know the reason why :///
CrocoDuck
Established Member
Posts: 1133
Joined: Sat May 05, 2012 6:12 pm
Been thanked: 17 times

Re: Improve performance and reduce latency

Post by CrocoDuck »

steinwayer wrote:I found this... It's old but... What's that "VERY IMPORTANT" mixer option he talks about? He says that cannot jack cannot play nicely with intel hda without that enabled... How do I enable that???
Sorry I do not understand what you are referring to. Where did you find the reference? Is in the links I shared above?
steinwayer
Established Member
Posts: 18
Joined: Fri Oct 12, 2018 11:25 pm

Re: Improve performance and reduce latency

Post by steinwayer »

CrocoDuck wrote:
steinwayer wrote:I found this... It's old but... What's that "VERY IMPORTANT" mixer option he talks about? He says that cannot jack cannot play nicely with intel hda without that enabled... How do I enable that???
Sorry I do not understand what you are referring to. Where did you find the reference? Is in the links I shared above?
Ahah my bad forgot to share the link
Here it is:

https://wiki.linuxaudio.org/wiki/intel_ ... time_howto
CrocoDuck
Established Member
Posts: 1133
Joined: Sat May 05, 2012 6:12 pm
Been thanked: 17 times

Re: Improve performance and reduce latency

Post by CrocoDuck »

steinwayer wrote:Ahah my bad forgot to share the link
Here it is:

https://wiki.linuxaudio.org/wiki/intel_ ... time_howto
That's interesting. I did not know anything about that. You are right, the article is quite old (2014 last update, references to 2.6.X kernel era), not sure how relevant that will be anymore. I think you can use alsamixer to check that the elements are enabled:

Code: Select all

alsamixer
It will open up an interface which should be quite self explanatory. Make sure everything is enabled in your card.
CrocoDuck
Established Member
Posts: 1133
Joined: Sat May 05, 2012 6:12 pm
Been thanked: 17 times

Re: Improve performance and reduce latency

Post by CrocoDuck »

That also ringed some bells about the video card setting though. Is the card you are using a chip within your videocard? Can you repost the output of:

Code: Select all

lspci -vnn
steinwayer
Established Member
Posts: 18
Joined: Fri Oct 12, 2018 11:25 pm

Re: Improve performance and reduce latency

Post by steinwayer »

CrocoDuck wrote:That also ringed some bells about the video card setting though. Is the card you are using a chip within your videocard? Can you repost the output of:

Code: Select all

lspci -vnn
here is the output of lspci -vnn

Code: Select all

00:00.0 Host bridge [0600]: Intel Corporation Device [8086:3ec4] (rev 07)
        Subsystem: Dell Device [1028:0825]
        Flags: bus master, fast devsel, latency 0
        Capabilities: <access denied>

00:01.0 PCI bridge [0604]: Intel Corporation Skylake PCIe Controller (x16) [8086:1901] (rev 07) (prog-if 00 [Normal decode])
        Flags: bus master, fast devsel, latency 0, IRQ 16
        Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
        I/O behind bridge: 00004000-00004fff
        Memory behind bridge: ec000000-ed0fffff
        Prefetchable memory behind bridge: 00000000c0000000-00000000d1ffffff
        Capabilities: <access denied>
        Kernel driver in use: pcieport
        Kernel modules: shpchp

00:02.0 VGA compatible controller [0300]: Intel Corporation Device [8086:3e9b] (prog-if 00 [VGA controller])
        Subsystem: Dell Device [1028:0825]
        Flags: bus master, fast devsel, latency 0, IRQ 126
        Memory at eb000000 (64-bit, non-prefetchable) [size=16M]
        Memory at 80000000 (64-bit, prefetchable) [size=256M]
        I/O ports at 5000 [size=64]
        [virtual] Expansion ROM at 000c0000 [disabled] [size=128K]
        Capabilities: <access denied>
        Kernel driver in use: i915
        Kernel modules: i915

00:04.0 Signal processing controller [1180]: Intel Corporation Skylake Processor Thermal Subsystem [8086:1903] (rev 07)
        Subsystem: Dell Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Thermal Subsystem [1028:0825]
        Flags: fast devsel, IRQ 16
        Memory at ed398000 (64-bit, non-prefetchable) [size=32K]
        Capabilities: <access denied>
        Kernel driver in use: proc_thermal
        Kernel modules: processor_thermal_device

00:08.0 System peripheral [0880]: Intel Corporation Skylake Gaussian Mixture Model [8086:1911]
        Subsystem: Dell Xeon E3-1200 v5/v6 / E3-1500 v5 / 6th/7th Gen Core Processor Gaussian Mixture Model [1028:0825]
        Flags: fast devsel, IRQ 255
        Memory at ed3b1000 (64-bit, non-prefetchable) [disabled] [size=4K]
        Capabilities: <access denied>

00:12.0 Signal processing controller [1180]: Intel Corporation Device [8086:a379] (rev 10)
        Subsystem: Dell Device [1028:0825]
        Flags: fast devsel, IRQ 16
        Memory at ed3b0000 (64-bit, non-prefetchable) [size=4K]
        Capabilities: <access denied>
        Kernel driver in use: intel_pch_thermal
        Kernel modules: intel_pch_thermal

00:14.0 USB controller [0c03]: Intel Corporation Device [8086:a36d] (rev 10) (prog-if 30 [XHCI])
        Subsystem: Dell Device [1028:0825]
        Flags: bus master, medium devsel, latency 0, IRQ 124
        Memory at ed380000 (64-bit, non-prefetchable) [size=64K]
        Capabilities: <access denied>
        Kernel driver in use: xhci_hcd

00:14.2 RAM memory [0500]: Intel Corporation Device [8086:a36f] (rev 10)
        Subsystem: Dell Device [1028:0825]
        Flags: fast devsel
        Memory at ed3a8000 (64-bit, non-prefetchable) [disabled] [size=8K]
        Memory at ed3af000 (64-bit, non-prefetchable) [disabled] [size=4K]
        Capabilities: <access denied>

00:14.3 Network controller [0280]: Intel Corporation Device [8086:a370] (rev 10)
        Subsystem: Intel Corporation Device [8086:4030]
        Flags: bus master, fast devsel, latency 0, IRQ 16
        Memory at ed3a4000 (64-bit, non-prefetchable) [size=16K]
        Capabilities: <access denied>
        Kernel driver in use: iwlwifi
        Kernel modules: iwlwifi

00:15.0 Serial bus controller [0c80]: Intel Corporation Device [8086:a368] (rev 10)
        Subsystem: Dell Device [1028:0825]
        Flags: bus master, fast devsel, latency 0, IRQ 16
        Memory at 7e800000 (64-bit, non-prefetchable) [size=4K]
        Capabilities: <access denied>
        Kernel driver in use: intel-lpss
        Kernel modules: intel_lpss_pci

00:15.1 Serial bus controller [0c80]: Intel Corporation Device [8086:a369] (rev 10)
        Subsystem: Dell Device [1028:0825]
        Flags: bus master, fast devsel, latency 0, IRQ 17
        Memory at 7e801000 (64-bit, non-prefetchable) [size=4K]
        Capabilities: <access denied>
        Kernel driver in use: intel-lpss
        Kernel modules: intel_lpss_pci

00:16.0 Communication controller [0780]: Intel Corporation Device [8086:a360] (rev 10)
        Subsystem: Dell Device [1028:0825]
        Flags: bus master, fast devsel, latency 0, IRQ 127
        Memory at ed3ac000 (64-bit, non-prefetchable) [size=4K]
        Capabilities: <access denied>
        Kernel driver in use: mei_me
        Kernel modules: mei_me

00:17.0 RAID bus controller [0104]: Intel Corporation 82801 Mobile SATA Controller [RAID mode] [8086:282a] (rev 10)
        Subsystem: Dell 82801 Mobile SATA Controller [RAID mode] [1028:0825]
        Flags: bus master, 66MHz, medium devsel, latency 0, IRQ 16
        Memory at ed390000 (32-bit, non-prefetchable) [size=32K]
        Memory at ed3ab000 (32-bit, non-prefetchable) [size=256]
        I/O ports at 5090 [size=8]
        I/O ports at 5080 [size=4]
        I/O ports at 5060 [size=32]
        Memory at ed300000 (32-bit, non-prefetchable) [size=512K]
        Capabilities: <access denied>
        Kernel driver in use: ahci
        Kernel modules: ahci

00:1b.0 PCI bridge [0604]: Intel Corporation Device [8086:a32c] (rev f0) (prog-if 00 [Normal decode])
        Flags: bus master, fast devsel, latency 0, IRQ 122
        Bus: primary=00, secondary=02, subordinate=3a, sec-latency=0
        I/O behind bridge: 00006000-00006fff
        Memory behind bridge: d4000000-ea0fffff
        Prefetchable memory behind bridge: 0000000090000000-00000000b1ffffff
        Capabilities: <access denied>
        Kernel driver in use: pcieport
        Kernel modules: shpchp

00:1d.0 PCI bridge [0604]: Intel Corporation Device [8086:a335] (rev f0) (prog-if 00 [Normal decode])
        Flags: bus master, fast devsel, latency 0, IRQ 123
        Bus: primary=00, secondary=3b, subordinate=3b, sec-latency=0
        I/O behind bridge: 00003000-00003fff
        Memory behind bridge: ed200000-ed2fffff
        Capabilities: <access denied>
        Kernel driver in use: pcieport
        Kernel modules: shpchp

00:1f.0 ISA bridge [0601]: Intel Corporation Device [8086:a30d] (rev 10)
        Subsystem: Dell Device [1028:0825]
        Flags: bus master, fast devsel, latency 0

00:1f.3 Audio device [0403]: Intel Corporation Device [8086:a348] (rev 10)
        Subsystem: Dell Device [1028:0825]
        Flags: bus master, fast devsel, latency 32, IRQ 142
        Memory at ed3a0000 (64-bit, non-prefetchable) [size=16K]
        Memory at ed100000 (64-bit, non-prefetchable) [size=1M]
        Capabilities: <access denied>
        Kernel driver in use: snd_hda_intel
        Kernel modules: snd_hda_intel

00:1f.4 SMBus [0c05]: Intel Corporation Device [8086:a323] (rev 10)
        Subsystem: Dell Device [1028:0825]
        Flags: medium devsel, IRQ 255
        Memory at ed3aa000 (64-bit, non-prefetchable) [size=256]
        I/O ports at efa0 [size=32]
        Kernel modules: i2c_i801

00:1f.5 Serial bus controller [0c80]: Intel Corporation Device [8086:a324] (rev 10)
        Subsystem: Dell Device [1028:0825]
        Flags: fast devsel
        Memory at fe010000 (32-bit, non-prefetchable) [size=4K]

01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP106M [GeForce GTX 1060 Mobile] [10de:1c20] (rev a1) (prog-if 00 [VGA controller])
        Flags: bus master, fast devsel, latency 0, IRQ 255
        Memory at ec000000 (32-bit, non-prefetchable) [size=16M]
        Memory at c0000000 (64-bit, prefetchable) [size=256M]
        Memory at d0000000 (64-bit, prefetchable) [size=32M]
        I/O ports at 4000 [disabled] [size=128]
        [virtual] Expansion ROM at ed000000 [disabled] [size=512K]
        Capabilities: <access denied>
        Kernel modules: nvidiafb, nouveau, nvidia_drm, nvidia

3b:00.0 Ethernet controller [0200]: Qualcomm Atheros Killer E2400 Gigabit Ethernet Controller [1969:e0a1] (rev 10)
        Subsystem: Dell Killer E2400 Gigabit Ethernet Controller [1028:0825]
        Flags: bus master, fast devsel, latency 0, IRQ 17
        Memory at ed200000 (64-bit, non-prefetchable) [size=256K]
        I/O ports at 3000 [size=128]
        Capabilities: <access denied>
        Kernel driver in use: alx
        Kernel modules: alx
as far as the alsamixer goes, i tried, but i didn't find any "capture" option :/
CrocoDuck
Established Member
Posts: 1133
Joined: Sat May 05, 2012 6:12 pm
Been thanked: 17 times

Re: Improve performance and reduce latency

Post by CrocoDuck »

steinwayer wrote:as far as the alsamixer goes, i tried, but i didn't find any "capture" option :/
I have one if I make sure I select the correct card with F6, and then press F4 to look at Capture devices:

Image

I am not sure whether that is the capture the page talks about, but it is the only bell that it rings for now.
steinwayer wrote:here is the output of lspci -vnn
Uhm... I have seen in the past things going a bit unstable with Nvidea cards. Seems to me that you have nouveau installed. Normally things go a bit quirky with the Nvidia proprietary drivers and RT kernels, but it could be worth to disable your drivers and just boot with the generic ones, just for testing purposes.

I think we could also try to fiddle with ALSA options for your codec (ALC3246), but for that I would like to ask what computer you are using also. Is it a Dell XPS13? Also, did you already try to edit the options? Post

Code: Select all

cat /etc/modprobe.d/alsa-base.conf
steinwayer
Established Member
Posts: 18
Joined: Fri Oct 12, 2018 11:25 pm

Re: Improve performance and reduce latency

Post by steinwayer »

CrocoDuck wrote:
steinwayer wrote:as far as the alsamixer goes, i tried, but i didn't find any "capture" option :/
I have one if I make sure I select the correct card with F6, and then press F4 to look at Capture devices:

Image

I am not sure whether that is the capture the page talks about, but it is the only bell that it rings for now.
steinwayer wrote:here is the output of lspci -vnn
Uhm... I have seen in the past things going a bit unstable with Nvidea cards. Seems to me that you have nouveau installed. Normally things go a bit quirky with the Nvidia proprietary drivers and RT kernels, but it could be worth to disable your drivers and just boot with the generic ones, just for testing purposes.

I think we could also try to fiddle with ALSA options for your codec (ALC3246), but for that I would like to ask what computer you are using also. Is it a Dell XPS13? Also, did you already try to edit the options? Post

Code: Select all

cat /etc/modprobe.d/alsa-base.conf
My laptop is a Dell G7. Very powerful machine as far as specs goes. Uhm i didn't try selecting the sound card with f6, i will try as soon as i get home and post as well the output of cat /etc/modprobe.d/alsa-base.conf

I am not running nouveau drivers right now, but the proprietary ones "when" i enable the nvidia graphics card. The thing is my laptop is an optimus laptop, which means it has 2 videocards, the intel one and the geforce one. With Kubuntu i can switch between the two cards from the prime profiles in the proprietary drivers (sadly this option is not enabled for other distributions, if you are not running ubuntu and have an optimus laptop, there a few tricks you can implement but none is equal in resulst to the canonical implementation.. at least so far. Which is a shame, since I am not an Ubuntu user, used Debian since the first years of 2000...)

Anyway, right now i am running the intel card, the nvidia one is temporairly disabled. I tried also running only the nvidia one and have the intel off, but nothing changes.
CrocoDuck
Established Member
Posts: 1133
Joined: Sat May 05, 2012 6:12 pm
Been thanked: 17 times

Re: Improve performance and reduce latency

Post by CrocoDuck »

steinwayer wrote:The thing is my laptop is an optimus laptop,
OK. I am not sure what is the state of support of NVIDIA Optimus with realtime kernels. Chances are you might be stuck with the intel card if you try to use linux-rt. But I am not sure about this.

Anyway, I would like to see what kernel modules are loaded while you run your laptop on the intel:

Code: Select all

lsmod
steinwayer
Established Member
Posts: 18
Joined: Fri Oct 12, 2018 11:25 pm

Re: Improve performance and reduce latency

Post by steinwayer »

CrocoDuck wrote:
steinwayer wrote:The thing is my laptop is an optimus laptop,
OK. I am not sure what is the state of support of NVIDIA Optimus with realtime kernels. Chances are you might be stuck with the intel card if you try to use linux-rt. But I am not sure about this.

Anyway, I would like to see what kernel modules are loaded while you run your laptop on the intel:

Code: Select all

lsmod
here is the output of cat /etc/modprobe.d/alsa-base.conf:

Code: Select all

# autoloader aliases
install sound-slot-0 /sbin/modprobe snd-card-0
install sound-slot-1 /sbin/modprobe snd-card-1
install sound-slot-2 /sbin/modprobe snd-card-2
install sound-slot-3 /sbin/modprobe snd-card-3
install sound-slot-4 /sbin/modprobe snd-card-4
install sound-slot-5 /sbin/modprobe snd-card-5
install sound-slot-6 /sbin/modprobe snd-card-6
install sound-slot-7 /sbin/modprobe snd-card-7

# Cause optional modules to be loaded above generic modules
install snd /sbin/modprobe --ignore-install snd $CMDLINE_OPTS && { /sbin/modprobe --quiet --use-blacklist snd-ioctl32 ; /sbin/modprobe --quiet --use-blacklist snd-seq ; }
#
# Workaround at bug #499695 (reverted in Ubuntu see LP #319505)
install snd-pcm /sbin/modprobe --ignore-install snd-pcm $CMDLINE_OPTS && { /sbin/modprobe --quiet --use-blacklist snd-pcm-oss ; : ; }
install snd-mixer /sbin/modprobe --ignore-install snd-mixer $CMDLINE_OPTS && { /sbin/modprobe --quiet --use-blacklist snd-mixer-oss ; : ; }
install snd-seq /sbin/modprobe --ignore-install snd-seq $CMDLINE_OPTS && { /sbin/modprobe --quiet --use-blacklist snd-seq-midi ; /sbin/modprobe --quiet --use-blacklist snd-seq-oss ; : ; }
#
install snd-rawmidi /sbin/modprobe --ignore-install snd-rawmidi $CMDLINE_OPTS && { /sbin/modprobe --quiet --use-blacklist snd-seq-midi ; : ; }
# Cause optional modules to be loaded above sound card driver modules
install snd-emu10k1 /sbin/modprobe --ignore-install snd-emu10k1 $CMDLINE_OPTS && { /sbin/modprobe --quiet --use-blacklist snd-emu10k1-synth ; }
install snd-via82xx /sbin/modprobe --ignore-install snd-via82xx $CMDLINE_OPTS && { /sbin/modprobe --quiet --use-blacklist snd-seq ; }

# Load saa7134-alsa instead of saa7134 (which gets dragged in by it anyway)
install saa7134 /sbin/modprobe --ignore-install saa7134 $CMDLINE_OPTS && { /sbin/modprobe --quiet --use-blacklist saa7134-alsa ; : ; }
# Prevent abnormal drivers from grabbing index 0
options bt87x index=-2
options cx88_alsa index=-2
options saa7134-alsa index=-2
options snd-atiixp-modem index=-2
options snd-intel8x0m index=-2
options snd-via82xx-modem index=-2
options snd-usb-audio index=-2
options snd-usb-caiaq index=-2
options snd-usb-ua101 index=-2
options snd-usb-us122l index=-2
options snd-usb-usx2y index=-2
# Ubuntu #62691, enable MPU for snd-cmipci
options snd-cmipci mpu_port=0x330 fm_port=0x388
# Keep snd-pcsp from being loaded as first soundcard
options snd-pcsp index=-2
# Keep snd-usb-audio from beeing loaded as first soundcard
options snd-usb-audio index=-2
and here is the output of lsmod:

Code: Select all

Module                  Size  Used by
ccm                    20480  6
pci_stub               16384  1
vboxpci                24576  0
vboxnetadp             28672  0
vboxnetflt             28672  0
vboxdrv               471040  3 vboxpci,vboxnetadp,vboxnetflt
rfcomm                 77824  16
cmac                   16384  0
bnep                   20480  2
nls_iso8859_1          16384  1
arc4                   16384  2
snd_hda_codec_hdmi     49152  1
iwlmvm                364544  0
snd_hda_codec_realtek   106496  1
mac80211              778240  1 iwlmvm
snd_hda_codec_generic    73728  1 snd_hda_codec_realtek
hid_multitouch         20480  0
intel_rapl             20480  0
x86_pkg_temp_thermal    16384  0
intel_powerclamp       16384  0
snd_hda_intel          40960  3
uvcvideo               86016  0
coretemp               16384  0
dell_wmi               16384  0
dell_smbios_wmi        16384  0
videobuf2_vmalloc      16384  1 uvcvideo
kvm_intel             212992  0
wmi_bmof               16384  0
dell_laptop            20480  1
mxm_wmi                16384  0
snd_hda_codec         126976  4 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec_realtek
videobuf2_memops       16384  1 videobuf2_vmalloc
dell_wmi_descriptor    16384  2 dell_wmi,dell_smbios_wmi
intel_wmi_thunderbolt    16384  0
dell_smbios_smm        16384  0
kvm                   598016  1 kvm_intel
videobuf2_v4l2         24576  1 uvcvideo
irqbypass              16384  1 kvm
snd_hda_core           81920  5 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,snd_hda_codec_realtek
videobuf2_core         40960  2 videobuf2_v4l2,uvcvideo
dell_smbios            16384  4 dell_wmi,dell_laptop,dell_smbios_wmi,dell_smbios_smm
btusb                  45056  0
crct10dif_pclmul       16384  0
dcdbas                 16384  1 dell_smbios_smm
btrtl                  16384  1 btusb
videodev              184320  3 videobuf2_core,videobuf2_v4l2,uvcvideo
crc32_pclmul           16384  0
btbcm                  16384  1 btusb
ghash_clmulni_intel    16384  0
snd_hwdep              20480  1 snd_hda_codec
pcbc                   16384  0
btintel                16384  1 btusb
snd_pcm                98304  4 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,snd_hda_core
media                  40960  2 videodev,uvcvideo
bluetooth             548864  43 btrtl,btintel,btbcm,bnep,btusb,rfcomm
snd_seq_midi           16384  0
snd_seq_midi_event     16384  1 snd_seq_midi
aesni_intel           188416  4
snd_rawmidi            32768  1 snd_seq_midi
ecdh_generic           24576  1 bluetooth
aes_x86_64             20480  1 aesni_intel
crypto_simd            16384  1 aesni_intel
glue_helper            16384  1 aesni_intel
cryptd                 24576  3 crypto_simd,ghash_clmulni_intel,aesni_intel
snd_seq                65536  2 snd_seq_midi,snd_seq_midi_event
intel_cstate           20480  0
intel_rapl_perf        16384  0
snd_seq_device         16384  3 snd_seq,snd_seq_midi,snd_rawmidi
iwlwifi               282624  1 iwlmvm
snd_timer              32768  2 snd_seq,snd_pcm
joydev                 24576  0
input_leds             16384  0
idma64                 20480  0
virt_dma               16384  1 idma64
serio_raw              16384  0
snd                    81920  17 snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_hda_codec,snd_hda_codec_realtek,snd_timer,snd_pcm,snd_rawmidi
cfg80211              622592  3 iwlmvm,iwlwifi,mac80211
intel_lpss_pci         20480  0
mei_me                 40960  0
mei                    90112  1 mei_me
soundcore              16384  1 snd
intel_lpss             16384  1 intel_lpss_pci
processor_thermal_device    16384  0
int3403_thermal        16384  0
int340x_thermal_zone    16384  2 int3403_thermal,processor_thermal_device
intel_soc_dts_iosf     16384  1 processor_thermal_device
shpchp                 36864  0
intel_hid              16384  0
intel_pch_thermal      16384  0
sparse_keymap          16384  2 intel_hid,dell_wmi
int3400_thermal        16384  0
wmi                    24576  6 intel_wmi_thunderbolt,dell_wmi,wmi_bmof,dell_wmi_descriptor,dell_smbios_wmi,mxm_wmi
acpi_pad              180224  0
acpi_thermal_rel       16384  1 int3400_thermal
mac_hid                16384  0
sch_fq_codel           20480  9
parport_pc             36864  0
ppdev                  20480  0
lp                     20480  0
parport                49152  3 parport_pc,lp,ppdev
ip_tables              28672  0
x_tables               40960  1 ip_tables
autofs4                40960  2
i915                 1617920  35
i2c_algo_bit           16384  1 i915
drm_kms_helper        172032  1 i915
syscopyarea            16384  1 drm_kms_helper
sysfillrect            16384  1 drm_kms_helper
sysimgblt              16384  1 drm_kms_helper
fb_sys_fops            16384  1 drm_kms_helper
i2c_hid                20480  0
ahci                   36864  3
alx                    49152  0
psmouse               147456  0
drm                   401408  11 drm_kms_helper,i915
mdio                   16384  1 alx
libahci                32768  1 ahci
hid                   118784  2 i2c_hid,hid_multitouch
video                  45056  3 dell_wmi,dell_laptop,i915
i did look into the settings of alsamixer, and found capture, mine is set to 40, so looks like it is enabled..
CrocoDuck
Established Member
Posts: 1133
Joined: Sat May 05, 2012 6:12 pm
Been thanked: 17 times

Re: Improve performance and reduce latency

Post by CrocoDuck »

steinwayer wrote:here is the output of cat /etc/modprobe.d/alsa-base.conf:
Oh wow. Ubuntu devs do really like defaults. On Arch there is no default conf. I don't see anything worrisome, though. I have been searching for special options for your codec here, but none are reported. Maybe we can try some of the dell options. If for example you want to try the dell-laptop option (although that is supposed to be for conexant chips) do:

Code: Select all

sudo gedit /etc/modprobe.d/alsa-base.conf
And append this at the bottom:

Code: Select all

options snd-hda-intel model=dell-laptop 
Maybe worth a trial and error of few options. If none work, just remove that line from the file. In theory we could also try some options for the various ALC codecs, even though there isn't one specifically for the ALC3246. Maybe the most similar in terms of codec properties. Not sure which one that would be though.
steinwayer wrote:and here is the output of lsmod:
OK, that looks alright. I don't see the "dodgy" (not really dodgy nowadays I think) video card drivers loaded. Just one thing: there are few device drivers loaded. According to your lspci your device is being driven by snd_hda_intel, which is indeed loaded, by there are two more in there:

Code: Select all

snd_hda_codec_hdmi
snd_hda_codec_realtek
Now, I don't think this should be an issue, but I remember few cases of conflicts between on board audio and external audio devices. The solution was to disable the onboard drivers. Here we can try to see if anything at all improves if we briefly disable those two guys above. This should do:

Code: Select all

modprobe -r snd_hda_codec_hdmi
That probably needs sudo. Run it and do some test. After tests, you could load it back with

Code: Select all

modprobe snd_hda_codec_hdmi
But a reboot will also do.

Then, after reload/reboot, do the same with the other module:

Code: Select all

modprobe -r snd_hda_codec_realtek
Do some tests. This might actually make your audio card unavailable, as it is, indeed, a Realtek. So, if you have no audio after unloading that module, we know we have to keep it in.

If you still had audio after unloading the realtek module, Then reload/reboot, and test with both of them out of the way:

Code: Select all

modprobe -r snd_hda_codec_hdmi
modprobe -r snd_hda_codec_realtek
Do some tests.

I have been loading/unloading modules countless times in my machines, so I am pretty confident that there will be no permanent effects to the commands above. The Arch wiki says nothing against manual module handling. If things go quirky just reboot.

I am not entirely confident any of the above will do anything, but perhaps worth a shot. I would maybe try the modules first. If one of the modules make your system audio unstable, then we can blacklist it to prevent it from automatically loading.

Good luck.
asbak
Established Member
Posts: 897
Joined: Thu Sep 11, 2014 3:04 pm
Has thanked: 71 times
Been thanked: 64 times

Re: Improve performance and reduce latency

Post by asbak »

So, after doing several tests, my resultst are as follows:

I can play with a "decently" low latency with 256 samples at 2 periods/buffer, but i still get occasional xruns (especially when i play a good amount of notes together with my midi controller) . If i try setting it at 128 samples, xruns are going insane, even when i don't play anything and when i put 64, they just go by the hundreds in a matter of seconds , since the moment i start jack, without even opening the daw.

I tried a few tweaks and workarounds found online ( like editing the file /etc/security/limits.conf by adding the rtprio set to 99 etc) but none worked.
You shouldn't be experiencing issues at 128 samples. A properly functioning Linux audio system with a reasonable soundcard should be working fine at that samplerate. Some cards will be trouble free even at 64 samples. (The occasional xrun perhaps but that's usually due to patch changes, connecting more softsynths, messing with a web browser etc.)


It all starts with having a decent low-latency capable audio interface that works well under Linux.
Without that it'll be like trying to smear lipstick on a pig.

In practice (what works for me) that means something like an EMU 0404, Behringer UMC series cards, certain Edirol models like UA-25 (this one isn't super low latency but works OK), some of the Focusrite cards, some of the NI cards etc etc. Typically a class compliant USB interface should work.

With the hardware selection out of the way next stop is the kernel. It needs to be at least a pre-empt kernel and don't let any clowns tell you differently. There are loads of posters on forums such as this who confuse getting sound out of their soundcards with good low-latency performance.

I wouldn't bother with a RT kernel, too much hassle & I couldn't detect a performance gain aka "reduction in xruns" with it but perhaps others can. Whatever the case, RT caused me more problems than it was worth. Without at least a pre-empt kernel you're going to be SOL with regards to minimising xruns. You could try a pre-packaged low-latency kernel. I compiled my own 1000Hz one and it works great for audio & general purpose usage.

It is recommended to set the kernel to performance as opposed to powersave when doing audio work. I don't usually bother and have not had significant issues but setting it to performance may be helpful so its worth considering.

Next stop - videodrivers. The Intel video drivers work OK out of the box. In the past I've had big problems (read xruns) with Nouveau Nvidia drivers and ditched them for the proprietary drivers. Performance improved (meaning xruns decreased significantly).
AMD - not sure. Just be aware that video drivers can mess with results.

Wireless drivers / wireless can cause issues but generally speaking it doesn't seem to cause problems on my T430.
Web Browsers can cause xruns, generally speaking it doesn't seem to cause problems on my T430.

USB Ports. Whilst in some cases one can get away with using a USB hub (my UA-25 worked fine in a hub) other cards will definitely stutter and fail, for example my Behringer UMC. Use a USB port on the motherboard, avoid USB hubs.

Integrated MIDI ports. I've only seen this happen on a RME 9652 but be aware that drivers can be buggy and when controlling softsynths via integrated MIDI on certain soundcards (RME 9652) can cause xruns. I've not had this happen with any other card so it must be an issue with that particular card.


Next are system settings & tuning, without that you're always going to run into problems.
- Find background scheduled jobs & processes and set these up to either complete after boot (so you have to give it time) or disable them when doing audio, because they can hog I/O and cause xruns.

- Pulseaudio, I kill it when using jack. Yes it's possible to combine it but I kill it anyway.
- jackdbus, I never liked it and it was forever causing weird audio lockups on my systems. To get rid of it I compiled jackdmp without jackdbus. Life is better this way.

- Audio settings, you need to set up something like the following

#Add audio group
groupadd audio

#Add your user account to the audio group

#Fix the limits.conf files in /etc/security
/etc/security/limits.conf

Add this to the bottom, <username> is the name of your local account.

Code: Select all

@audio - rtprio 90
@audio - memlock unlimited
<username>        soft    nofile           100000
<username>        hard    nofile           100000
/etc/security/limits.d/audio.conf

Code: Select all

@audio   -  memlock    unlimited
@audio   -  rtprio     90
Add this line to /etc/pam.d/common-session

Code: Select all

session required pam_limits.so

# Starting Jack
In Qjackctl you need to ensure that you tick Realtime, Frames could be 64 or 128 (depending on how well the card works, some just won't work well at those latencies)
Periods are usually 3 for USB.
Server Prefix use jackd -S
Priority, set that to +- 90

Final note, Windows VST's under Wine. Performance generally isn't all that great with these and the chances of crashes increase. Yes people here will passionately brag about how great it works for them with this or that VST host but it's a can of worms. It's fine for marvelling at that it actually can be done, and it doesn't matter in a studio setting where if things crash it's no big deal. But it's way too unreliable for live usage unless you wanted to make a fool of yourself on stage. Avoid Windows VST's would be my advice. Run them on a Windows machine, not Linux, for any serious kind of work.


There are a bunch of other things that can be tried and tested but these steps will get you a baseline low-latency capable audio subsystem on Linux.
Some Focal / 20.04 audio packages and resources https://midistudio.groups.io/g/linuxaudio
Post Reply