Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio underrun issues related to pipewire priority #114

Closed
fruitchewy opened this issue Mar 24, 2024 · 5 comments · Fixed by #118
Closed

Audio underrun issues related to pipewire priority #114

fruitchewy opened this issue Mar 24, 2024 · 5 comments · Fixed by #118

Comments

@fruitchewy
Copy link

fruitchewy commented Mar 24, 2024

I've been seeing a lot of underrun/skipping/crackling issues in pipewire since switching to the system76 scheduler. After playing with quantums and buffer sizes for many hours, I noticed the pipewire process was claiming a niceness value of 49. I assume that's an artifact of something system76 is doing with the bespoke priority values for pipewire, but it sent me down the right troubleshooting path.

I've ultimately managed to resolve all of my issues while still using default low latency quantums by changing
sound-server nice=-15 sched=(fifo)49 io=(realtime)0 {
to
sound-server nice=-15 io=(realtime)0 {
in my config.kdl

I'm not sure if this isn't working as intended, or if fifo realtime just isn't playing nice with pipewire, but everything seems to be working great with just the niceness and realtime io set. Wanted to share in case this isn't working as intended or could be relevant to #99 or #102 .

System info:
ASUS B550-I motherboard audio (Starship/Matisse HD Audio)
System76 Scheduler as default in Bazzite

@liammcdermott
Copy link

liammcdermott commented Mar 25, 2024

@fruitchewy I've been experiencing the same thing for months, and figured out it was system76-scheduler one day after you! Thank you for making this issue, it's good to know I'm not alone.


Below are the niceness values on my machine. Before making the change in OP:

$ ps -elf | grep pipewire
4 S root        3713    2218  0  92  12 - 42747 -      21:52 ?        00:00:00 /usr/bin/system76-scheduler pipewire
0 S liam        6618    6603  1  69 -11 - 44977 ep_pol 21:58 ?        00:02:15 /usr/bin/pipewire
0 S liam        6634    6603  0  80   0 -  6583 ep_pol 21:58 ?        00:00:00 /usr/bin/pipewire -c filter-chain.conf
0 S liam        6635    6603  0  69 -11 - 46585 ep_pol 21:58 ?        00:01:12 /usr/bin/pipewire-pulse

Then after:

$ ps -elf | grep pipewire
0 S liam        6618    6603  1  65 -15 - 44977 ep_pol Mar24 ?        00:09:44 /usr/bin/pipewire
0 S liam        6634    6603  0  65 -15 -  6583 ep_pol Mar24 ?        00:00:00 /usr/bin/pipewire -c filter-chain.conf
0 S liam        6635    6603  0  65 -15 - 46585 ep_pol Mar24 ?        00:03:40 /usr/bin/pipewire-pulse
4 S root      100086  100077  0  92  12 - 23798 -      10:18 ?        00:00:00 /usr/bin/system76-scheduler pipewire

The before values don't seem right, niceness should be -15, not a mix of -12 and 0. The after values look correct and lead to less Rice Krispies effect in my recorded audio.

Could it be, system76-scheduler isn't able to set sched=(fifo)49 for some reason, and therefore doesn't set the other priorities (niceness, io)?

journalctl -u com.system76.Scheduler.service turns up no errors (or anything else relevant), just the service stopping and starting successfully on reboot.

System info:
Audient iD4 audio interface, this issue happens when recording audio (and when listening, but to a lesser extent).
Ubuntu 23.10
My system76-scheduler configuration is default, besides the change described in OP.

@liammcdermott
Copy link

liammcdermott commented Mar 25, 2024

Just in case it's useful information, adding sched=(fifo)49 back into the sound-server profile -- and restarting the system76-scheduler service -- yields these results:

$ ps -elf | grep pipewire
0 S liam        6618    6603  1  10   - - 45014 ep_pol Mar24 ?        00:10:54 /usr/bin/pipewire
0 S liam        6634    6603  0  10   - -  6583 ep_pol Mar24 ?        00:00:00 /usr/bin/pipewire -c filter-chain.conf
0 S liam        6635    6603  0  10   - - 43519 ep_pol Mar24 ?        00:04:07 /usr/bin/pipewire-pulse
4 S root      109511  109502  0  92  12 - 23798 -      11:56 ?        00:00:00 /usr/bin/system76-scheduler pipewire

Edit: This looks better than my other results, since niceness values aren't applicable to processes with realtime priorities set (AFAICT, YMMV).

ps also showing realtime priorities:

$ sudo ps -e -o pid,uid,pri,nice,rtprio,vsz,rss,tty,stat,start,time,comm | grep -E 'PID|pipewire'
    PID   UID PRI  NI RTPRIO    VSZ   RSS TT       STAT  STARTED     TIME COMMAND
   7939  1000  89   -     49 141344 20924 ?        S<sl 13:16:20 00:07:21 pipewire
   7955  1000  89   -     49  26332  5888 ?        S<sl 13:16:20 00:00:00 pipewire
   7957  1000  89   -     49 167412 34064 ?        S<Lsl 13:16:20 00:05:08 pipewire-pulse

@liammcdermott
Copy link

I've been testing playing and recording audio over the past couple of days, and mine is now good. Here's what I did:

  • My niceness values are the same as in my last ps example above ^^, i.e. realtime priorities are in effect, after I restarted system76-scheduler.
  • In /etc/default/grub I added threadirqs to GRUB_CMDLINE_LINUX_DEFAULT

I'm not sure the realtime priorities will stick after a reboot, I'll have to wait and see.

@mmstick
Copy link
Member

mmstick commented Mar 28, 2024

Feel free to submit a PR with the priority adjustments

@gcentauri
Copy link
Contributor

Original Post helped me out today. Haven't had a single pipewire error since changing the config and restarting the system76 scheduler. previously I would get ~5 per song I'd try to play. I made the PR for the small change, but I don't have any deeper knowledge of what it changes :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants