Audio stutters then stops when compiling (heavy cpu usage)

I’ve recently installed manjaro after coming from OpenSuse and to a lesser extend kde neon (aka Ubuntu 22.04).

I got my build environment setup, but when compiling a large program, eg ardupilot, any audio that is running, eg spotify, teams, vlc… , begins to stutter before eventually just crapping out.

In this case the build environment uses waf to spawn multiple compilation threads (gcc/g++).

This occurs even if I limit the number of cpu’s that the compilation takes, i.e. nproc reports 16 processors, so if I limit the multiprocess compilations to 6, I still get the issue.

I noticed that the kswap process owned by root is taking an exceptionally large amount of cpu, but I have no idea if this is normal in manjaro.

Historically, I’ve used pulse and not pipewire, so I’m not sure how to restart pipewire while logged in, so I’ve been having to log out and log back in whenever this occurs which is not super efficient.

Since I like to listen to music while I work, or participate in work meetings, this is a bit of an issue.

Thanks.

Hello @gnac, welcome to the forum

Which instructions are you using to build? It is manual compilation or from the AUR?

Manual compilation per the ardupilot build instructions.
eg
./waf configure
./waf build

For what its worth, the issue is more about the interference with pipewire.
I suspect its because the build is taking a lot of resources, but I would perhaps expect a bit of stuttering while the build is running, but pipewire/sound remains hosed after the build completes.

I now suspect that I’m running out of memory and the system is randomly shutting down important processes.
For example, eclipse (my ide) keeps shutting down, even when I’m not compiling. Additionally, something to shutdown Kate, but because I had an unsaved document in it, a popup asked me to save it. I wasn’t even on the kate window.
I noticed during installation that I was informed about using a swap file instead of a partition.
Is there a way to manage that?

Restoring PipeWire and Wireplumber settings to default

systemctl --user restart pipewire pipewire-pulse wireplumber
1 Like

This will be helpful to you:

Also this, which enables you to use your RAM as compressed swap space:

https://wiki.archlinux.org/title/Zram

I recommend using zram-generator - it makes the whole process very simple.

1 Like

That is entirely possible

There is multiple selections when installing

  • no swap
  • swap - no hibernate
  • swap - with hibernate
  • swapfile

The latter is easy to resize

swapon

Then disable swap for the swap device e.g. /swapfile

sudo swapoff /swapfile

Then create a new file of the desired size e.g. 16GB - see the wiki article

SIZE=16384
sudo dd if=/dev/zero of=/swapfile bs=1M count=$SIZE status=progress

Then activate swap

sudo swapon /swapfile

Worth considering - /tmp default to tmpfs which initialize to half your RAM size - so when compiling you may run out of memory - especially on compiling large sources.

Comment the tmp in your fstab - that will change your /tmp to be on the physical disk - that may improve on your system responsiveness during compilation.

Decoding video may not be offloaded to GPU but instead done by CPU - depending on configuration.

1 Like

I chose swapfile, but apparently a swapfile wasn’t created, or if it was, it wasn’t “mounted” via /etc/fstab. I’ve gone ahead and manally created the swapfile and added it to fstab.

Ah, thats a good tip, it is indeed setup to half my ram. Thanks.
Is there a way to set up /tmp to behave like a swapfile, eg I like that it is in fact temporary when in ram, but I don’t want to sacrifice the ram. Ideally create a /tmpfile that tmp is mounted to similar to /swapfile.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.