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:
khz wrote:rtirq-init is automatically started as a service at system startup.
The command should rather be

Code: Select all

/etc/init.d/rtirq status
Yes, that's how it works on Ubuntu.
steinwayer wrote:I tried installing rtirq, but the command you gave me does not work. I installed form the official repos, it's called rtirq-init, after i install it and reboot, i dont' seem to find a command to launch it.

Any suggestions?
Try the command above.
Gotcha :)
Here is the output of the command:
PID CLS RTPRIO NI PRI %CPU STAT COMMAND
685 FF 79 - 119 0.0 S irq/128-mei_me
688 FF 78 - 118 0.0 S irq/129-iwlwifi
689 FF 77 - 117 0.0 S irq/130-iwlwifi
690 FF 76 - 116 0.0 S irq/131-iwlwifi
691 FF 75 - 115 0.0 S irq/132-iwlwifi
692 FF 74 - 114 0.0 S irq/133-iwlwifi
694 FF 73 - 113 0.0 S irq/134-iwlwifi
695 FF 72 - 112 0.0 S irq/135-iwlwifi
696 FF 71 - 111 0.0 S irq/136-iwlwifi
697 FF 70 - 110 0.0 S irq/137-iwlwifi
698 FF 69 - 109 0.0 S irq/138-iwlwifi
699 FF 68 - 108 0.0 S irq/139-iwlwifi
700 FF 67 - 107 0.0 S irq/140-iwlwifi
702 FF 66 - 106 0.0 S irq/141-iwlwifi
704 FF 65 - 105 0.0 S irq/142-iwlwifi
663 FF 50 - 90 0.4 S irq/51-DELL0825
7 TS - 0 19 0.0 S ksoftirqd/0
16 TS - 0 19 0.0 S ksoftirqd/1
22 TS - 0 19 0.0 S ksoftirqd/2
28 TS - 0 19 0.0 S ksoftirqd/3
34 TS - 0 19 0.0 S ksoftirqd/4
40 TS - 0 19 0.0 S ksoftirqd/5
46 TS - 0 19 0.0 S ksoftirqd/6
52 TS - 0 19 0.0 S ksoftirqd/7
58 TS - 0 19 0.0 S ksoftirqd/8
64 TS - 0 19 0.0 S ksoftirqd/9
70 TS - 0 19 0.0 S ksoftirqd/10
76 TS - 0 19 0.0 S ksoftirqd/11
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 »

Ok, I think rtirq isn't working. Post the output of this:

Code: Select all

cat /etc/default/grub
and

Code: Select all

cat /etc/default/rtirq
By the way, I would encourage you to enclose the commands output in the code delimiters, so that they look boxed as my commands above.
User avatar
khz
Established Member
Posts: 1648
Joined: Thu Apr 17, 2008 6:29 am
Location: German
Has thanked: 42 times
Been thanked: 92 times

Re: Improve performance and reduce latency

Post by khz »

CrocoDuck wrote:Ok, I think rtirq isn't working.

Code: Select all

/etc/init.d/rtirq start
?
. . . FZ - Does humor belongs in Music?
. . GNU/LINUX@AUDIO ~ /Wiki $ Howto.Info && GNU/Linux Debian installing >> Linux Audio Workstation LAW
  • I don't care about the freedom of speech because I have nothing to say.
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 »

khz wrote:
CrocoDuck wrote:Ok, I think rtirq isn't working.

Code: Select all

/etc/init.d/rtirq start
?
The command is working, and its output shows that rtirq is not threading the hardware. Or not? I cannot see audio devices in the output, makes me think the configuration has to be sorted.
steinwayer
Established Member
Posts: 18
Joined: Fri Oct 12, 2018 11:25 pm

Re: Improve performance and reduce latency

Post by steinwayer »

CrocoDuck wrote:Ok, I think rtirq isn't working. Post the output of this:

Code: Select all

cat /etc/default/grub
and

Code: Select all

cat /etc/default/rtirq
By the way, I would encourage you to enclose the commands output in the code delimiters, so that they look boxed as my commands above.
Here is the output of cat /etc/default/grub:

Code: Select all

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX="nouveau.modeset=0"

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
and this is the output of cat /etc/default/rtirq

Code: Select all

#
# Copyright (C) 2004-2015, rncbc aka Rui Nuno Capela.
#
#   This program is free software; you can redistribute it and/or
#   modify it under the terms of the GNU General Public License
#   as published by the Free Software Foundation; either version 2
#   of the License, or (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License along
#   with this program; if not, write to the Free Software Foundation, Inc.,
#   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# /etc/sysconfig/rtirq
# /etc/default/rtirq
#
# Configuration for IRQ thread tunning,
# for realtime-preempt enabled kernels.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 or later.
#

# IRQ thread service names
# (space separated list, from higher to lower priority).
# RTIRQ_NAME_LIST="rtc snd usb i8042" # old
RTIRQ_NAME_LIST="snd usb i8042"

# Highest priority.
RTIRQ_PRIO_HIGH=90

# Priority decrease step.
RTIRQ_PRIO_DECR=5

# Lowest priority.
RTIRQ_PRIO_LOW=51

# Whether to reset all IRQ threads to SCHED_OTHER.
RTIRQ_RESET_ALL=0

# On kernel configurations that support it,
# which services should be NOT threaded 
# (space separated list).
RTIRQ_NON_THREADED="rtc snd"

# Process names which will be forced to the
# highest realtime priority range (99-91)
# (space separated list, from highest to lower priority).
# RTIRQ_HIGH_LIST="timer"
I don't know if it may matter in any way, but i am running on generic kernel as of now (since with the low latency i didn't see any differences or improvements in my latency)
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 »

OK, we need to say to grub that we want to boot our kernels with threadirqs, so that rtirq can give high priority to our audio devices.

Edit /etc/default/grub, I think you will need sudo:

Code: Select all

sudo gedit /etc/default/grub
Go to GRUB_CMDLINE_LINUX and make it look as follows:

Code: Select all

GRUB_CMDLINE_LINUX="threadirqs nouveau.modeset=0"
We just added threadirqs there. Then you need to update grub. This should do it on Ubuntu:

Code: Select all

sudo update-grub 
Then you can reboot and check how it works now with:

Code: Select all

/etc/init.d/rtirq status
Your rtirq conf seems OK, your snd device (internal audio card) is given highest priority.
steinwayer wrote:I don't know if it may matter in any way, but i am running on generic kernel as of now (since with the low latency i didn't see any differences or improvements in my latency)
Lowlatency and standard kernels are actually very similar. In theory, lowlatency should help you to have less xruns for the same JACK configuration.
steinwayer
Established Member
Posts: 18
Joined: Fri Oct 12, 2018 11:25 pm

Re: Improve performance and reduce latency

Post by steinwayer »

CrocoDuck wrote:OK, we need to say to grub that we want to boot our kernels with threadirqs, so that rtirq can give high priority to our audio devices.

Edit /etc/default/grub, I think you will need sudo:

Code: Select all

sudo gedit /etc/default/grub
Go to GRUB_CMDLINE_LINUX and make it look as follows:

Code: Select all

GRUB_CMDLINE_LINUX="threadirqs nouveau.modeset=0"
We just added threadirqs there. Then you need to update grub. This should do it on Ubuntu:

Code: Select all

sudo update-grub 
Then you can reboot and check how it works now with:

Code: Select all

/etc/init.d/rtirq status
Your rtirq conf seems OK, your snd device (internal audio card) is given highest priority.

steinwayer wrote:I don't know if it may matter in any way, but i am running on generic kernel as of now (since with the low latency i didn't see any differences or improvements in my latency)
Lowlatency and standard kernels are actually very similar. In theory, lowlatency should help you to have less xruns for the same JACK configuration.
Just tried doing as instructed, updated grub after making the changes, rebooted, checked the rtprio (it was set to 90, so it was good)

But sadly, nothing, the latency remains the same :// and i don't understand why really ://
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:Just tried doing as instructed, updated grub after making the changes, rebooted, checked the rtprio (it was set to 90, so it was good)

But sadly, nothing, the latency remains the same :// and i don't understand why really ://
Can we see again the output of

Code: Select all

/etc/init.d/rtirq status
If you don't change JACK parameters then latency stays the same. These interventions are aimed at making the system more stable (i.e. less xruns). Latency is only affected by the audio stack implementation, audio stack parameters (in this case sample rate, buffer size and periods) and hardware.

By the way, since Windows seem to be your benchmark platform, did you have any latency measurement in there by any chance? Maybe the Win audio stack is using additional safety buffers, or a Delay Locked Implementation, and its latency might actually be bigger than the Linux one despite the buffering variables being the same. This is the case on various Mac OS versions, for example. What I am afraid of is that we might be trying to push your Linux to an unreasonable limit, which maybe is not achieved by your Windows in the first place.

Despite that, I think we need some more tuning steps. Let's check your limits configuration, we might want to help the audio group rtprio a little:

Code: Select all

cat /etc/security/limits.conf
Then, let's check your soundcard capabilities to ensure we set JACK parameters so that we don't have ALSA converting the streams:

Code: Select all

cat /proc/asound/card0/codec#0
I think it might be worth to bump the sample rate to 48 kHz.

If everything fails, we could try the realtime kernel, or installing a light weight window manager like Open Box and use that when doing music. KDE is a bit on the heavy side.

By the way, how the xuns look like? Do they come in clusters at regular times or are they fairly random?
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:Just tried doing as instructed, updated grub after making the changes, rebooted, checked the rtprio (it was set to 90, so it was good)

But sadly, nothing, the latency remains the same :// and i don't understand why really ://
Can we see again the output of

Code: Select all

/etc/init.d/rtirq status
If you don't change JACK parameters then latency stays the same. These interventions are aimed at making the system more stable (i.e. less xruns). Latency is only affected by the audio stack implementation, audio stack parameters (in this case sample rate, buffer size and periods) and hardware.

By the way, since Windows seem to be your benchmark platform, did you have any latency measurement in there by any chance? Maybe the Win audio stack is using additional safety buffers, or a Delay Locked Implementation, and its latency might actually be bigger than the Linux one despite the buffering variables being the same. This is the case on various Mac OS versions, for example. What I am afraid of is that we might be trying to push your Linux to an unreasonable limit, which maybe is not achieved by your Windows in the first place.

Despite that, I think we need some more tuning steps. Let's check your limits configuration, we might want to help the audio group rtprio a little:

Code: Select all

cat /etc/security/limits.conf
Then, let's check your soundcard capabilities to ensure we set JACK parameters so that we don't have ALSA converting the streams:

Code: Select all

cat /proc/asound/card0/codec#0
I think it might be worth to bump the sample rate to 48 kHz.

If everything fails, we could try the realtime kernel, or installing a light weight window manager like Open Box and use that when doing music. KDE is a bit on the heavy side.

By the way, how the xuns look like? Do they come in clusters at regular times or are they fairly random?

here is the output of /etc/init.d/rtirq status

Code: Select all

PID CLS RTPRIO  NI PRI %CPU STAT COMMAND
  777 FF      90   - 130  0.0 S    irq/143-snd_hda
  161 FF      85   - 125  0.0 S    irq/124-xhci_hc
  163 FF      80   - 120  0.0 S    irq/1-i8042
  162 FF      79   - 119  0.0 S    irq/12-i8042
   94 FF      50   -  90  0.1 S    irq/9-acpi
  157 FF      50   -  90  0.0 S    irq/122-pcie-dp
  158 FF      50   -  90  0.0 S    irq/123-pcie-dp
  164 FF      50   -  90  0.0 S    irq/8-rtc0
  244 FF      50   -  90  1.0 S    irq/125-ahci[00
  250 FF      50   -  90  0.9 S    irq/126-i915
  572 FF      50   -  90  0.0 S    irq/16-idma64.0
  582 FF      50   -  90  0.0 S    irq/16-i2c_desi
  616 FF      50   -  90  1.3 S    irq/17-idma64.1
  647 FF      50   -  90  2.8 S    irq/17-i2c_desi
  648 FF      50   -  90  0.5 S    irq/51-DELL0825
  686 FF      50   -  90  0.0 S    irq/128-mei_me
  723 FF      50   -  90  0.0 S    irq/129-iwlwifi
  726 FF      50   -  90  0.0 S    irq/130-iwlwifi
  729 FF      50   -  90  0.0 S    irq/131-iwlwifi
  731 FF      50   -  90  0.0 S    irq/132-iwlwifi
  736 FF      50   -  90  0.0 S    irq/133-iwlwifi
  738 FF      50   -  90  0.0 S    irq/134-iwlwifi
  740 FF      50   -  90  0.0 S    irq/135-iwlwifi
  742 FF      50   -  90  0.0 S    irq/136-iwlwifi
  744 FF      50   -  90  0.0 S    irq/137-iwlwifi
  746 FF      50   -  90  0.0 S    irq/138-iwlwifi
  748 FF      50   -  90  0.0 S    irq/139-iwlwifi
  750 FF      50   -  90  0.0 S    irq/140-iwlwifi
  753 FF      50   -  90  0.0 S    irq/141-iwlwifi
  756 FF      50   -  90  0.0 S    irq/142-iwlwifi
 1252 FF      50   -  90  0.0 S    irq/127-enp59s0
 1253 FF      50   -  90  0.0 S    irq/144-enp59s0
 1254 FF      50   -  90  0.0 S    irq/145-enp59s0
 1255 FF      50   -  90  0.0 S    irq/146-enp59s0
 1256 FF      50   -  90  0.0 S    irq/147-enp59s0
  724 FF      49   -  89  0.0 S    irq/129-s-iwlwi
  728 FF      49   -  89  0.0 S    irq/130-s-iwlwi
  730 FF      49   -  89  0.0 S    irq/131-s-iwlwi
  735 FF      49   -  89  0.0 S    irq/132-s-iwlwi
  737 FF      49   -  89  0.0 S    irq/133-s-iwlwi
  739 FF      49   -  89  0.0 S    irq/134-s-iwlwi
  741 FF      49   -  89  0.0 S    irq/135-s-iwlwi
  743 FF      49   -  89  0.0 S    irq/136-s-iwlwi
  745 FF      49   -  89  0.0 S    irq/137-s-iwlwi
  747 FF      49   -  89  0.0 S    irq/138-s-iwlwi
  749 FF      49   -  89  0.0 S    irq/139-s-iwlwi
  752 FF      49   -  89  0.0 S    irq/140-s-iwlwi
  755 FF      49   -  89  0.0 S    irq/141-s-iwlwi
  757 FF      49   -  89  0.0 S    irq/142-s-iwlwi
    7 TS       -   0  19  0.2 S    ksoftirqd/0
   16 TS       -   0  19  0.1 S    ksoftirqd/1
   22 TS       -   0  19  0.1 S    ksoftirqd/2
   28 TS       -   0  19  0.1 S    ksoftirqd/3
   34 TS       -   0  19  0.1 S    ksoftirqd/4
   40 TS       -   0  19  0.3 S    ksoftirqd/5
   46 TS       -   0  19  0.1 S    ksoftirqd/6
   52 TS       -   0  19  0.1 S    ksoftirqd/7
   58 TS       -   0  19  0.1 S    ksoftirqd/8
   64 TS       -   0  19  0.1 S    ksoftirqd/9
   70 TS       -   0  19  0.1 S    ksoftirqd/10
   76 TS       -   0  19  0.1 S    ksoftirqd/11
here is the output of cat /etc/security/limits.conf

Code: Select all

# /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#<domain>        <type>  <item>  <value>
#
#Where:
#<domain> can be:
#        - a user name
#        - a group name, with @group syntax
#        - the wildcard *, for default entry
#        - the wildcard %, can be also used with %group syntax,
#                 for maxlogin limit
#        - NOTE: group and wildcard limits are not applied to root.
#          To apply a limit to the root user, <domain> must be
#          the literal username root.
#
#<type> can have the two values:
#        - "soft" for enforcing the soft limits
#        - "hard" for enforcing hard limits
#
#<item> can be one of the following:
#        - core - limits the core file size (KB)
#        - data - max data size (KB)
#        - fsize - maximum filesize (KB)
#        - memlock - max locked-in-memory address space (KB)
#        - nofile - max number of open files
#        - rss - max resident set size (KB)
#        - stack - max stack size (KB)
#        - cpu - max CPU time (MIN)
#        - nproc - max number of processes
#        - as - address space limit (KB)
#        - maxlogins - max number of logins for this user
#        - maxsyslogins - max number of logins on the system
#        - priority - the priority to run user process with
#        - locks - max number of file locks the user can hold
#        - sigpending - max number of pending signals
#        - msgqueue - max memory used by POSIX message queues (bytes)
#        - nice - max nice priority allowed to raise to values: [-20, 19]
#        - rtprio - max realtime priority
#        - chroot - change root to directory (Debian-specific)
#
#<domain>      <type>  <item>         <value>
#

#*               soft    core            0
#root            hard    core            100000
#*               hard    rss             10000
#@student        hard    nproc           20
#@faculty        soft    nproc           20
#@faculty        hard    nproc           50
#ftp             hard    nproc           0
#ftp             -       chroot          /ftp
#@student        -       maxlogins       4

# End of file
and here is the output of cat /proc/asound/card0/codec#0

Code: Select all

Codec: Realtek ALC3246
Address: 0
AFG Function Id: 0x1 (unsol 1)
Vendor Id: 0x10ec0256
Subsystem Id: 0x10280825
Revision Id: 0x100002
No Modem Function Group found
Default PCM:
    rates [0x560]: 44100 48000 96000 192000
    bits [0xe]: 16 20 24
    formats [0x1]: PCM
Default Amp-In caps: N/A
Default Amp-Out caps: N/A
State of AFG node 0x01:
  Power states:  D0 D1 D2 D3 D3cold CLKSTOP EPSS
  Power: setting=D0, actual=D0
GPIO: io=3, o=0, i=0, unsolicited=1, wake=0
  IO[0]: enable=0, dir=0, wake=0, sticky=0, data=0, unsol=0
  IO[1]: enable=0, dir=0, wake=0, sticky=0, data=0, unsol=0
  IO[2]: enable=0, dir=0, wake=0, sticky=0, data=0, unsol=0
Node 0x02 [Audio Output] wcaps 0x41d: Stereo Amp-Out
  Control: name="Speaker Playback Volume", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Amp-Out caps: ofs=0x57, nsteps=0x57, stepsize=0x02, mute=0
  Amp-Out vals:  [0x51 0x51]
  Converter: stream=1, channel=0
  PCM:
    rates [0x60]: 44100 48000
    bits [0xe]: 16 20 24
    formats [0x1]: PCM
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
Node 0x03 [Audio Output] wcaps 0x41d: Stereo Amp-Out
  Control: name="Headphone Playback Volume", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Device: name="ALC3246 Analog", type="Audio", device=0
  Amp-Out caps: ofs=0x57, nsteps=0x57, stepsize=0x02, mute=0
  Amp-Out vals:  [0x00 0x00]
  Converter: stream=1, channel=0
  PCM:
    rates [0x60]: 44100 48000
    bits [0xe]: 16 20 24
    formats [0x1]: PCM
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
Node 0x04 [Vendor Defined Widget] wcaps 0xf00000: Mono
Node 0x05 [Vendor Defined Widget] wcaps 0xf00000: Mono
Node 0x06 [Audio Output] wcaps 0x611: Stereo Digital
  Converter: stream=0, channel=0
  Digital:
  Digital category: 0x0
  IEC Coding Type: 0x0
  PCM:
    rates [0x5e0]: 44100 48000 88200 96000 192000
    bits [0xe]: 16 20 24
    formats [0x1]: PCM
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D3, actual=D3
Node 0x07 [Audio Input] wcaps 0x10051b: Stereo Amp-In
  Amp-In caps: ofs=0x17, nsteps=0x3f, stepsize=0x02, mute=1
  Amp-In vals:  [0x97 0x97]
  Converter: stream=0, channel=0
  SDI-Select: 0
  PCM:
    rates [0x560]: 44100 48000 96000 192000
    bits [0xe]: 16 20 24
    formats [0x1]: PCM
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D3, actual=D3
  Connection: 1
     0x24
Node 0x08 [Audio Input] wcaps 0x10051b: Stereo Amp-In
  Control: name="Capture Volume", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=0, ofs=0
  Control: name="Capture Switch", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=0, ofs=0
  Device: name="ALC3246 Analog", type="Audio", device=0
  Amp-In caps: ofs=0x17, nsteps=0x3f, stepsize=0x02, mute=1
  Amp-In vals:  [0x27 0x27]
  Converter: stream=1, channel=0
  SDI-Select: 0
  PCM:
    rates [0x560]: 44100 48000 96000 192000
    bits [0xe]: 16 20 24
    formats [0x1]: PCM
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
  Connection: 1
     0x23
Node 0x09 [Audio Input] wcaps 0x10051b: Stereo Amp-In
  Amp-In caps: ofs=0x17, nsteps=0x3f, stepsize=0x02, mute=1
  Amp-In vals:  [0x97 0x97]
  Converter: stream=0, channel=0
  SDI-Select: 0
  PCM:
    rates [0x560]: 44100 48000 96000 192000
    bits [0xe]: 16 20 24
    formats [0x1]: PCM
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D3, actual=D3
  Connection: 1
     0x22
Node 0x0a [Vendor Defined Widget] wcaps 0xf00000: Mono
Node 0x0b [Vendor Defined Widget] wcaps 0xf00000: Mono
Node 0x0c [Vendor Defined Widget] wcaps 0xf00000: Mono
Node 0x0d [Vendor Defined Widget] wcaps 0xf00000: Mono
Node 0x0e [Vendor Defined Widget] wcaps 0xf00000: Mono
Node 0x0f [Vendor Defined Widget] wcaps 0xf00000: Mono
Node 0x10 [Vendor Defined Widget] wcaps 0xf00000: Mono
Node 0x11 [Vendor Defined Widget] wcaps 0xf00000: Mono
Node 0x12 [Pin Complex] wcaps 0x40040b: Stereo Amp-In
  Control: name="Internal Mic Boost Volume", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=0, ofs=0
  Amp-In caps: ofs=0x00, nsteps=0x03, stepsize=0x27, mute=0
  Amp-In vals:  [0x00 0x00]
  Pincap 0x00000020: IN
  Pin Default 0x90a60180: [Fixed] Mic at Int N/A
    Conn = Digital, Color = Unknown
    DefAssociation = 0x8, Sequence = 0x0
    Misc = NO_PRESENCE
  Pin-ctls: 0x20: IN
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
Node 0x13 [Pin Complex] wcaps 0x40040b: Stereo Amp-In
  Amp-In caps: ofs=0x00, nsteps=0x03, stepsize=0x27, mute=0
  Amp-In vals:  [0x00 0x00]
  Pincap 0x00000020: IN
  Pin Default 0x40000000: [N/A] Line Out at Ext N/A
    Conn = Unknown, Color = Unknown
    DefAssociation = 0x0, Sequence = 0x0
  Pin-ctls: 0x00:
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D3, actual=D3
Node 0x14 [Pin Complex] wcaps 0x40058d: Stereo Amp-Out
  Control: name="Speaker Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
  Amp-Out vals:  [0x00 0x00]
  Pincap 0x00010014: OUT EAPD Detect
  EAPD 0x2: EAPD
  Pin Default 0x90170120: [Fixed] Speaker at Int N/A
    Conn = Analog, Color = Unknown
    DefAssociation = 0x2, Sequence = 0x0
    Misc = NO_PRESENCE
  Pin-ctls: 0x40: OUT
  Unsolicited: tag=00, enabled=0
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
  Connection: 1
     0x02
Node 0x15 [Vendor Defined Widget] wcaps 0xf00000: Mono
Node 0x16 [Vendor Defined Widget] wcaps 0xf00000: Mono
Node 0x17 [Vendor Defined Widget] wcaps 0xf00000: Mono
Node 0x18 [Pin Complex] wcaps 0x40048b: Stereo Amp-In
  Amp-In caps: ofs=0x00, nsteps=0x03, stepsize=0x27, mute=0
  Amp-In vals:  [0x00 0x00]
  Pincap 0x00003724: IN Detect
    Vref caps: HIZ 50 GRD 80 100
  Pin Default 0x411111f0: [N/A] Speaker at Ext Rear
    Conn = 1/8, Color = Black
    DefAssociation = 0xf, Sequence = 0x0
    Misc = NO_PRESENCE
  Pin-ctls: 0x20: IN VREF_HIZ
  Unsolicited: tag=00, enabled=0
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D3, actual=D3
Node 0x19 [Pin Complex] wcaps 0x40048b: Stereo Amp-In
  Control: name="Headset Mic Boost Volume", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=0, ofs=0
  Amp-In caps: ofs=0x00, nsteps=0x03, stepsize=0x27, mute=0
  Amp-In vals:  [0x00 0x00]
  Pincap 0x00003724: IN Detect
    Vref caps: HIZ 50 GRD 80 100
  Pin Default 0x411111f0: [N/A] Speaker at Ext Rear
    Conn = 1/8, Color = Black
    DefAssociation = 0xf, Sequence = 0x0
    Misc = NO_PRESENCE
  Pin-ctls: 0x24: IN VREF_80
  Unsolicited: tag=00, enabled=0
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D3, actual=D3
Node 0x1a [Pin Complex] wcaps 0x40048b: Stereo Amp-In
  Control: name="Headphone Mic Boost Volume", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=0, ofs=0
  Amp-In caps: ofs=0x00, nsteps=0x03, stepsize=0x27, mute=0
  Amp-In vals:  [0x00 0x00]
  Pincap 0x00003724: IN Detect
    Vref caps: HIZ 50 GRD 80 100
  Pin Default 0x411111f0: [N/A] Speaker at Ext Rear
    Conn = 1/8, Color = Black
    DefAssociation = 0xf, Sequence = 0x0
    Misc = NO_PRESENCE
  Pin-ctls: 0x20: IN VREF_HIZ
  Unsolicited: tag=00, enabled=0
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D3, actual=D3
Node 0x1b [Pin Complex] wcaps 0x40058f: Stereo Amp-In Amp-Out
  Amp-In caps: ofs=0x00, nsteps=0x03, stepsize=0x27, mute=0
  Amp-In vals:  [0x00 0x00]
  Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
  Amp-Out vals:  [0x80 0x80]
  Pincap 0x00013734: IN OUT EAPD Detect
    Vref caps: HIZ 50 GRD 80 100
  EAPD 0x2: EAPD
  Pin Default 0x411111f0: [N/A] Speaker at Ext Rear
    Conn = 1/8, Color = Black
    DefAssociation = 0xf, Sequence = 0x0
    Misc = NO_PRESENCE
  Pin-ctls: 0x20: IN VREF_HIZ
  Unsolicited: tag=00, enabled=0
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D3, actual=D3
  Connection: 2
     0x02* 0x03
Node 0x1c [Vendor Defined Widget] wcaps 0xf00000: Mono
Node 0x1d [Pin Complex] wcaps 0x400400: Mono
  Pincap 0x00000020: IN
  Pin Default 0x40700001: [N/A] Modem Hand at Ext N/A
    Conn = Unknown, Color = Unknown
    DefAssociation = 0x0, Sequence = 0x1
  Pin-ctls: 0x20: IN
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D3, actual=D3
Node 0x1e [Pin Complex] wcaps 0x400781: Stereo Digital
  Pincap 0x00000014: OUT Detect
  Pin Default 0x411111f0: [N/A] Speaker at Ext Rear
    Conn = 1/8, Color = Black
    DefAssociation = 0xf, Sequence = 0x0
    Misc = NO_PRESENCE
  Pin-ctls: 0x40: OUT
  Unsolicited: tag=00, enabled=0
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D3, actual=D3
  Connection: 1
     0x06
Node 0x1f [Vendor Defined Widget] wcaps 0xf00000: Mono
Node 0x20 [Vendor Defined Widget] wcaps 0xf00040: Mono
  Processing caps: benign=0, ncoeff=91
Node 0x21 [Pin Complex] wcaps 0x40058d: Stereo Amp-Out
  Control: name="Headphone Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
  Amp-Out vals:  [0x80 0x80]
  Pincap 0x0001001c: OUT HP EAPD Detect
  EAPD 0x2: EAPD
  Pin Default 0x02211030: [Jack] HP Out at Ext Front
    Conn = 1/8, Color = Black
    DefAssociation = 0x3, Sequence = 0x0
  Pin-ctls: 0xc0: OUT HP
  Unsolicited: tag=01, enabled=1
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D3, actual=D3
  Connection: 2
     0x02 0x03*
Node 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In
  Amp-In caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
  Amp-In vals:  [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x80 0x80]
  Connection: 5
     0x18 0x19 0x1a 0x1b 0x1d
Node 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In
  Amp-In caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
  Amp-In vals:  [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x00 0x00]
  Connection: 6
     0x18 0x19 0x1a 0x1b 0x1d 0x12
Node 0x24 [Audio Selector] wcaps 0x300101: Stereo
  Connection: 2
     0x12* 0x13
The xruns are constant if i put 64 samples and 2 periods , from the moment i start jack i start having hundreds of those without doing anything , if i increase the periods to 4, i get them randomly but as soon as i start playing the keyboard, i get a lot of them with a lot of clicks. i get xruns also at 256 samples and 4 periods , after an hour long recording session, i usually end up having something around 35-45 xruns. And that is with synchronous mode on, if i don't have that one the situation gets worse. As far as Windows, i don't how to measure the latency, but i did notice that asio4all seems to have a parameter set to 4ms as an extra latency i think.
To be honest, I still believe there is something wrong with jack. If it was my computer or the driver, i wouldn't be able to use pianoteq standalone with alsa and my midi controller at 64 samples witohut clicks and xruns , but i might be wrong of course :)
User avatar
bluebell
Established Member
Posts: 1909
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland, Germany
Has thanked: 111 times
Been thanked: 116 times

Re: Improve performance and reduce latency

Post by bluebell »

Did you try a samplerate of 48000? Any differences to 44100?

Linux – MOTU UltraLite AVB – Qtractor – http://suedwestlicht.saar.de/

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 /etc/init.d/rtirq status
OK, that's working OK now.
steinwayer wrote:here is the output of cat /etc/security/limits.conf
Looks like there aren't priorities set for the audio group. Let's fix that.

Repost the output of:

Code: Select all

groups
I think it will tell us you are in the audio group. If so, then appending these lines to the bottom of to your limits.conf should work:

Code: Select all

@audio - rtprio 98
@audio - memlock unlimited
You will have to open the file with sudo:

Code: Select all

sudo gedit /etc/security/limits.conf
Then, when you ran JACK, your priority should be at least 10 less than the one defined in the file. So go with 88. By the way, let's make sure you don't have conf files around that might override the setting:

Code: Select all

ls /etc/security
ls /etc/security/limits.d/
steinwayer wrote:The xruns are constant if i put 64 samples and 2 periods , from the moment i start jack i start having hundreds of those without doing anything , if i increase the periods to 4, i get them randomly but as soon as i start playing the keyboard, i get a lot of them with a lot of clicks. i get xruns also at 256 samples and 4 periods , after an hour long recording session, i usually end up having something around 35-45 xruns. And that is with synchronous mode on, if i don't have that one the situation gets worse. As far as Windows, i don't how to measure the latency, but i did notice that asio4all seems to have a parameter set to 4ms as an extra latency i think.
To be honest, I still believe there is something wrong with jack. If it was my computer or the driver, i wouldn't be able to use pianoteq standalone with alsa and my midi controller at 64 samples witohut clicks and xruns , but i might be wrong of course :)
Looks like it is a problem with system load. Sorting out the priorities should help, but it might not be definitive.

JACK can be a bit of a pain, sometimes I sort of wish we had only ALSA, with Delay Locked Loop implementation and JACK like interface to connect applications.

Still, stability can be affected by your JACK settings too. Normally 48 kHz works better than 44.1 kHz. I would suggest to make the latency integer, as explained here. It works best for USB soundcards, but I would try it anyway. Using 48 kHz helps making the number an integer.
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: here is the output of /etc/init.d/rtirq status
OK, that's working OK now.
steinwayer wrote:here is the output of cat /etc/security/limits.conf
Looks like there aren't priorities set for the audio group. Let's fix that.

Repost the output of:

Code: Select all

groups
I think it will tell us you are in the audio group. If so, then appending these lines to the bottom of to your limits.conf should work:

Code: Select all

@audio - rtprio 98
@audio - memlock unlimited
You will have to open the file with sudo:

Code: Select all

sudo gedit /etc/security/limits.conf
Then, when you ran JACK, your priority should be at least 10 less than the one defined in the file. So go with 88. By the way, let's make sure you don't have conf files around that might override the setting:

Code: Select all

ls /etc/security
ls /etc/security/limits.d/
steinwayer wrote:The xruns are constant if i put 64 samples and 2 periods , from the moment i start jack i start having hundreds of those without doing anything , if i increase the periods to 4, i get them randomly but as soon as i start playing the keyboard, i get a lot of them with a lot of clicks. i get xruns also at 256 samples and 4 periods , after an hour long recording session, i usually end up having something around 35-45 xruns. And that is with synchronous mode on, if i don't have that one the situation gets worse. As far as Windows, i don't how to measure the latency, but i did notice that asio4all seems to have a parameter set to 4ms as an extra latency i think.
To be honest, I still believe there is something wrong with jack. If it was my computer or the driver, i wouldn't be able to use pianoteq standalone with alsa and my midi controller at 64 samples witohut clicks and xruns , but i might be wrong of course :)
Looks like it is a problem with system load. Sorting out the priorities should help, but it might not be definitive.

JACK can be a bit of a pain, sometimes I sort of wish we had only ALSA, with Delay Locked Loop implementation and JACK like interface to connect applications.

Still, stability can be affected by your JACK settings too. Normally 48 kHz works better than 44.1 kHz. I would suggest to make the latency integer, as explained here. It works best for USB soundcards, but I would try it anyway. Using 48 kHz helps making the number an integer.
Yes i already have a file in /etc/security/limits.d/audio.conf that specifies the priority of the audio group and the memlock. I setted as you said the value to 48000 instead of 44.1 but no noticeable improvement sadly.. :///
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:Yes i already have a file in /etc/security/limits.d/audio.conf that specifies the priority of the audio group and the memlock. I setted as you said the value to 48000 instead of 44.1 but no noticeable improvement sadly.. :///
OK. Looks like nothing is left a part the heavy artillery. We could try the realtime kernel. I think the easiest way to get on is through the KX Studio repos:

https://kxstudio.linuxaudio.org/Repositories
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:Yes i already have a file in /etc/security/limits.d/audio.conf that specifies the priority of the audio group and the memlock. I setted as you said the value to 48000 instead of 44.1 but no noticeable improvement sadly.. :///
OK. Looks like nothing is left a part the heavy artillery. We could try the realtime kernel. I think the easiest way to get on is through the KX Studio repos:

https://kxstudio.linuxaudio.org/Repositories
I would like to point out couple things first Crocoduck :)

First of all, thanks SOOO MUCH for all the help and effort you are putting into helping me find the perfect config.

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.

I am not sure the problem is kernel related, i still thing is jack related... if it was kernel related, i shouldn't be able to play at 64 samples directly with alsa.
Looks like Jack is creating some issue at least that's what looks like the most plausible explanation.

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.

Before posting to this forum, in order to get to my current configuration, i had to go through a lot of guides and a lot of "misguides" (sadly/fortunately since linux updates very fast, you tend to find guides related to older versions that don't do anything good to newer systems and so on)
I managed to have wineasio perfectly working thus kontakt through wine with low latency, which is already remarkable by itself.
Of course i don't expect to be able to keep my system at 64 samples while using a daw, that is just impossible (i don't think anyone can actually achieve that if they work with heavy projects with multiple plugin-loaded tracks) 256 works just fine and when it starts suffering from the moltitude of tracks i can always either:
1.bump the settings up to 512
2.or even better, translate the tracks that i am not planning to change into audio, so that i just have the audio playing without putting too much strain on the cpu.

I don't think the problem is distro related because i tried also under ubuntu studio and ended up with the exact same results (fresh install)

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 still curious to give the rt kernel a try of course, it's not a biggie if when i want to record i need to reboot and load a different kernel. But doing it from the kx studio repos, is not a very good idea.

Ideally, if i could find the deb files to just install in the distro and try how it works, it would be much better.

Do you have any suggestions??
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: 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.
Post Reply