friendica.eskimo.com

Performance tanking during swapping

Hi guys!

I have what I'd consider a beefy gaming PC. AMD 7700 CPU, 32GB RAM, 7800XT 16GB, NVMe 1TB for OS, mSATA SSD 2TB for storage/games.

So...whenever I get a while using the computer, with a bunch of windows open, say firefox taking 4GB of RAM, total for everything a bit over 16GB...I'm prone to get a whole system slowdown/freeze, which can take a few full minutes until it settles. I can see the storage red led on the whole time without blinking, so it really looks like swapping.

However sometimes I don't see movements in the system process viewer, in usage from RAM/swap, I'd imagine those graphs would change if the data in swap has changed.

Swapping is set in the mSATA, taking 8GB, so I reckon that migth not be the fastest. Still, that's an SSD. I'm not sure how can I check/troubleshoot whatever is tanking my computer performance?

11 1
Even if you're not swapping, more RAM means more buffer and cache. 32GB isn't all that much, I've got 96GB in my workstation and 256GB in the server that runs friendica.

Been enjoying Linux for ~25 years, but have never been happy with how it handled low memory situations. Swapping have always killed the system, tho it have improved a little. It's been a while since I've messed with it. I've buckled up and are using more ram now, but afair, you can play with:

(0. reduce running software, and optimize them for less memory, yada yada)

  1. use a better OOM (out of memory) manager that activates sooner and more gracefully. Search in your OS' repository for it.
  2. use zram as a more intelligent buffer and to remove same (zero) pages. It can lightly compress lesser used memory pages and use a partition backend for storing uncompressible pages. You spend a little cpu, to minimize swap, and when needed, only swap out what can't be compressed.
  3. play with all the sysctl vm settings like swappiness and such, but be aware that there's SO much misinformation out there, so seek the official kernel docs. For instance, you can adapt the system to swap more often, but in much smaller chunks, so you avoid spending 5 minutes to hours regaining control - the system may get 'sluggish', but you have control.
  4. use cgroups to divide you resources, so firefox/chrome (or compilers/memory-hogs) can only use X amount before their memory have to swap out (if they don't adapt to lower mem conditions automatically). That leaves a system for you that can still react to your input (while ff/chrome would freeze). Not perfect, tho.
  5. when gaming, activate a low-system mode, where unnecessary services etc are disabled. I think there's a library/command that helps with that (and raise priority etc), but forgot its name.

EDIT: 6. when NOT gaming, add some of your vram as swap space. Its much faster than your ssd. Search github or your repository for 'vram cache' or something like that. It works via opencl, so everyone with dedicated vram can use it as super fast cache. Perhaps others can remember the name/link ?

Something like that anyway, others will know more about each point.

Also, perhaps ask an AI to create a small interface for you to fiddle with vm settings and cgroups in an automated/permanent way ? just a quick thought. Good luck.

This entry was edited (1 month ago)
1 1 1
I will add to all of this, which is basically good advice, also MONITOR how changes you make affect performance, use tools like glances, btop, iotop, top, free, to monitor various system parameters and modern kernels really do help a lot. I saw wait time go down quite a bit with 6.14 relative to 6.13, granted this is an environment with around 1000 simultaneous processes and even more threads, but I think it will help most loads. But bottom line, measure, measure, and then measure.

An SSD is a few thousand times slower than ram

What's your ram usage look like? Your system shouldn't need swap unless you are running something very ram intensive

This entry was edited (1 month ago)
1 1
Honestly you probably don't even need swap. On my Fedora box it uses zram instead of swap.
1
You shouldn't really use swap on an SSD in the first place. It reduces the drive's lifespan.
While true, you're still unlikely to see significant wear from a typical PC use case over the typical replacement time.
I try to keep in mind that replacement shouldn't mean landfill. When my needs have outgrown an SSD, it gets repurposed, donated, or sold. (Old ones still work great in computers used in education, special-purpose systems, test environments, refurbished laptops, appliance-like machines, etc.) In the long run, conserving SSD life while I own it translates into less waste and pollution in the world.
This entry was edited (1 month ago)
It reduces the drive’s lifespan.


Let's remember that swapping frequency and volume are system-dependent; practically zero on many systems. On a healthy system that doesn't swap much, having swap space on an SSD can be easier on the environment and wallet than buying and powering a separate device for it.

Nevertheless, I agree that minimizing SSD writes is worthwhile., and avoid the mindset of an SSD's useful lifetime ending when I'm done with it. (See my other comment.)

This entry was edited (1 month ago)