(SOLVED) Would a low-latency kernel make a difference?

Still new to all of this? Feel free to post in any of the subforums on this site, but in this subforum newbie questions are especially encouraged!

Moderators: MattKingUSA, khz

Post Reply
amc252
Established Member
Posts: 139
Joined: Fri May 05, 2023 12:24 am
Has thanked: 92 times
Been thanked: 22 times

(SOLVED) Would a low-latency kernel make a difference?

Post by amc252 »

Hello everybody,

I have set up a minimal devuan system on a spare partition to play around with music.
If I play my midi keyboard with fluidsynth there is no noticeable latency, but if I play it with linuxsampler I can see a slight delay.
So, I have installed a second kernel, low-latency liquorix-6.0.0-10.1-amd64 to see if it would improve performance.
I could not see any significant improvement.
My laptop is a Toshiba Satellite with the following characteristics:

Code: Select all

 sudo lshw
                          
description: Notebook product: Satellite C55-B (PSCMNU) vendor: TOSHIBA version: PSCMNU-01SNB1 serial: ZE091570P width: 64 bits capabilities: smbios-2.8 dmi-2.8 smp vsyscall32 configuration: boot=normal chassis=notebook family=* sku=PSCMNU uuid=05E5289C-7C4D-11E4-85C7-F0761C4DCFB0 *-core description: Motherboard product: ZBWAA vendor: TOSHIBA physical id: 0 version: 1.00 serial: * slot: * *-firmware description: BIOS vendor: TOSHIBA physical id: 0 version: 1.60 date: 11/27/2014 size: 64KiB capacity: 1MiB capabilities: pci upgrade shadowing cdboot bootselect socketedrom edd int13floppy1200 int13floppy720 int13floppy2880 int5printscreen int14serial int17printer acpi usb biosbootspecification uefi *-memory description: System Memory physical id: e slot: System board or motherboard size: 4GiB *-bank:0 description: DIMM DDR3 1333 MHz (0.8 ns) product: M471B5173DB0-YK0 vendor: Samsung physical id: 0 serial: 18219D3F slot: A1_DIMM0 size: 4GiB width: 64 bits clock: 1333MHz (0.8ns) *-bank:1 description: DIMM [empty] product: Array1_PartNumber1 vendor: A1_Manufacturer1 physical id: 1 serial: A1_SerNum1 slot: A1_DIMM1 *-cache:0 description: L1 cache physical id: 18 slot: CPU Internal L1 size: 112KiB capacity: 112KiB capabilities: internal write-back configuration: level=1 *-cache:1 description: L2 cache physical id: 19 slot: CPU Internal L2 size: 1MiB capacity: 1MiB capabilities: internal write-back unified configuration: level=2 *-cpu description: CPU product: Intel(R) Celeron(R) CPU N2840 @ 2.16GHz vendor: Intel Corp. physical id: 1a bus info: cpu@0 version: Intel(R) Celeron(R) CPU N2840 @ 2.16GHz slot: SOCKET 0 size: 2583MHz width: 64 bits clock: 83MHz capabilities: lm fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp x86-64 constant_tsc arch_perfmon pebs bts rep_good nopl xtopology tsc_reliable nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 movbe popcnt tsc_deadline_timer rdrand lahf_lm 3dnowprefetch epb pti tpr_shadow vnmi flexpriority ept vpid tsc_adjust smep erms dtherm ida arat cpufreq configuration: cores=2 enabledcores=2 threads=2 *-pci description: Host bridge product: Atom Processor Z36xxx/Z37xxx Series SoC Transaction Register vendor: Intel Corporation physical id: 100 bus info: pci@0000:00:00.0 version: 0e width: 32 bits clock: 33MHz configuration: driver=iosf_mbi_pci resources: irq:0 *-display description: VGA compatible controller product: Atom Processor Z36xxx/Z37xxx Series Graphics & Display vendor: Intel Corporation physical id: 2 bus info: pci@0000:00:02.0 version: 0e width: 32 bits clock: 33MHz capabilities: pm msi vga_controller bus_master cap_list rom configuration: driver=i915 latency=0 resources: irq:91 memory:d0000000-d03fffff memory:c0000000-cfffffff ioport:f080(size=8) memory:c0000-dffff *-sata description: SATA controller product: Atom Processor E3800 Series SATA AHCI Controller vendor: Intel Corporation physical id: 13 bus info: pci@0000:00:13.0 logical name: scsi0 logical name: scsi1 version: 0e width: 32 bits clock: 66MHz capabilities: sata msi pm ahci_1.0 bus_master cap_list emulated configuration: driver=ahci latency=0 resources: irq:90 ioport:f070(size=8) ioport:f060(size=4) ioport:f050(size=8) ioport:f040(size=4) ioport:f020(size=32) memory:d0816000-d08167ff *-disk description: ATA Disk product: HGST HTS545050A7 physical id: 0 bus info: scsi@0:0.0.0 logical name: /dev/sda version: AH20 serial: 141120TM8513TD1SRNSM size: 465GiB (500GB) capabilities: partitioned partitioned:dos configuration: ansiversion=5 logicalsectorsize=512 sectorsize=4096 signature=731c80f0 *-volume:0 description: EXT4 volume vendor: Linux physical id: 1 bus info: scsi@0:0.0.0,1 logical name: /dev/sda1 logical name: / version: 1.0 serial: c3a16f36-3544-4e30-8f3f-f47836ba25d4 size: 30GiB capacity: 30GiB capabilities: primary bootable journaled extended_attributes large_files huge_files dir_nlink 64bit extents ext4 ext2 initialized configuration: created=2022-10-07 09:53:28 filesystem=ext4 label=Devuan lastmountpoint=/ modified=2023-05-23 13:54:09 mount.fstype=ext4 mount.options=rw,relatime,errors=remount-ro mounted=2023-05-23 11:43:58 state=mounted *-volume:1 description: Extended partition physical id: 2 bus info: scsi@0:0.0.0,2 logical name: /dev/sda2 size: 435GiB capacity: 435GiB capabilities: primary extended partitioned partitioned:extended *-logicalvolume:0 description: EXT4 volume vendor: Linux physical id: 5 logical name: /dev/sda5 logical name: /media/mac/Files version: 1.0 serial: 711911f1-7502-4b4d-b9f9-2b5eb29d5081 size: 390GiB capacity: 390GiB capabilities: journaled extended_attributes large_files huge_files dir_nlink recover extents ext4 ext2 initialized configuration: created=2022-09-11 21:00:32 filesystem=ext4 label=Files lastmountpoint=/media/mac/Files modified=2023-05-23 13:54:22 mount.fstype=ext4 mount.options=rw,relatime mounted=2023-05-23 13:54:22 state=mounted *-logicalvolume:1 description: EXT4 volume vendor: Linux physical id: 6 logical name: /dev/sda6 logical name: /media/root/Devuan Devel version: 1.0 serial: 7aba8942-b5cc-4d60-acc0-7e97a34a5f57 size: 20GiB capacity: 20GiB capabilities: journaled extended_attributes large_files huge_files dir_nlink recover 64bit extents ext4 ext2 initialized configuration: created=2022-09-16 12:58:11 filesystem=ext4 label=Devuan Devel lastmountpoint=/media/root/Devuan Devel modified=2023-05-23 14:28:07 mount.fstype=ext4 mount.options=rw,nosuid,nodev,noexec,noatime mounted=2023-05-23 14:28:07 state=mounted *-logicalvolume:2 description: EXT4 volume vendor: Linux physical id: 7 logical name: /dev/sda7 version: 1.0 serial: b2feaaf3-a841-41d6-9eb1-50571946d3ad size: 14GiB capacity: 14GiB capabilities: journaled extended_attributes large_files huge_files dir_nlink recover 64bit extents ext4 ext2 initialized configuration: created=2023-05-16 15:18:02 filesystem=ext4 label=Fedora lastmountpoint=/media/root/Fedora modified=2023-05-23 11:44:38 mounted=2023-05-23 11:44:38 state=clean *-logicalvolume:3 description: EXT4 volume vendor: Linux physical id: 8 logical name: /dev/sda8 version: 1.0 serial: e2d6bbf2-9633-47ac-aeae-28e418395bf8 size: 9997MiB capacity: 9997MiB capabilities: journaled extended_attributes large_files huge_files dir_nlink 64bit extents ext4 ext2 initialized configuration: created=2023-05-13 13:25:59 filesystem=ext4 label=Debian lastmountpoint=/media/root/Debian modified=2023-05-23 11:30:45 mounted=2023-05-23 11:00:52 state=clean *-cdrom description: DVD-RAM writer product: CDDVDW SU-208FB vendor: TSSTcorp physical id: 1 bus info: scsi@1:0.0.0 logical name: /dev/cdrom logical name: /dev/cdrw logical name: /dev/dvd logical name: /dev/dvdrw logical name: /dev/sr0 version: TF01 capabilities: removable audio cd-r cd-rw dvd dvd-r dvd-ram configuration: ansiversion=5 status=nodisc *-usb description: USB controller product: Atom Processor Z36xxx/Z37xxx, Celeron N2000 Series USB xHCI vendor: Intel Corporation physical id: 14 bus info: pci@0000:00:14.0 version: 0e width: 64 bits clock: 33MHz capabilities: pm msi xhci bus_master cap_list configuration: driver=xhci_hcd latency=0 resources: irq:93 memory:d0800000-d080ffff *-generic description: Encryption controller product: Atom Processor Z36xxx/Z37xxx Series Trusted Execution Engine vendor: Intel Corporation physical id: 1a bus info: pci@0000:00:1a.0 version: 0e width: 32 bits clock: 33MHz capabilities: pm msi bus_master cap_list configuration: driver=mei_txe latency=0 resources: irq:92 memory:d0500000-d05fffff memory:d0400000-d04fffff *-multimedia description: Audio device product: Atom Processor Z36xxx/Z37xxx Series High Definition Audio Controller vendor: Intel Corporation physical id: 1b bus info: pci@0000:00:1b.0 version: 0e width: 64 bits clock: 33MHz capabilities: pm msi bus_master cap_list configuration: driver=snd_hda_intel latency=0 resources: irq:95 memory:d0810000-d0813fff *-pci:0 description: PCI bridge product: Atom Processor E3800 Series PCI Express Root Port 1 vendor: Intel Corporation physical id: 1c bus info: pci@0000:00:1c.0 version: 0e width: 32 bits clock: 33MHz capabilities: pci pciexpress msi pm normal_decode bus_master cap_list configuration: driver=pcieport resources: irq:87 ioport:1000(size=4096) *-pci:1 description: PCI bridge product: Atom Processor E3800 Series PCI Express Root Port 2 vendor: Intel Corporation physical id: 1c.1 bus info: pci@0000:00:1c.1 version: 0e width: 32 bits clock: 33MHz capabilities: pci pciexpress msi pm normal_decode bus_master cap_list configuration: driver=pcieport resources: irq:88 ioport:2000(size=4096) memory:d0700000-d07fffff *-network description: Wireless interface product: AR9485 Wireless Network Adapter vendor: Qualcomm Atheros physical id: 0 bus info: pci@0000:02:00.0 logical name: wlan0 version: 01 serial: ac:b5:7d:90:83:9f width: 64 bits clock: 33MHz capabilities: pm msi pciexpress bus_master cap_list rom ethernet physical wireless configuration: broadcast=yes driver=ath9k driverversion=5.10.0-23-amd64 firmware=N/A ip=192.168.1.69 latency=0 link=yes multicast=yes wireless=IEEE 802.11 resources: irq:17 memory:d0700000-d077ffff memory:d0780000-d078ffff *-pci:2 description: PCI bridge product: Atom Processor E3800 Series PCI Express Root Port 3 vendor: Intel Corporation physical id: 1c.2 bus info: pci@0000:00:1c.2 version: 0e width: 32 bits clock: 33MHz capabilities: pci pciexpress msi pm normal_decode bus_master cap_list configuration: driver=pcieport resources: irq:89 ioport:3000(size=4096) memory:d0600000-d06fffff *-generic description: Unassigned class product: RTS5229 PCI Express Card Reader vendor: Realtek Semiconductor Co., Ltd. physical id: 0 bus info: pci@0000:03:00.0 version: 01 width: 32 bits clock: 33MHz capabilities: pm msi pciexpress bus_master cap_list configuration: driver=rtsx_pci latency=0 resources: irq:94 memory:d0600000-d0600fff *-isa description: ISA bridge product: Atom Processor Z36xxx/Z37xxx Series Power Control Unit vendor: Intel Corporation physical id: 1f bus info: pci@0000:00:1f.0 version: 0e width: 32 bits clock: 33MHz capabilities: isa bus_master cap_list configuration: driver=lpc_ich latency=0 resources: irq:0 *-serial description: SMBus product: Atom Processor E3800 Series SMBus Controller vendor: Intel Corporation physical id: 1f.3 bus info: pci@0000:00:1f.3 version: 0e width: 32 bits clock: 33MHz capabilities: pm cap_list configuration: driver=i801_smbus latency=0 resources: irq:18 memory:d0814000-d081401f ioport:f000(size=32) *-pnp00:00 product: PnP device PNP0b00 physical id: 1 capabilities: pnp configuration: driver=rtc_cmos *-pnp00:01 product: PnP device PNP0c02 physical id: 2 capabilities: pnp configuration: driver=system *-pnp00:02 product: PnP device TOS0330 physical id: 3 capabilities: pnp configuration: driver=i8042 aux *-pnp00:03 product: PnP device TOS1106 physical id: 4 capabilities: pnp configuration: driver=i8042 kbd *-pnp00:04 product: PnP device PNP0c02 physical id: 5 capabilities: pnp configuration: driver=system

As you can see, this computer is not precisely high-end, so here's my question:

I'm considering creating a small music-dedicated live iso to run on ram (based on slax, since av linux is quite heavy on resources).
Before compiling a low-latency kernel to go with it, I'd like to know if such kernel would be worth the trouble running on my hardware.

Thanks for your feedback.

Last edited by amc252 on Thu May 25, 2023 4:57 pm, edited 1 time in total.
Musicteacher
Established Member
Posts: 194
Joined: Mon Nov 13, 2017 5:54 am
Has thanked: 8 times
Been thanked: 4 times

Re: Would a low-latency kernel make a difference?

Post by Musicteacher »

Probably noone will be able to tell in advance if it will make a difference for you.

Also, you won't notice a difference when using a realtime kernel without making further adjustments.

Most people here use Jack, and try out different buffer sizes and then use the lowest buffer size which doesn't give xruns (dropouts).

So it might be that with a vanilla kernel you can have 256 pages buffer size, no dropouts, and with a rt-kernel , 128 pages buffer size. But if you leave your other settings as they are, you wil have exactly the same latency with a rt-kernel as with a vanilla kernel.

Are you using jack?

User avatar
Impostor
Established Member
Posts: 1390
Joined: Wed Aug 17, 2022 1:55 pm
Has thanked: 148 times
Been thanked: 365 times

Re: Would a low-latency kernel make a difference?

Post by Impostor »

amc252 wrote: Tue May 23, 2023 9:48 pm

Before compiling a low-latency kernel to go with it, I'd like to know if such kernel would be worth the trouble running on my hardware.

Thanks for your feedback.

Have you optimized your system for audio? If you do that there's probably no need for a low latency, let alone a real time, kernel. The following steps are working on my system (mint, so probably also for ubuntu and devian):

  1. Add yourself to the audio group:

    Code: Select all

    sudo usermod -a -G audio username
  2. To /etc/sysctl.conf, add:

    Code: Select all

     fs.inotify.max_user_watches = 524288
     vm.swappiness=10 
  3. /etc/security/limits.conf or /etc/security/limits.d/audio.conf should contain something like:

    Code: Select all

     @audio - rtprio 90       # maximum realtime priority
     @audio - memlock unlimited  # maximum locked-in-memory address space (KB)
    
  4. Open /etc/default/grub. Look for GRUB_CMDLINE_LINUX_DEFAULT and add threadirqs to the list of options:

    Code: Select all

    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash threadirqs"
    

    Save the file and update the grub configuration:

    Code: Select all

    sudo update-grub
    

    Reboot.

  5. Optionally (to prevent x-runs if they bother you) you could set your CPUs to performance. But that may not even be needed with new CPUs. (since I upgraded to AMD 5600X I almost never need to do this anymore)

  6. Use qjackctl to optimize jack settings for latency: set your buffer (too small will give distorted audio. too large gives too much latency) Do not set it smaller than you need though since this will tax your CPU unnecessarily. Set it to run realtime.

amc252
Established Member
Posts: 139
Joined: Fri May 05, 2023 12:24 am
Has thanked: 92 times
Been thanked: 22 times

Re: Would a low-latency kernel make a difference?

Post by amc252 »

Are you using jack?

Thanks for the suggestions. I'm trying different setups, with and without jack.
That's why I installed a fresh Devuan system in a separated partition, so I can tinker and experiment with it without screwing up my working distro.

Have you optimized your system for audio?

Not yet, but that's the idea.
I'm very new to linux audio, still at the beginning of my journey and all of your suggestions are precious.
So far, after learning how to connect everything (mainly fluidsynth and linuxsamper) all I did was trying out different soundfonts and SFZ piano samples, some lighter than others.

User avatar
onefang
Established Member
Posts: 148
Joined: Fri Feb 03, 2023 1:17 am
Location: Australia
Has thanked: 67 times
Been thanked: 11 times
Contact:

Re: Would a low-latency kernel make a difference?

Post by onefang »

amc252 wrote: Tue May 23, 2023 9:48 pm

Hello everybody,

I have set up a minimal devuan system on a spare partition to play around with music.
If I play my midi keyboard with fluidsynth there is no noticeable latency, but if I play it with linuxsampler I can see a slight delay.
So, I have installed a second kernel, low-latency liquorix-6.0.0-10.1-amd64 to see if it would improve performance.

Devuan has a RT kernel. It's what I use.

I prefer to be known as a figment of the 'nets imagination, living in the future, waiting for the rest of you to catch up.
Notes from Untalenz, an untalented old muso https://Untalenz.rocks/

amc252
Established Member
Posts: 139
Joined: Fri May 05, 2023 12:24 am
Has thanked: 92 times
Been thanked: 22 times

Re: Would a low-latency kernel make a difference?

Post by amc252 »

Thanks again for the suggestions.

Devuan has a RT kernel. It's what I use.

Yes, I installed that too but haven't tried it yet.

To /etc/sysctl.conf, add:

Code: Select all

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

I added the first line. Not having swap I assume the second is unnecessary.

/etc/security/limits.conf or /etc/security/limits.d/audio.conf should contain something like:

Code: Select all

@audio - rtprio 90       # maximum realtime priority
 @audio - memlock unlimited  # maximum locked-in-memory address space (KB)

my /etc/security/limits.conf has:

Code: Select all

@audio - rtprio 90
@audio - nice -10
@audio - memlock 500000

and /etc/security/limits.d/audio.conf has:

Code: Select all

@audio   -  rtprio     95
@audio   -  memlock    unlimited

Should I use only one setting?

User avatar
Impostor
Established Member
Posts: 1390
Joined: Wed Aug 17, 2022 1:55 pm
Has thanked: 148 times
Been thanked: 365 times

Re: Would a low-latency kernel make a difference?

Post by Impostor »

amc252 wrote: Wed May 24, 2023 9:37 pm

my /etc/security/limits.conf has:

Code: Select all

@audio - rtprio 90
@audio - nice -10
@audio - memlock 500000

and /etc/security/limits.d/audio.conf has:

Code: Select all

@audio   -  rtprio     95
@audio   -  memlock    unlimited

Should I use only one setting?

The settings in the limits.d/audio.conf file seemingly have precedence over those in the other file. So it's ok like that. And the niceness setting is irrelevant for realtime processes, if I remember correctly.

And it's not clear to me if setting swappiness has any effect at all, even if you do have a swap partition. I just copied those instructions from somewhere a couple of years ago. Some may have become obsolete.

amc252
Established Member
Posts: 139
Joined: Fri May 05, 2023 12:24 am
Has thanked: 92 times
Been thanked: 22 times

Re: Would a low-latency kernel make a difference?

Post by amc252 »

Well, I tried Impostor's setting and the Devuan RT kernel, and YES, there's a great difference.

I recorded video and audio in OBS Studio, trying both Linuxsampler + Amethyst Imperial Grand - Imperial Hall.sfz soundfonts, and also Pianoteq Grand Piano.
The latency that was very annoying in my previous recording is now down to negligible.
Also the cracking noises are completely gone, and the sound quality is rather good.

amc252
Established Member
Posts: 139
Joined: Fri May 05, 2023 12:24 am
Has thanked: 92 times
Been thanked: 22 times

Re: Would a low-latency kernel make a difference?

Post by amc252 »

Musicteacher wrote: Wed May 24, 2023 10:21 am

So it might be that with a vanilla kernel you can have 256 pages buffer size, no dropouts, and with a rt-kernel , 128 pages buffer size. But if you leave your other settings as they are, you wil have exactly the same latency with a rt-kernel as with a vanilla kernel.

You might be underestimating my ignorance.
When you say 'page buffer size' are you referring to the Frames/period setting in qjackctl parameters?

Musicteacher
Established Member
Posts: 194
Joined: Mon Nov 13, 2017 5:54 am
Has thanked: 8 times
Been thanked: 4 times

Re: Would a low-latency kernel make a difference?

Post by Musicteacher »

amc252 wrote: Thu May 25, 2023 6:48 am
Musicteacher wrote: Wed May 24, 2023 10:21 am

So it might be that with a vanilla kernel you can have 256 pages buffer size, no dropouts, and with a rt-kernel , 128 pages buffer size. But if you leave your other settings as they are, you wil have exactly the same latency with a rt-kernel as with a vanilla kernel.

You might be underestimating my ignorance.
When you say 'page buffer size' are you referring to the Frames/period setting in qjackctl parameters?

Yes, but I got that wrong myself, it's "frames", not pages.

amc252
Established Member
Posts: 139
Joined: Fri May 05, 2023 12:24 am
Has thanked: 92 times
Been thanked: 22 times

Re: Would a low-latency kernel make a difference?

Post by amc252 »

Thanks!
Little by little I'm getting there.
This forum is wonderful.

Post Reply