jamulussoftware / jamulus

Jamulus enables musicians to perform real-time jam sessions over the internet.
https://jamulus.io
Other
1.01k stars 224 forks source link

Disable memory swapping on Linux servers #3381

Open dtinth opened 1 month ago

dtinth commented 1 month ago

Short description of changes

Updated systemd unit file to disable swap on Jamulus process.

CHANGELOG: Server: Disabled swap memory usage on Linux.

Context: Fixes an issue?

I noticed that Jamulus server randomly (intermittently) become unresponsive for 0.3 – 1 seconds every once in a while. (This issue has happened for a long time prior.) This caused everyone to experience some sound drops (we call it "ตกหลุมอากาศ," an aviation term that refers to the experience of a cruising plane hitting an air pocket causing turbulence).

Last month I installed Netdata on my servers to collect detailed metrics. It seems that Linux has been paging some memory to/from disk every once in a while around the unresponsiveness occurs.

So systemd has the ability to prevent an app from using swap space. This might help with this issue. From my preliminary testing, it seems to have helped, albeit not completely.

As memory footprint of Jamulus server is very minimal (19.7M used after 8 months of uptime) I think this config change should not have any negative impact unless the server is run on a potato.

Does this change need documentation? What needs to be documented and how?

No.

Status of this Pull Request

Ready

What is missing until this pull request can be merged?

N/A

Checklist

ann0see commented 1 month ago

Thanks. But why would the OS swap in the first place? The app is active and ram should be available for such a small footprint.

Maybe the server is running too much other stuff?

dtinth commented 1 month ago

Yeah, the server runs other stuff too (such as a system that broadcasts MP3 streams, some web servers), so that’s a possible cause. I did cat /proc/<pid>/smaps before the change and some memory is indeed in the swap area.

The system I was running happens to have vm.swappiness = 60 (default value), so I think there is always a chance that the system moves the memory to swap area despite Jamulus having a low memory footprint and the system having plenty of free RAM.

softins commented 1 month ago

I've added this change to my own servers, but I can't actually test properly until I'm back home after my holiday.

pljones commented 1 month ago

Added to my servers and directories. I've a few other bits:

[Service]
CPUSchedulingPolicy=fifo
CPUSchedulingPriority=20
IOSchedulingClass=realtime
IOSchedulingPriority=3
MemorySwapMax=0

No idea if the differences help.